/* =============================================================================
   header-mobile.css — mobile header component
   Visible below 1024px. Completely independent of header-desktop.css.

   Responsibilities:
   - Fixed 72px bar at the top of the viewport.
   - Three-zone layout: [back chevron] [page title] [menu toggle].
   - Center title is always visually centered, regardless of icon visibility.
   - Owns the mobile nav toggle and its open/close icon swap.
   - Back chevron is shown/hidden by js/nav.js based on the current page.

   Shares design tokens (colors, spacing, typography) with header-desktop.css
   but has no shared HTML structure, CSS rules, or JavaScript behavior.
   ============================================================================= */


/* ── Component shell ─────────────────────────────────────────────────────────── */

.header-mobile {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--layout-header-height);           /* 72px */
  padding-top: env(safe-area-inset-top);
  background-color: var(--color-carbon);

  /* Three-zone grid — equal-width flanks guarantee the title is optically centred */
  display: grid;
  grid-template-columns: 44px 1fr 44px;          /* 44px = minimum touch-target width */
  align-items: center;
  padding-inline: var(--layout-margin);          /* 24px from each edge */
}


/* ── Zone containers ─────────────────────────────────────────────────────────── */

.header-mobile__left,
.header-mobile__right {
  display: flex;
  align-items: center;
}

.header-mobile__right {
  justify-content: flex-end;
}


/* ── Center title ────────────────────────────────────────────────────────────── */
/*
 * Displays the studio name ("Vertical Works") or, on inner pages,
 * the current page name. Always horizontally and vertically centered.
 */

.header-mobile__title {
  display: block;
  text-align: center;
  font-family: var(--font-family-base);
  font-size: 0.875rem;                           /* 14px */
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-white);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ── Back button — left zone ─────────────────────────────────────────────────── */
/*
 * Visible on inner pages; hidden on the home page.
 * The [hidden] attribute is toggled by js/nav.js.
 * The 44px grid column always reserves space so the title stays centred
 * even when the button is not rendered.
 */

.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;                                   /* minimum touch target */
  height: 44px;                                  /* minimum touch target */
  background: none;
  border: none;
  padding: 0;
  color: var(--color-white);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.nav-back img {
  display: block;
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.nav-back:focus-visible {
  outline: 2px solid var(--color-rose-400);
  outline-offset: 2px;
  border-radius: 4px;
}

/* [hidden] hides the button; the grid column preserves the zone width */
.nav-back[hidden] {
  display: none;
}


/* ── Navigation toggle — right zone ─────────────────────────────────────────── */
/*
 * Toggles the nav panel (nav.css / js/nav.js).
 * Icon is a CSS-drawn three-bar hamburger that animates into an X.
 * aria-expanded="true" drives the animation — no JS class needed.
 *
 * Geometry:
 *   Bar: 20px × 2px, gap 5px between bars.
 *   Total icon height: 3×2 + 2×5 = 16px, centered in 44px button.
 *   X offset: center of bar 1 to center of bar 2 = 2 + 5 = 7px.
 */

.nav-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;                                   /* minimum touch target */
  height: 44px;                                  /* minimum touch target */
  background: none;
  border: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--color-rose-400);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Three bars — hamburger in closed state */
.nav-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--color-white);
  border-radius: 1px;
  transform-origin: center;
  transition:
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity   300ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Open state: bars animate into an X */
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* ── Desktop: hide this component entirely ───────────────────────────────────── */

@media (min-width: 1024px) {
  .header-mobile {
    display: none;
  }
}
