/* ============================================================================
   surface-texture / demo.css - the surface texture lab, its notation views
   and the printed figures.

   Loaded after msu-theme.css and app.css. Every colour outside the print
   block is a theme token, so both skins come for free.

   The theme's contrast rules hold here too:
     - gold (--flag) and red orange (--cat3) are lines, fills and borders,
       never text on a light ground;
     - meaning never rides on colour alone: peaks and valleys are also
       triangles pointing up and down, the evaluation length is also solid
       against dashed, a failed limit is also a cross and the word "over".
   ========================================================================== */

[data-interactive="surface-texture"] { min-width: 0; }
[data-interactive="surface-texture"] [hidden] { display: none !important; }
.st-live > .st-static { display: none; }

/* ---- SVG type: sizes are viewBox units, so they scale with the figure ----*/
.st-lbl       { font-family: var(--f-display); font-size: 12px; font-weight: 700; letter-spacing: .06em; fill: var(--ink); }
.st-small     { font-family: var(--f-display); font-size: 11.5px; fill: var(--ink-soft); }
.st-tick      { font-family: var(--f-mono); font-size: 10.5px; fill: var(--ink); }
.st-face-lbl  { font-family: var(--f-display); font-size: 11px; font-weight: 700; letter-spacing: .12em; fill: var(--ink-soft); }
.st-sec-num   { font-family: var(--f-display); font-size: 12px; font-weight: 700; fill: var(--ink-soft); }
.st-halo      { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.st-compact .st-lbl   { font-size: 18px; }
.st-compact .st-small { font-size: 16px; }
.st-compact .st-tick  { font-size: 16px; }
.st-compact .st-sec-num { font-size: 18px; }

/* ---- the block of surface ------------------------------------------------*/
.st-face-top   { fill: color-mix(in srgb, var(--surface-2) 70%, var(--paper)); stroke: none; }
.st-face-front { fill: color-mix(in srgb, var(--ink-soft) 30%, var(--surface-2)); stroke: var(--ink); stroke-width: 1; stroke-linejoin: round; }
.st-face-side  { fill: color-mix(in srgb, var(--ink-soft) 18%, var(--surface-2)); stroke: var(--ink); stroke-width: 1; stroke-linejoin: round; }
.st-edge       { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.st-crest      { fill: none; stroke: var(--ink-soft); stroke-width: .9; stroke-linecap: round; opacity: .85; }
.st-mini .st-crest { stroke-width: .8; }
.st-scratch    { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.st-trace      { fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.st-trace-extra { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 4; }
.st-trace-tick { fill: none; stroke: var(--accent); stroke-width: 2; }
.st-stylus     { fill: var(--surface); stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.st-dim        { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
.st-arrowhead  { fill: var(--ink-soft); }
.st-viewdir    { fill: none; stroke: var(--cat3); stroke-width: 3; }
.st-mini .st-viewdir { stroke-width: 2.4; }
.st-viewdir-head { fill: var(--cat3); }

/* ---- the profiles ------------------------------------------------------------*/
.st-frame      { fill: none; stroke: var(--rule); stroke-width: 1; }
.st-grid       { fill: none; stroke: var(--rule); stroke-width: 1; opacity: .7; }
.st-axis       { fill: none; stroke: var(--ink); stroke-width: 1; }
.st-axis-tick  { fill: none; stroke: var(--ink); stroke-width: 1; }
.st-extra      { fill: color-mix(in srgb, var(--ink-soft) 10%, transparent); stroke: none; }
.st-p          { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.st-w          { fill: none; stroke: var(--flag); stroke-width: 3.2; stroke-linecap: round; }
.st-r          { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: var(--accent); stroke-width: 1.3; stroke-linejoin: round; }
.st-mean       { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.st-ra-line    { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 6 4; }
.st-section    { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 2 3; }
.st-zline      { fill: none; stroke: var(--cat3); stroke-width: 1; stroke-dasharray: 1 3; }
.st-zbar       { fill: none; stroke: var(--cat3); stroke-width: 2.5; }
.st-peak       { fill: var(--accent); stroke: var(--paper); stroke-width: .8; }
.st-valley     { fill: var(--paper); stroke: var(--accent); stroke-width: 1.4; }
.st-rt         { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 3 3; }
.st-rt-bar     { fill: none; stroke: var(--ink); stroke-width: 1.4; }

/* ---- symbols -------------------------------------------------------------------*/
.st-sym-line    { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }
.st-sym-surface { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.st-view-block  { fill: var(--surface-2); stroke: var(--ink); stroke-width: 2.4; }
.st-req         { font-family: var(--f-display); font-size: 14px; font-weight: 600; fill: var(--ink); }
.st-grade-box   { fill: var(--surface-2); stroke: var(--ink); stroke-width: 1.6; }
.st-grade       { font-family: var(--f-display); font-size: 30px; font-weight: 700; fill: var(--ink); }
.st-tri         { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: miter; }

/* ==========================================================================
   The live views
   ========================================================================*/
.st-lab,
.st-notation,
.st-challenge {
  container: st-view / inline-size;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

/* Parameter symbols and units keep their case inside uppercase labels: an
   uppercased "µm" is a capital mu that reads as "MM", "λc" becomes "ΛC", and
   Ra is not RA. */
.st-nocase { text-transform: none; letter-spacing: 0; }

.st-k {
  font-family: var(--f-display);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.25;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---- buttons: the same tab look as the other machining labs, 44 px tall ---*/
:is(.st-lab, .st-notation, .st-challenge) button {
  cursor: pointer;
  min-height: 2.75rem;
  margin: 0;
  padding: .45rem .8rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-family: var(--f-display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  line-height: 1.2;
  text-transform: uppercase;
}
:is(.st-lab, .st-notation, .st-challenge) button:not(:disabled):hover { border-color: var(--accent); background: var(--surface-2); }
.st-lab button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--paper); }
:is(.st-lab, .st-notation, .st-challenge) :is(button, input, select, summary, a, [tabindex]):focus-visible {
  outline: 3px solid var(--cat2);
  outline-offset: 2px;
}

/* ---- experiments ----------------------------------------------------------*/
.st-exp { display: flex; flex-direction: column; gap: .6rem; }
.st-exp-head { display: flex; flex-direction: column; gap: .4rem; }
.st-exp-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .4rem; }
.st-exp-row button { text-align: start; }
.st-exp-n {
  display: inline-grid; place-items: center;
  width: 1.4rem; height: 1.4rem; margin-right: .2rem;
  border: 1.5px solid currentColor; border-radius: 50%;
  font-size: .72rem;
}
.st-mission {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem;
  padding: .75rem .9rem;
  background: var(--flag-soft);
  border: 1.5px solid var(--flag);
  border-radius: var(--radius-sm);
  color: var(--ink);
  line-height: 1.5;
}
.st-mission p { flex: 1 1 22rem; min-width: 0; }
.st-mission .st-act { flex: none; background: var(--surface); }

/* ---- the two figures and their controls ----------------------------------------
   Each control group sits beside the thing it changes. In the reading column the
   block shares a row with the surface controls, and the numbers and the trace
   controls come straight after, above the profile they summarise. With the room
   of a presentation, the block and the profile sit side by side. */
.st-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "pic" "surf" "tiles" "meas" "prof";
  gap: 1rem 1.2rem;
  align-items: start;
}
.st-a-pic { grid-area: pic; }
.st-a-surf { grid-area: surf; }
.st-a-tiles { grid-area: tiles; }
.st-a-meas { grid-area: meas; }
.st-a-prof { grid-area: prof; }
@container st-view (min-width: 40rem) {
  .st-stage {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr);
    grid-template-areas: "pic surf" "tiles tiles" "meas meas" "prof prof";
  }
  .st-a-surf { grid-template-columns: minmax(0, 1fr); }
  .st-a-meas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container st-view (min-width: 72rem) {
  .st-stage {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    grid-template-areas: "pic prof" "surf tiles" "surf meas";
  }
  .st-a-surf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.st-fig { display: flex; flex-direction: column; gap: .45rem; min-width: 0; margin: 0; container: st-fig / inline-size; }
.st-svg svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}
.st-fig figcaption { font-size: .86rem; line-height: 1.45; color: var(--ink-soft); }
.st-fig figcaption strong { color: var(--ink); }

.st-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: .7rem 1rem;
  align-items: start;
}
.st-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.st-field legend { padding: 0; margin-bottom: .3rem; }
.st-field select {
  min-height: 2.75rem;
  width: 100%;
  padding: .4rem .55rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-xs);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-family: var(--f-display);
  font-size: .95rem;
}
.st-chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.st-chip { position: relative; display: inline-flex; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.st-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.st-chip span {
  display: flex; align-items: center; justify-content: center; width: 100%;
  min-height: 2.75rem;
  padding: .4rem .7rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-xs);
  color: var(--accent);
  font-family: var(--f-display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.2;
  text-align: center;
}
.st-chip:hover span { border-color: var(--accent); background: var(--surface-2); }
.st-chip input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--paper); }
.st-chip input:focus-visible + span { outline: 3px solid var(--cat2); outline-offset: 2px; }
.st-chip input:disabled + span { opacity: .45; cursor: default; }
.st-shape { grid-column: 1 / -1; }
.st-range-row { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.st-range input[type="range"] { flex: 1 1 auto; min-width: 0; min-height: 2.75rem; margin: 0; accent-color: var(--accent); }
.st-range output { flex: none; min-width: 6.5ch; font-family: var(--f-mono); font-size: .95rem; font-weight: 700; text-align: end; color: var(--ink); }
.st-check { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; cursor: pointer; font-size: .95rem; }
.st-check input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); flex: none; }
.st-rel { grid-column: 1 / -1; font-size: .92rem; line-height: 1.45; color: var(--ink); }
.st-match-status { grid-column: 1 / -1; padding: .6rem; border-inline-start: 3px solid var(--flag); background: var(--flag-soft); color: var(--ink); font-size: .9rem; line-height: 1.4; }

.st-more { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding-top: .2rem; }
.st-more > summary,
.st-work > summary {
  display: flex; align-items: center; gap: .5rem;
  min-height: 2.75rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--f-display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
}
.st-more > summary::-webkit-details-marker,
.st-work > summary::-webkit-details-marker { display: none; }
.st-more > summary::before,
.st-work > summary::before { content: "+"; width: 1rem; font-size: 1.1rem; text-align: center; }
.st-more[open] > summary::before,
.st-work[open] > summary::before { content: "\2212"; }
.st-more-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: .5rem 1rem;
  padding: .2rem 0 .4rem;
}

/* ---- the numbers: the site's result-tile shape ------------------------------*/
.st-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.75rem), 1fr));
  gap: .55rem;
}
.st-tile {
  display: flex; flex-direction: column; gap: .15rem;
  min-width: 0;
  padding: .6rem .7rem;
  background: var(--surface-2);
  border-inline-start: .3rem solid var(--accent);
  border-radius: var(--radius-xs);
}
.st-tile[data-st-tile="Rz"] { border-inline-start-color: var(--cat3); }
.st-tile[data-st-tile="Rt"] { border-inline-start-color: var(--ink); }
.st-tile[data-st-tile="W"]  { border-inline-start-color: var(--flag); }
.st-v { font-family: var(--f-display); font-size: 1.22rem; font-weight: 700; line-height: 1.2; color: var(--ink); overflow-wrap: anywhere; }
.st-s { font-size: .8rem; line-height: 1.35; color: var(--ink-soft); }
.st-s [data-st-uin] { font-family: var(--f-mono); }

