/* =========================================================================
   site-header.css — the live Triptico site header (brand, Teachers/Students
   reveal panels, student code form, Start/Sign In actions) ported into the
   Class League home experiment.

   Ported VERBATIM from css/home.css (the live header), scoped under
   `.site-header` (root as `header.site-header`) so it can't collide with Class
   League's OWN .site-header / .brand / .site-nav / .nav-link rules in
   styles.css. Load this file LAST. Tokens it relies on (bg, surface, ink,
   accent, border, radius, gold, error) already live in CL's :root, with accent
   overridden to Triptico blue in triptico-skin.css.

   The header gutter is the literal clamp(16px, 3vw, 48px), repeated on the
   header padding and the panel left/right so their edges line up (kept inline
   rather than a custom property to stay self-contained). The page-dim scrim
   (body::before) is the one intentionally global rule.
   ========================================================================= */

/* ---------- Buttons (nav actions + code-go) ---------- */
.site-header .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 24px;
  min-height: 2.75rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    rgba(0, 0, 0, 0.1) 0 1px 2px,
    rgba(0, 0, 0, 0.06) 0 -2px 0 inset;
  transition:
    filter 0.15s ease,
    transform 0.02s ease,
    background 0.15s ease;
}
.site-header .btn:hover {
  filter: brightness(1.07);
}
.site-header .btn:active {
  transform: translateY(1px);
}
.site-header .btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.site-header .btn--outline {
  background: var(--surface);
  color: var(--accent);
  box-shadow: none;
}
.site-header .btn--outline:hover {
  background: rgba(52, 152, 219, 0.07);
  filter: none;
}

/* ---------- Header bar ---------- */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(16px, 3vw, 48px);
  background: var(--surface);
  border-bottom: 0; /* CL's .site-header adds one; the box-shadow replaces it */
  box-shadow:
    rgba(9, 30, 66, 0.06) 0 1px 2px,
    rgba(9, 30, 66, 0.12) 0 8px 24px -16px;
  /* Promote the sticky bar to its own compositor layer. Without this, iOS
     repaints the header AND its soft box-shadow over the page content on every
     scroll frame — the cause of the iPad header judder. As its own layer it's
     simply composited over the scrolling content, no per-frame repaint. */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.site-header .brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.site-header .brand-logo {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  background: var(--accent);
  border-radius: 9px;
  box-shadow:
    rgba(0, 0, 0, 0.1) 0 1px 2px,
    rgba(0, 0, 0, 0.1) 0 -2px 0 inset,
    rgba(255, 255, 255, 0.18) 0 2px 0 inset;
}
.site-header .brand-logo img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  display: block;
}
.site-header .brand-name {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.site-header .site-nav {
  justify-self: center;
}
.site-header .nav-list {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-header .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}
.site-header .nav-link:hover {
  color: var(--ink);
  background: rgba(17, 24, 39, 0.05);
}
.site-header .nav-caret {
  width: 10px;
  height: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: transform 0.18s ease;
}
.site-header .nav-link[aria-expanded='true'] .nav-caret {
  transform: rotate(180deg);
}
.site-header .nav-link[aria-expanded='true'] {
  background: var(--gold);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.025);
  color: var(--ink);
}
.site-header .nav-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Header panels (Teachers / Students) ---------- */
.site-header .nav-panel {
  position: absolute;
  top: calc(100% + 8px);
  /* Positioned against the sticky header (its containing block), so top:100% is
     just below the bar and the gutter matches the header's own side padding. */
  left: clamp(16px, 3vw, 48px);
  right: clamp(16px, 3vw, 48px);
  z-index: 10;
  min-height: 158px;
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow:
    rgba(0, 0, 0, 0.4) 0px 2px 4px,
    rgba(0, 0, 0, 0.3) 0px 7px 13px -3px,
    rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
}
.site-header .nav-panel[hidden] {
  display: none;
}
.site-header .panel-cards {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.site-header .panel-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  padding: 24px;
  background: none;
  border: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  font: inherit;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  border-radius: 0;
}
.site-header .panel-card:first-child {
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.site-header .panel-card:last-child {
  border-right: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.site-header .panel-card:hover {
  background: #fff;
  box-shadow: rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
}
.site-header .panel-icon {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--ink);
  flex-shrink: 0;
}
.site-header .panel-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.site-header .panel-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  margin: 0;
}
.site-header .panel-text strong {
  font-size: 0.95rem;
  font-weight: 600;
}
.site-header .panel-text span {
  font-size: 0.82rem;
  color: var(--muted);
}
/* Students panel: info cell (col 2) + code cell (cols 3-4), framed by dividers */
.site-header .panel-split {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
}
.site-header .panel-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  padding: 24px;
}
.site-header .panel-split .panel-cell:first-child {
  grid-column: 2;
  border-left: 1px solid rgba(0, 0, 0, 0.05);
  background: #fff;
  box-shadow: rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
}
.site-header .panel-cell--form {
  grid-column: 3 / 5;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  background: #fff;
  box-shadow: rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
}
.site-header #code-title.is-error {
  color: var(--error);
}
.site-header .code-form {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  background: rgba(0, 0, 0, 0.1);
  padding: 6px;
  border-radius: var(--radius-md);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.site-header .code-form input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
}
.site-header .code-form input:focus {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.site-header .code-go {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
}
.site-header .code-go svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
  display: block;
}

/* ---------- Mobile nav toggle ---------- */
.site-header .nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  padding: 0 10px;
  background: none;
  border: 0;
  cursor: pointer;
}
.site-header .nav-toggle span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}
/* Burger morphs into an X when the menu is open. Bars are 2px tall with a 4px
   gap, so centres sit 6px apart: collapse the outer two onto the middle and
   cross them, fade the middle out. */
.site-header.nav-open .nav-toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.site-header.nav-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}
.site-header.nav-open .nav-toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 880px) {
  /* Header collapses: brand + burger on top; nav + actions stack below. */
  header.site-header {
    display: flex;
    flex-wrap: wrap;
    padding: 10px 16px;
  }
  .site-header .nav-toggle {
    display: flex;
    margin-left: auto;
  }
  .site-header .site-nav,
  .site-header .nav-actions {
    flex-basis: 100%;
    display: none;
  }
  .site-header.nav-open .site-nav {
    display: block;
  }
  .site-header.nav-open .nav-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 8px;
  }
  .site-header .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  .site-header .nav-link {
    width: 100%;
    justify-content: space-between;
  }
  .site-header .nav-panel {
    position: static;
    min-height: 0;
    box-shadow: none;
    border-radius: 0;
    padding-left: 10px;
  }
  .site-header .panel-cards,
  .site-header .panel-split {
    grid-template-columns: 1fr;
  }
  .site-header .panel-card,
  .site-header .panel-cell {
    padding: 12px 8px;
  }
  .site-header .panel-split .panel-cell:first-child,
  .site-header .panel-cell--form {
    grid-column: auto;
  }
}

/* ---------- Page-dim scrim behind open nav panels (intentionally global) ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 22, 42, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    visibility 0s linear 0.25s;
}
body.nav-scrim-on::before {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
@media (prefers-reduced-motion: reduce) {
  body::before {
    transition: none;
  }
}
