/* mechbox-chrome v1.6.0
 * Shared header + footer for Mechbox ecosystem landings.
 * Public API: classes mb-header__*, mb-footer__*, attributes data-app, data-theme, data-section.
 * See CONTRACT.md before changing.
 *
 * v1.6.0: 4-я плитка Gallery в eco-nav. TypeScript: ChromeApp +=  "gallery". Mobile: 2x2 grid instead of 3 cols.
 * v1.5.0: eco-nav прячется на внутренних страницах. React: проп hideEcoNav.
 *          Static HTML: data-hide-eco="true" на .mb-header.
 *          См. docs/design/INTERFACE-DESIGN-SYSTEM.md (Концепция 2 — правило лендингов).
 * v1.4.1: bugfix — .mb-header__cta-slot теперь имеет order:99 как .mb-header__cta,
 *          иначе грид auto-placement клал слот в центральную колонку (где eco-nav).
 * v1.4.0: добавлены ctaSlot/location/locationHref props на Header для adult shell.
 * v1.3.0: CTA параметризована (текст + href). На shop — «Каталог», на остальных — «Войти».
 * v1.2.0: breadcrumb уровень 2 (.mb-header__brand-module) теперь <a> с href на корень модуля.
 *          Eco-nav центрирован относительно шапки через grid 1fr/auto/1fr (не 1fr/auto/auto).
 * v1.1.0: drop hamburger+drawer for landings — only 3 sections, drawer was overkill.
 *          On mobile, eco-nav becomes 3 equal-width tiles (long labels collapse to short).
 */

:where(.mb-header, .mb-footer) {
  --mb-bg: rgba(255,255,255,0.85);
  --mb-bg-solid: #FFFFFF;
  --mb-text: #0E0E11;
  --mb-text-2: #404048;
  --mb-text-3: #6E6E78;
  --mb-line: rgba(14,14,17,0.08);
  --mb-line-strong: rgba(14,14,17,0.16);
  --mb-accent: #C0451A;
  --mb-accent-hover: #E54A0F;
  --mb-on-accent: #FFFFFF;
  --mb-footer-bg: #14110D;
  --mb-footer-text: rgba(255,255,255,0.75);
  --mb-footer-text-dim: rgba(255,255,255,0.5);
  --mb-footer-text-faint: rgba(255,255,255,0.45);
  --mb-footer-line: rgba(255,255,255,0.1);
  --mb-stripe-1: #FF5A1F;
  --mb-stripe-2: #2563EB;
  --mb-stripe-3: #C7F800;
  --mb-radius-md: 8px;
  --mb-radius-lg: 14px;
  --mb-radius-pill: 999px;
  --mb-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --mb-dur: 150ms;
  --mb-font-sans: 'Inter Tight', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mb-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mb-header[data-theme="dark"],
.mb-footer[data-theme="dark"] {
  --mb-bg: rgba(15,23,42,0.72);
  --mb-bg-solid: #0F172A;
  --mb-text: #F8FAFC;
  --mb-text-2: rgba(248,250,252,0.78);
  --mb-text-3: rgba(248,250,252,0.55);
  --mb-line: rgba(255,255,255,0.10);
  --mb-line-strong: rgba(255,255,255,0.20);
  --mb-accent: #60A5FA;
  --mb-accent-hover: #93C5FD;
  --mb-on-accent: #0F172A;
}

/* ════════════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════════ */
.mb-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--mb-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--mb-line);
  font-family: var(--mb-font-sans);
  color: var(--mb-text);
}

.mb-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 32px;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
  flex-wrap: wrap;
  row-gap: 10px;
}

/* Desktop (≥900px): grid with symmetric 1fr/auto/1fr columns so eco-nav sits
 * ROW-CENTERED relative to the whole header, not centered between brand and CTA.
 * Required by the design system — see docs/design/INTERFACE-DESIGN-SYSTEM.md
 * ("Концепция 2. Eco-nav — переключатель экосистемы"). Когда CTA скрыта через
 * data-no-cta, третья колонка остаётся (display:none не убирает grid track),
 * поэтому центровка eco-nav сохраняется. */
@media (min-width: 900px) {
  .mb-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    flex-wrap: nowrap;
    row-gap: 0;
  }
  .mb-header__brand { justify-self: start; }
  .mb-header__eco {
    justify-self: center;
    flex: initial;     /* override flex:1 1 auto from base rule */
    min-width: 0;
  }
  .mb-header__cta {
    justify-self: end;
    order: initial;    /* grid does the ordering, no flex order hack needed */
  }
}

