/* StudentPilot — interactive learning visuals (/visuals and its diagrams).
 * Built on the design tokens in application.css (docs/design-system.md).
 *
 * Three layers, so the next diagram reuses the first two:
 *   .diagram*   the page parts: stage, controls, steps panel, legend
 *   .dg-*       the ink inside any diagram's SVG: lines, the highlight under
 *               the active one, labels, notes, the moving marker
 *   .tp-*       what only the traffic pattern draws (runway, wind arrow)
 *   .wc-*       what only the wind correction draws (wind triangle, controls)
 *   .as-*       what only the airspace classes draw (zones, ground, readout)
 * A new diagram adds its own short prefix for the third layer only. */

/* ---------- The index ---------- */

.visuals-index { margin-bottom: var(--space-4); }
.visuals-index__card .visuals-index__open {
  margin-top: var(--space-1);
  font-family: var(--font-display); font-weight: 700; color: var(--blue);
}
.visuals-index__card--coming { background: var(--paper-deep); }
.visuals-index__card--coming h3 { color: var(--ink-soft); }

/* ---------- A diagram page ---------- */

.diagram-back { margin: 0 0 var(--space-1); font-size: .9rem; }
.diagram-intro { max-width: 46rem; color: var(--ink-soft); margin-bottom: var(--space-3); }

.diagram {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: var(--space-3);
  align-items: start;
}

.diagram__stage {
  background: var(--card);
  border: var(--outline);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
}
.diagram__svg { display: block; width: 100%; height: auto; }

/* ---------- Ink inside a diagram ---------- */

/* Text sizes are in SVG units and set per breakpoint: the drawing scales
 * with its frame, so a phone needs bigger units to print the same size. */
.diagram__svg { --dg-label: 22px; --dg-note: 17px; }

.dg-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
}
.dg-line--dashed { stroke-dasharray: 12 11; }
/* A stretch that lies on something already drawn (the runway) has no line
 * of its own: the marker still flies it and its highlight still shows. */
.dg-line--onrunway { stroke: none; }

/* The narrator's mustard, laid under the line being flown. */
.dg-glow {
  fill: none;
  stroke: var(--mustard);
  stroke-width: 20;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity .25s;
}
.dg-glow.is-active { opacity: 1; }

.dg-hit {
  fill: none; stroke: transparent; stroke-width: 46;
  pointer-events: stroke; cursor: pointer;
}

.dg-label {
  font-family: var(--font-display);
  font-size: var(--dg-label); font-weight: 700; letter-spacing: .01em;
  fill: var(--ink-soft);
  cursor: pointer;
  transition: fill .25s;
}
.dg-label.is-active { fill: var(--ink-press); }
.dg-note {
  font-family: var(--font-display);
  font-size: var(--dg-note); font-weight: 700;
  fill: var(--ink-faint);
}
.dg-hint { fill: none; stroke: var(--ink-faint); stroke-width: 3; stroke-dasharray: 6 6; }
.dg-hint-head { fill: var(--ink-faint); }

/* The moving marker is "where you are", so it is printed in mustard. */
.dg-marker { fill: var(--mustard); stroke: var(--ink-press); stroke-width: 1.5; stroke-linejoin: round; pointer-events: none; }

/* ---------- Traffic pattern only ---------- */

.tp-runway { fill: var(--ink); }
.tp-centreline { stroke: var(--card); stroke-width: 3; stroke-dasharray: 14 12; }
.tp-runway-number {
  fill: var(--card);
  font-family: var(--font-display);
  font-size: var(--dg-label); font-weight: 700;
}
.tp-wind__shaft { stroke: var(--blue); stroke-width: 6; stroke-linecap: round; }
.tp-wind__head { fill: var(--blue); }
.tp-wind__label {
  font-family: var(--font-display);
  font-size: var(--dg-label); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  fill: var(--blue-deep);
}

/* ---------- Controls ---------- */

.diagram__controls {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  padding: var(--space-2) var(--space-1) var(--space-1);
}
.diagram__play { min-width: 5.25rem; }
.diagram__speed { display: inline-flex; gap: var(--space-1); }
.diagram__speed .btn.is-active,
.diagram__follow[aria-pressed="true"] { background: var(--mustard-soft); border-color: var(--ink); color: var(--ink); }

/* ---------- The steps panel ---------- */

.diagram__panel {
  background: var(--card);
  border: var(--outline);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}
.diagram__panel-title { font-size: 1.05rem; margin-bottom: var(--space-2); }

