/*
 * Grammar-first explainer (plan-joe-mauriello-2026.11.17.1953-p680-grammar-first-motion-explainer; index.html, the #why section).
 * Tokens only, like site.css. The explainer is one black callout box, so its
 * copy, controls, grid, connectors and labels are white or light (the site
 * rule: white text only on black). Without the script nothing here hides
 * anything: the scenes read as a numbered list and the figure keeps its
 * hidden attribute. Every hiding or stacking rule is scoped to .is-enhanced.
 * SVG text and strokes also carry presentation attributes in the markup
 * (know-svg-shapes-need-attribute-fallbacks); these rules override them.
 */

.explainer {
  /* A dark surface: the same role values site.css gives its black panels. */
  --fg: var(--nh-brand-bg-white);
  --fg-soft: var(--nh-colors-eggplant-200);
  --focus: var(--nh-brand-bg-white);
  --btn-bg: var(--nh-brand-bg-white);
  --btn-fg: var(--nh-brand-bg-black);
  color: var(--fg-soft);
  background: var(--nh-brand-bg-black);
  border-radius: var(--frame-radius);
  padding: clamp(20px, 5vw, 56px);
  display: grid;
  gap: var(--nh-spacing-2xl-px);
  margin-top: var(--nh-spacing-3xl-px);
}
@media (max-width: 600px) {
  /* Narrow: the box reaches nearer the page edge so the figure keeps its size. */
  .explainer {
    margin-inline: calc(8px - var(--gutter));
    padding: 20px 12px;
    border-radius: calc(var(--frame-radius) / 2);
  }
}
@media (min-width: 861px) {
  .explainer.is-enhanced {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: center;
    gap: var(--nh-spacing-3xl-px);
  }
}

/* Scene copy: an ordered list. */
.explainer__scenes {
  margin: 0;
  padding-left: 1.4em;
  display: grid;
  gap: var(--nh-spacing-xl-px);
  max-width: var(--reading-width);
}
.explainer__line {
  margin: 0;
  font-family: var(--nh-brand-font-display);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 700;
  line-height: 1.12;
  color: var(--fg);
}
.explainer__more {
  margin: var(--nh-spacing-md-px) 0 0;
  max-width: 44ch;
  color: var(--fg-soft);
}

/* Enhanced: one scene's copy at a time, all stacked in one cell so the height never jumps. */
.is-enhanced .explainer__scenes { list-style: none; padding-left: 0; }
.is-enhanced .explainer__scene { grid-area: 1 / 1; }
.is-enhanced .explainer__scene:not(.is-current) { opacity: 0; visibility: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .is-enhanced .explainer__scene { transition: opacity 700ms ease-in-out, visibility 700ms; }
}
@media (max-width: 860px) {
  /* One column: the figure first, its copy beneath. */
  .is-enhanced .explainer__figure { order: -1; }
}

.explainer__figure { margin: 0; min-width: 0; }
.explainer__stage {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 11; /* STAGE in scenes.js */
  color: var(--nh-brand-bg-white);
}

/* The circle grid: white at low strength, a quiet texture as on neighbourhoods.network. */
.explainer-grid__circles { stroke-opacity: 0.22; }
.explainer-grid__lines { stroke-opacity: 0.12; }

/* Labels: small white facet tags with a black halo so grid lines never cross a letter. */
.explainer-label {
  fill: var(--nh-brand-bg-white);
  stroke: var(--nh-brand-bg-black);
  stroke-width: 0.16px;
  stroke-linejoin: round;
  paint-order: stroke;
  font-family: var(--nh-brand-font-body);
  font-size: 0.4px;
  font-weight: 700;
  letter-spacing: 0.06px;
  text-transform: uppercase;
}
.explainer-label__detail { font-weight: 600; letter-spacing: 0; text-transform: none; }
/* State words and participant names: sentence case, not facet tags. */
.explainer-label--word,
.explainer-participant .explainer-label { font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 0.42px; }
/* The feed post's check mark: the success green, the one green the figure uses for a finished state. */
.explainer-check { stroke: var(--nh-theme-success-emphasis); }
/* The rule boundary: violet marks the highlighted path. */
.explainer-boundary { fill: var(--nh-role-color-diagram-accent); stroke: var(--nh-role-color-diagram-accent); }
@media (max-width: 600px) {
  .explainer-label,
  .explainer-label--word,
  .explainer-participant .explainer-label { font-size: 0.48px; }
}
.explainer-connector { stroke: var(--nh-brand-bg-white); }
.explainer-arrowhead { fill: var(--nh-brand-bg-white); }