.mb-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
}

.mb-header__brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--mb-text);
  text-decoration: none;
  transition: color var(--mb-dur) var(--mb-ease);
}
.mb-header__brand-link:hover { color: var(--mb-accent); }

.mb-header__logo {
  width: 40px;
  height: 40px;
  display: block;
  flex-shrink: 0;
}

.mb-header__brand-name {
  display: inline-block;
}

.mb-header__brand-sep {
  color: var(--mb-text-2);
  font-weight: 300;
  opacity: 0.5;
  user-select: none;
}

.mb-header__brand-module {
  font-family: var(--mb-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mb-text-2);
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--mb-dur) var(--mb-ease);
}
.mb-header__brand-module:hover { color: var(--mb-text); }

.mb-header__brand-location {
  color: var(--mb-text-3);
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--mb-dur) var(--mb-ease);
}
.mb-header__brand-location:hover {
  color: var(--mb-text);
}

.mb-header__cta-slot {
  justify-self: end;
  display: flex;
  align-items: center;
  order: 99;
}

.mb-header[data-app="home"] .mb-header__brand-sep,
.mb-header[data-app="home"] .mb-header__brand-module {
  display: none;
}

/* Eco-nav: desktop = inline links with long labels and underline-active.
 * Mobile (<900px) = three equal-width tiles with short labels and accent-bg-active.
 * The same DOM serves both: short/long labels are toggled via CSS.
 * Desktop layout uses flex-grow + justify-content:center to occupy the middle column
 * (no auto-margins — they fight CTA's margin-left:auto and pull CTA to the centre). */
.mb-header__eco {
  display: inline-flex;
  align-items: center;
  gap: 32px;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
  font-size: 14px;
}

.mb-header__brand { flex-shrink: 0; }

.mb-header__eco-link {
  color: var(--mb-text-2);
  text-decoration: none;
  padding-bottom: 4px;
  font-weight: 500;
  transition: color var(--mb-dur) var(--mb-ease), background var(--mb-dur) var(--mb-ease);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mb-header__eco-link:hover { color: var(--mb-text); }

.mb-header__eco-short { display: none; }

/* Active section auto-highlight: data-app on header matches data-section on link */
.mb-header[data-app="edu"] .mb-header__eco-link[data-section="edu"],
.mb-header[data-app="make"] .mb-header__eco-link[data-section="make"],
.mb-header[data-app="shop"] .mb-header__eco-link[data-section="shop"],
.mb-header[data-app="gallery"] .mb-header__eco-link[data-section="gallery"] {
  color: var(--mb-text);
  font-weight: 700;
  border-bottom: 2px solid var(--mb-accent);
}

.mb-header__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--mb-radius-md);
  background: var(--mb-accent);
  color: var(--mb-on-accent);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background var(--mb-dur) var(--mb-ease), transform var(--mb-dur) var(--mb-ease);
  white-space: nowrap;
  flex-shrink: 0;
  order: 99;  /* DOM has CTA before eco-nav so it lands on row 1 with brand on mobile;
                 on desktop, push it visually to the end (after eco-nav) */
}
.mb-header__cta:hover {
  background: var(--mb-accent-hover);
  transform: translateY(-1px);
}
.mb-header__cta:active { transform: scale(0.98); }

.mb-header[data-no-cta="true"] .mb-header__cta { display: none; }

/* Eco-nav скрывается на внутренних страницах сервисов (кабинеты, личные пути) —
 * показывается только на лендингах. См. docs/design/INTERFACE-DESIGN-SYSTEM.md
 * (Концепция 2). React: проп hideEcoNav. Static HTML: data-hide-eco="true". */
.mb-header[data-hide-eco="true"] .mb-header__eco { display: none; }

