/* =========================================================================
   Page — the developer landing page ({en,de}/developer.html)
   -------------------------------------------------------------------------
   The grammar is DESIGN_TOKENS.md §9. Two things about this page in
   particular:

   THE TERMINAL PANEL IS NOT PINNED DARK. `code-panel.css` already themes it
   through `--doc-code-bg`, which is the token §5 defines for exactly this. A
   panel hard-coded to a dark palette would be §5a's mistake in reverse: those
   four constants exist for surfaces that are dark in BOTH themes — the brand
   gradient and the portal sidebar — and a code sample is neither.

   Except here it sits INSIDE the gradient hero, which IS always dark. So the
   panel gets one override in that one place, and it uses `--brand-on-dark`,
   which is the constant §5a defines for text on the gradient.

   THE TABS ARE CSS. Three radios, three panels, `:checked ~`. No JavaScript,
   keyboard-operable by the browser, correct with scripting off — which a click
   handler toggling `hidden` would not be. The radio is visually hidden and the
   label is the tab, so the focus ring has to be moved onto the label by hand:
   `:focus-visible` on an element nobody can see is a keyboard user with no
   indication of where they are.
   ========================================================================= */

/* ---- The hero ------------------------------------------------------------- */

.dev-hero {
  align-items: center;
}

/* The hero's emphasis is the mint, not italics (redesign R8f, U-2282). */
.page-hero h1 em {
  font-style: normal;
  color: var(--brand-mint);
}

/* The one place a code panel sits on the brand gradient. Everything outside
   this block keeps the themed panel. */
.page-hero .dev-terminal {
  border-color: var(--brand-on-dark);
  /* The gradient has 0.19 of contrast headroom and nothing painted on it may
     lighten it (L-FE-17), so the panel keeps its own opaque ground rather than
     tinting the hero. */
  background: var(--doc-code-bg);
}

@media (max-width: 900px) {
  .dev-terminal {
    /* Below the split's breakpoint the panel is a full-width block under the
       prose, and a code sample that forced the hero wider would take the whole
       page with it. */
    max-width: 100%;
  }
}

/* ---- The CSS tabs --------------------------------------------------------- *
 * Visually hidden rather than `display: none`: a radio that is not displayed is
 * removed from the tab order, which would leave the tab strip unreachable by
 * keyboard. This keeps it focusable and invisible, and the label shows the ring.
 * ------------------------------------------------------------------------- */

.dev-tab-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The two planes as one panel (redesign R8f, U-2282): the tab strip on top,
   the chosen panel's words beside its code from 900 px, stacked below. On the
   alternating band the panel takes the muted ground, as a card does. */
.dev-tabs {
  border-radius: var(--radius);
  background: var(--doc-panel);
  overflow: hidden;
}

.section-alt .dev-tabs {
  background: var(--sd-surface-alt);
}

.dev-tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 var(--space-md);
  border-bottom: var(--border-w) solid var(--doc-line);
}

.dev-tab {
  padding: 12px var(--space-md);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-body);
  line-height: var(--text-body-lh);
  color: var(--doc-ink);
  border-bottom: var(--border-w) solid transparent;
  /* Sits on the strip's own hairline rather than beside it, so the selected
     tab's underline replaces that hairline instead of doubling it (§9.2). */
  margin-bottom: -1px;
}

.dev-tab:hover {
  color: var(--sd-text);
}

/* The focus ring, moved from the invisible radio onto its label. Without this a
   keyboard user tabbing into the strip sees nothing at all. */
.dev-tab-radio:focus-visible + .dev-tab-radio + .dev-tab-radio + .dev-tab-strip .dev-tab:first-child,
.dev-tab-radio:focus-visible + .dev-tab-radio + .dev-tab-strip .dev-tab:nth-child(2),
.dev-tab-radio:focus-visible + .dev-tab-strip .dev-tab:nth-child(3) {
  outline: 2px solid var(--sd-secondary);
  outline-offset: -2px;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* The selected tab. Same sibling arithmetic as the focus ring: radio 1 is two
   radios before the strip, radio 2 is one before it, radio 3 is adjacent. */
#authTabClient:checked ~ .dev-tab-strip .dev-tab:nth-child(1),
#authTabUser:checked ~ .dev-tab-strip .dev-tab:nth-child(2),
#authTabCall:checked ~ .dev-tab-strip .dev-tab:nth-child(3) {
  color: var(--sd-secondary);
  border-bottom-color: var(--sd-secondary);
}

.dev-tab-panel {
  display: none;
}

#authTabClient:checked ~ #authPanelClient,
#authTabUser:checked ~ #authPanelUser,
#authTabCall:checked ~ #authPanelCall {
  display: grid;
  gap: 0 var(--space-lg);
  padding: var(--space-lg);
  align-items: start;
}

@media (min-width: 900px) {
  #authTabClient:checked ~ #authPanelClient,
  #authTabUser:checked ~ #authPanelUser,
  #authTabCall:checked ~ #authPanelCall {
    grid-template-columns: 1fr 1fr;
  }

  /* The words in the first column, the code beside them, the note under the
     words. */
  .dev-tab-panel > p {
    grid-column: 1;
  }

  .dev-tab-panel > .code-panel {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

.dev-tab-panel > p {
  margin: 0 0 16px;
  line-height: 1.65;
  color: var(--sd-text-soft);
}

/* (0,2,1), which beats `.dev-tab-panel > p` at (0,1,1) on specificity. The
   first cut reached for `!important` here and the frontend guard refused it,
   correctly: a style that needs `!important` is a specificity bug, and this one
   had a one-word fix. Same lesson as L-FE-49, from the other end — there a page
   rule lost to a component rule and the answer was to delete it. */
.dev-tab-panel > p.dev-tab-note {
  margin-top: 16px;
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
}

/* ---- The no-JavaScript fallbacks ------------------------------------------ */

.dev-fallback {
  padding: 24px;
  background: var(--sd-sunk);
  border: 1px solid var(--doc-line);
  border-radius: var(--radius-lg);
}

.dev-fallback p {
  margin: 0 0 12px;
  color: var(--sd-text-soft);
  line-height: 1.65;
}

.dev-fallback .cta-actions {
  margin-top: 20px;
}

/* ---- Narrow ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .dev-tab {
    padding: 10px 12px;
  }
}