/* View panels (scene 5): quiet outlines over the dimmed grammar, white text, one violet and one green marker. */
.explainer-panel__box { fill: var(--nh-brand-bg-black); fill-opacity: 0.78; stroke: var(--nh-brand-bg-white); stroke-opacity: 0.4; }
.explainer-panel__bar { fill: var(--nh-brand-bg-white); fill-opacity: 0.22; }
.explainer-panel__title,
.explainer-panel__action { fill: var(--nh-brand-bg-white); font-family: var(--nh-brand-font-body); font-size: 0.42px; font-weight: 700; }
.explainer-panel__action { font-family: var(--nh-brand-font-display); font-size: 0.5px; }
.explainer-panel__dot--review { fill: var(--nh-role-color-diagram-accent); }
.explainer-panel__dot--done { fill: var(--nh-theme-success-emphasis); }
@media (max-width: 600px) {
  .explainer-panel__title { font-size: 0.48px; }
  .explainer-window__title { font-size: 0.4px; }
}
/* The app window: a black frame with a thin title strip, under the panels. */
.explainer-window__frame { fill: var(--nh-brand-bg-black); stroke: var(--nh-brand-bg-white); }
.explainer-window__title { fill: var(--nh-brand-bg-white); font-family: var(--nh-brand-font-body); font-weight: 600; }
/* Status tags: a coloured outline, the word in white on black (white text only on black). */
.explainer-tag rect { fill: var(--nh-brand-bg-black); }
.explainer-tag--review rect { stroke: var(--nh-role-color-diagram-accent); }
.explainer-tag--done rect { stroke: var(--nh-theme-success-emphasis); }
.explainer-tag__text { fill: var(--nh-brand-bg-white); font-family: var(--nh-brand-font-body); font-size: 0.3px; font-weight: 600; }
.explainer-button__text { fill: var(--nh-brand-bg-white); font-family: var(--nh-brand-font-body); font-size: 0.36px; font-weight: 700; }
/* After the click the button is quiet: the word alone, no pill. */
.explainer-button__text--quiet { font-weight: 600; }
/* Phones (scene 5's last frame): a black body, a feed of quiet cards, the new post outlined green. */
.explainer-phone__frame { fill: var(--nh-brand-bg-black); stroke: var(--nh-brand-bg-white); }
.explainer-phone__post { stroke: var(--nh-theme-success-emphasis); }
.explainer-phone__head,
.explainer-phone__text,
.explainer-phone__name { fill: var(--nh-brand-bg-white); font-family: var(--nh-brand-font-body); }
.explainer-phone__name { stroke: var(--nh-brand-bg-black); stroke-width: 0.16px; paint-order: stroke; }
.explainer-ripple { opacity: 0; fill: var(--nh-brand-bg-white); stroke: var(--nh-brand-bg-white); }
/* Pulses scale about their own box. */
[data-pulse] { transform-box: fill-box; transform-origin: center; }
.explainer-cursor .explainer-label { font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 0.42px; }

/*
 * Controls: one slim bar under the stage, inside the box. Icon-only play or pause,
 * the scene steps as thin segments (also the progress), icon-only replay. Marks are
 * small and rest at the soft foreground; each control's hit target is 44 x 44 px
 * through padding, with no gap between targets so all seven fit one row at 390 px.
 */
.explainer__controls {
  display: flex;
  align-items: center;
  margin-top: var(--nh-spacing-sm-px);
  color: var(--fg-soft);
}
.explainer__steps {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 var(--nh-spacing-sm-px);
  padding: 0;
  list-style: none;
}
.explainer__steps > li { flex: 1 1 0; min-width: 44px; display: flex; }
.explainer__control,
.explainer__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.explainer__control[hidden] { display: none; }
.explainer__step { width: 100%; padding: 0 3px; }
/* The focus ring stays inside the control, so neighbouring targets never cover it. */
.explainer__control:focus-visible,
.explainer__step:focus-visible { outline-offset: -3px; color: var(--fg); }
.explainer__icon { width: 16px; height: 16px; fill: currentColor; }
.explainer__icon--line { fill: none; stroke: currentColor; }
.explainer__control[data-state="playing"] .explainer__icon--play,
.explainer__control[data-state="paused"] .explainer__icon--pause { display: none; }
.explainer__step-track {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 28%, transparent);
}
/* scenes.js writes scaleX(progress) here: 1 past, 0 to 1 current, 0 future. */
.explainer__step-fill {
  display: block;
  height: 100%;
  background: currentColor;
  transform-origin: left center;
  transform: scaleX(0);
}
.explainer__step[aria-current] { color: var(--fg); }
@media (prefers-reduced-motion: reduce) {
  /* Nothing plays: the current scene's segment shows full. */
  .explainer__step[aria-current] .explainer__step-fill { transform: none !important; }
}
@media (hover: hover) {
  .explainer__control:hover,
  .explainer__step:hover { color: var(--fg); }
}
@media (prefers-reduced-motion: no-preference) {
  .explainer__control,
  .explainer__step { transition: color 150ms ease-out; }
}