@media (max-width: 899px) {
  /* Mobile/narrow tablet: brand row 1 (logo + name + CTA), eco-nav row 2 as tiles.
   * Level-3 breadcrumb (brand-location) wraps to its own row beneath brand
   * to satisfy spec §2.2 ("семантика трёх уровней сохраняется, переносится
   * на отдельную строку"). Level-2 (brand-module) remains hidden on mobile
   * to keep the top row compact. */
  .mb-header__inner { padding: 12px 16px; gap: 12px; }
  .mb-header__brand {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .mb-header__brand-sep,
  .mb-header__brand-module { display: none; }
  .mb-header__brand-location {
    flex: 1 1 100%;
    font-size: 0.8125rem;
    padding-top: 2px;
  }
  .mb-header__cta {
    order: 0;          /* back to natural DOM position so it sits on row 1 with brand */
    margin-left: auto;
    padding: 8px 14px;
    font-size: 13px;
  }
  .mb-header__eco {
    flex: 1 1 100%;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 13px;
    border-top: 1px solid var(--mb-line);
    padding-top: 10px;
  }
  .mb-header__eco-link {
    min-width: 0;
    padding: 10px 6px;
    border-radius: var(--mb-radius-md);
    background: var(--mb-line);
    color: var(--mb-text-2);
    font-weight: 600;
    text-align: center;
  }
  .mb-header__eco-link:hover { background: var(--mb-line-strong); color: var(--mb-text); }
  .mb-header__eco-link:active { transform: scale(0.97); }
  .mb-header__eco-long { display: none; }
  .mb-header__eco-short { display: inline; }
  .mb-header[data-app="edu"] .mb-header__eco-link[data-section="edu"],
  .mb-header[data-app="make"] .mb-header__eco-link[data-section="make"],
  .mb-header[data-app="shop"] .mb-header__eco-link[data-section="shop"],
  .mb-header[data-app="gallery"] .mb-header__eco-link[data-section="gallery"] {
    background: var(--mb-accent);
    color: var(--mb-on-accent);
    border-bottom: none;
  }
}

@media (max-width: 359px) {
  /* Extra-narrow: drop the brand text, keep just the logo so tiles row stays comfortable. */
  .mb-header__brand-name { display: none; }
}

/* ════════════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════════ */
.mb-footer {
  background: var(--mb-footer-bg);
  color: var(--mb-footer-text);
  padding: 96px 0 32px;
  margin-top: 48px;
  position: relative;
  overflow: hidden;
  font-family: var(--mb-font-sans);
}
.mb-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg,
    var(--mb-stripe-1) 0%,
    var(--mb-stripe-1) 33%,
    var(--mb-stripe-2) 33%,
    var(--mb-stripe-2) 66%,
    var(--mb-stripe-3) 66%,
    var(--mb-stripe-3) 100%);
}

.mb-footer__inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
}

.mb-footer__brand-col { max-width: 360px; }
.mb-footer__brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #FFFFFF;
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.mb-footer__logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-block;
  flex-shrink: 0;
}
.mb-footer__brand-name { display: inline-block; }
.mb-footer__tagline {
  font-size: 14px;
  line-height: 1.6;
  color: var(--mb-footer-text);
}

.mb-footer__nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
.mb-footer__col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mb-footer__col-title {
  font-family: var(--mb-font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mb-footer-text-dim);
  font-weight: 600;
  margin-bottom: 4px;
}
.mb-footer__col a {
  color: var(--mb-footer-text);
  text-decoration: none;
  font-size: 14px;
  transition: color var(--mb-dur) var(--mb-ease);
}
.mb-footer__col a:hover { color: var(--mb-stripe-1); }

.mb-footer__bottom {
  width: 100%;
  max-width: 1280px;
  margin: 48px auto 0;
  padding: 24px 32px 0;
  border-top: 1px solid var(--mb-footer-line);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-family: var(--mb-font-mono);
  color: var(--mb-footer-text-faint);
}
.mb-footer__copy { line-height: 1.5; }
.mb-footer__socials {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.mb-footer__socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--mb-footer-line);
  color: var(--mb-footer-text);
  text-decoration: none;
  transition: background var(--mb-dur) var(--mb-ease), color var(--mb-dur) var(--mb-ease), transform var(--mb-dur) var(--mb-ease);
}
.mb-footer__socials a:hover {
  background: rgba(255,255,255,0.10);
  color: #FFFFFF;
  transform: translateY(-2px);
}
.mb-footer__socials svg { width: 18px; height: 18px; }

@media (min-width: 800px) {
  .mb-footer__inner {
    grid-template-columns: 1.4fr 2.6fr;
    align-items: start;
  }
  .mb-footer__nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 32px;
  }
}
@media (max-width: 480px) {
  .mb-footer { padding: 64px 0 24px; }
  .mb-footer__inner { padding: 0 20px; }
  .mb-footer__bottom {
    padding: 20px 20px 0;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}