.diagram__steps { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.diagram__step {
  border-left: 4px solid var(--line);
  transition: background .25s, border-color .25s;
}
.diagram__step + .diagram__step { margin-top: var(--space-1); }
/* Each step is one real button, so a keyboard reaches it; it carries no
 * button chrome, only the design system's focus ring. */
.diagram__step-button {
  display: block; width: 100%;
  padding: var(--space-1) var(--space-2);
  background: none; border: 0; border-radius: 0;
  font: inherit; color: inherit; text-align: left;
  cursor: pointer;
}
.diagram__step-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.diagram__step-title {
  display: block; margin-bottom: .15rem;
  font-family: var(--font-display); font-size: .95rem; font-weight: 700;
  line-height: 1.2; letter-spacing: -0.015em;
}
.diagram__step-text { display: block; font-size: .87rem; color: var(--ink-soft); }
.diagram__step.is-active { background: var(--mustard-soft); border-left-color: var(--mustard-press); }
/* Read by a screen reader, never drawn. */
.diagram__announce {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.diagram__legend { border-top: 1px solid var(--line); padding-top: var(--space-2); }
.diagram__legend-title {
  font-size: var(--stamp-size); letter-spacing: var(--stamp-tracking); text-transform: uppercase;
  color: var(--ink-faint);
}
.diagram__legend-list { list-style: none; margin: 0 0 var(--space-2); padding: 0; font-size: .87rem; color: var(--ink-soft); }
.diagram__legend-list li { display: flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-1); }
.diagram__legend-note { margin: 0; font-size: .84rem; color: var(--ink-faint); }

.dg-key { display: inline-block; width: 1.6rem; height: 0; border-top: 5px solid var(--ink); flex-shrink: 0; }
.dg-key--active { box-shadow: 0 0 0 4px var(--mustard); }
.dg-key--dashed { border-top-style: dashed; }
.dg-key--marker {
  width: .85rem; height: .85rem; border: 1.5px solid var(--ink-press); border-radius: 50%;
  background: var(--mustard);
}

/* ---------- Phone and tablet: the drawing takes the full width, and the
 * panel shows all leg titles and expands the current explanation ---------- */

@media (max-width: 960px) {
  .diagram { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .diagram__stage { padding: 0; }
  .diagram__controls { padding: var(--space-2); }
  .diagram__step:not(.is-current) .diagram__step-text { display: none; }
  .diagram__step.is-current { background: var(--mustard-soft); border-left-color: var(--mustard-press); }
  .diagram__step-title { font-size: 1.1rem; }
  .diagram__step-text { font-size: 1rem; }
}
@media (max-width: 640px) {
  .diagram__svg { --dg-label: 29px; --dg-note: 28px; }
  /* Bleed the stage to the screen edges (.page pads 1.5rem a side). */
  .diagram__stage { margin-inline: -1.5rem; border-left: 0; border-right: 0; border-radius: 0; }
}

/* ---------- Wind correction only ---------- */

.wc-point { fill: var(--card); stroke: var(--ink); stroke-width: 4; }
.wc-north__shaft { stroke: var(--ink-faint); stroke-width: 3; }
.wc-north__head { fill: var(--ink-faint); }
.wc-course { stroke: var(--ink-faint); }
.wc-wind-vector { stroke: var(--blue); stroke-width: 5; stroke-linecap: round; }
.wc-wind-vector__head { fill: var(--blue); }
.wc-arc { fill: none; stroke: var(--ink-soft); stroke-width: 3; }
.wc-windsock__ring { fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-dasharray: 4 6; }
.wc-windsock__shaft { stroke: var(--blue); stroke-width: 6; stroke-linecap: round; }
.wc-windsock__head { fill: var(--blue); }
.wc-windsock__label {
  font-family: var(--font-display);
  font-size: var(--dg-label); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  fill: var(--blue-deep);
}
.wc-readout__line { fill: var(--ink); }
.wc-key--wind { border-top-color: var(--blue); }

.wc-controls { flex-wrap: wrap; }
.wc-control { display: inline-flex; flex-direction: column; gap: .25rem; min-width: 11rem; flex: 1 1 11rem; }
.wc-control__label { font-family: var(--font-display); font-weight: 700; font-size: .95rem; color: var(--ink-soft); }
.wc-control__label output { color: var(--ink); }
.wc-control__range { width: 100%; accent-color: var(--blue); min-height: 2rem; }
.wc-control__range:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.wc-cite { margin: .25rem 0 0; font-size: .85rem; color: var(--ink-faint); }
.diagram__step .wc-cite { padding: 0 var(--space-2) var(--space-1); }
@media (max-width: 960px) {
  .diagram__step:not(.is-current) .wc-cite { display: none; }
}

/* ---------- Airspace classes only ---------- */

.as-zone { stroke: var(--ink); stroke-width: 2; cursor: default; transition: fill .2s; }
.as-zone--a { fill: var(--paper-deep); }
.as-zone--e { fill: var(--card); }
.as-zone--g { fill: var(--paper-deep); }
.as-zone--b, .as-zone--c, .as-zone--d { fill: var(--card); stroke-width: 3; stroke-dasharray: 10 6; }
.as-zone.is-active { fill: var(--mustard-soft); stroke: var(--mustard-press); }
.as-ground { stroke: var(--ink); stroke-width: 4; }
.as-ground__fill { fill: var(--ink-faint); }
.as-runway { fill: var(--ink); }
.as-height { fill: var(--ink-soft); }
.as-letter { cursor: pointer; }
.as-readout__name { fill: var(--ink); }
.as-readout__span { fill: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) { .as-zone { transition: none; } }

.as-step-span { font-weight: 400; color: var(--ink-soft); }
.as-key { display: inline-block; width: 1.6rem; height: 1rem; border: 2px solid var(--ink); flex-shrink: 0; }
.as-key--b { background: var(--card); border-style: dashed; }
.as-key--e { background: var(--card); }
.as-key--g { background: var(--paper-deep); }

.as-cite { margin: .25rem 0 0; font-size: .85rem; color: var(--ink-faint); }
.diagram__step .as-cite { padding: 0 var(--space-2) var(--space-1); }
@media (max-width: 960px) {
  .diagram__step:not(.is-current) .as-cite { display: none; }
}