/* ---- the drawing ------------------------------------------------------------------*/
.st-drawing {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
@container st-view (min-width: 38rem) {
  .st-drawing { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-items: start; }
}
.st-fig-sym .st-svg svg { max-width: 24rem; margin-inline: auto; }
.st-drawing-body { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.st-verdict {
  padding: .7rem .85rem;
  background: var(--surface-2);
  border-inline-start: .3rem solid var(--cat1);
  border-radius: var(--radius-xs);
  line-height: 1.5;
}
.st-verdict[data-pass="no"] { border-inline-start-color: var(--cat3); background: var(--cat3-soft); color: var(--cat-ink); border-inline-start-style: double; border-inline-start-width: .45rem; }
.st-aside { display: block; margin-top: .3rem; font-size: .86rem; color: var(--ink-soft); }
.st-verdict[data-pass="no"] .st-aside { color: var(--cat-ink); }
.st-reading { gap: .4rem; font-size: .95rem; line-height: 1.45; }
.st-limit-row { display: flex; gap: .4rem; }
.st-limit-row select:first-child { flex: 0 0 5.5rem; }

/* ---- worked arithmetic: the site's worked-step style --------------------------------*/
.st-work { border-top: 1px solid var(--rule); padding-top: .2rem; }
.st-work-body {
  display: flex; flex-direction: column; gap: .4rem;
  padding: .75rem .9rem;
  background: var(--surface-2);
  border-inline-start: 2px solid var(--rule);
  color: var(--ink-soft);
  font-size: .94rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.st-work-body .st-k { display: block; }
.st-work-body strong { color: var(--ink); }

/* ---- one requirement, four notations ----------------------------------------------*/
.st-n-controls { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.st-n-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: .75rem;
}
.st-n-card {
  display: flex; flex-direction: column; gap: .5rem;
  min-width: 0; margin: 0;
  padding: .7rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}
.st-n-card .st-svg svg { border: 0; background: transparent; max-height: 8rem; }
.st-n-card figcaption { font-size: .86rem; line-height: 1.45; color: var(--ink-soft); }
.st-n-card figcaption strong { color: var(--ink); }
.st-n-card[data-ok="no"] { border-style: dashed; }
.st-n-inch { font-size: .95rem; line-height: 1.5; }

/* ---- read the callout ---------------------------------------------------------------*/
.st-ch-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; }
.st-ch-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: center; }
@container st-view (min-width: 40rem) {
  .st-challenge:not([data-kind="none"]) .st-ch-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
}
.st-ch-fig svg { max-width: 22rem; max-height: 14rem; margin-inline: auto; }
.st-ch-answers { display: flex; flex-direction: column; gap: .6rem; }
.st-ch-q { font-family: var(--f-display); font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.st-ch-options { display: flex; flex-wrap: wrap; gap: .5rem; }
.st-ch-options button { flex: 1 1 10rem; text-transform: none; letter-spacing: 0; font-size: .92rem; }
.st-ch-options button:disabled { cursor: default; opacity: .55; }
.st-ch-options button[data-answer="true"] { opacity: 1; border-color: var(--accent); background: var(--accent); color: var(--paper); }
.st-ch-options button[data-answer="true"]::after { content: " \2713"; }
.st-ch-options button[data-picked="wrong"] { opacity: 1; border-style: dashed; border-color: var(--cat3); color: var(--ink); text-decoration: line-through; }
.st-ch-reveal { display: flex; flex-direction: column; gap: .75rem; padding-top: .9rem; border-top: 1px solid var(--rule); }
.st-ch-reveal:focus { outline: none; }
.st-ch-reveal:focus-visible { outline: 3px solid var(--cat2); outline-offset: 2px; }
.st-ch-verdict { font-size: 1rem; line-height: 1.5; }

/* ---- the authored static figures (no JavaScript, and paper) -------------------------*/
.st-static { display: flex; flex-direction: column; gap: .9rem; }
.st-static-fig { margin: 0; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.st-static-fig svg { display: block; width: 100%; height: auto; }
.st-static-fig figcaption { font-size: .86rem; color: var(--ink-soft); line-height: 1.45; }
.st-static-fig figcaption strong { color: var(--ink); }
.st-static-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; align-items: start; }
.st-static-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: .75rem; }
.st-static-grid figure { margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.st-static-grid svg { display: block; width: 100%; height: auto; max-height: 9rem; }
.st-static-grid figcaption { font-size: .84rem; line-height: 1.4; color: var(--ink-soft); }
.st-static-grid figcaption strong { color: var(--ink); }
.st-tri-cell svg { display: inline-block; height: 1.15rem; width: auto; vertical-align: middle; }
.st-sym-cell svg { display: block; width: 10rem; max-width: 100%; height: auto; }
.st-lay-sym { font-family: var(--f-display); font-weight: 700; font-size: 1.3rem; }

/* ---- small figures: when the block is drawn small (a phone, or beside its
   controls in the reading column) its labels grow in viewBox units to stay
   readable -----------------------------------------------------------------------------*/
@container st-fig (max-width: 30rem) {
  .st-pictorial:not(.st-mini) .st-lbl { font-size: 18px; }
  .st-pictorial:not(.st-mini) .st-small { font-size: 17px; }
  .st-pictorial:not(.st-mini) .st-tick { font-size: 16px; }
  .st-pictorial:not(.st-mini) .st-face-lbl { font-size: 15px; }
}
@container st-view (max-width: 34rem) {
  .st-lab, .st-notation, .st-challenge { padding: .8rem; }
}

/* ---- presentation: read from across the room --------------------------------------*/
.presenting :is(.st-lab, .st-notation, .st-challenge) button,
.presenting .st-chip span { min-height: 3rem; font-size: .9rem; }
.presenting .st-v { font-size: 1.45rem; }
.presenting .st-mission { font-size: 1.08rem; }
.presenting .st-ch-q { font-size: 1.25rem; }

/* ---- print: the complete authored lesson and all challenge answers ----------------*/
@media print {
  .st-live > :not(.st-static) { display: none !important; }
  .st-live > .st-static { display: flex !important; }
  .st-exp-head, .st-mission button, .st-controls, .st-more, .st-ch-options button:not([data-answer]), .st-ch-actions { display: none !important; }
  .st-work { display: none !important; }
  .st-lab, .st-notation, .st-challenge { border-color: #777; }
  .st-fig, .st-static-fig, .st-results, .st-drawing, .st-n-card { break-inside: avoid; }
  .st-svg svg, .st-static-fig svg, .st-static-grid svg, .st-tile, .st-verdict, .st-mission {
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  .st-stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "pic" "tiles" "prof" "surf" "meas"; }
}
