/* ============================================================
   UI — instruments and furniture: buttons, the Call Slip,
   the Depth Dial, gates, widgets, the brass confidence stop.
   ============================================================ */

/* ---------- Buttons ---------- */
.btn, button {
  appearance: none;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: var(--u) var(--u3);
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover, button:hover { border-color: var(--rubric); color: var(--rubric); }
.btn.primary, button.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn.primary:hover, button.primary:hover { background: var(--rubric); border-color: var(--rubric); color: #F6F1E5; }
.btn:disabled, button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--muted);
  color: var(--muted);
  background: transparent;
}
.btn.quiet { border-color: var(--hairline); color: var(--muted); font-weight: 500; }
.btn.quiet:hover { border-color: var(--rubric); color: var(--rubric); }

input[type="text"], input[type="number"], input[type="date"], input[type="search"], textarea, select {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink);
  padding: var(--u) var(--u2);
  font-size: 1rem;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }

/* ---------- The Call Slip — search everything ---------- */
dialog.call-slip {
  border: 1px solid var(--ink);
  background: var(--stock);
  color: var(--ink);
  width: min(680px, calc(100vw - var(--u4)));
  margin: 10vh auto auto;
  padding: 0;
  box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 25%, transparent);
}
dialog.call-slip::backdrop { background: color-mix(in srgb, #17140F 45%, transparent); }
.call-slip-card { padding: var(--u3); }
.call-slip-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--ink);
  padding-bottom: var(--u);
  margin-bottom: var(--u2);
}
.call-slip-head .title { font-family: var(--font-body); font-variant-caps: all-small-caps; letter-spacing: 0.14em; }
.call-slip-head-right { display: inline-flex; align-items: center; gap: var(--u2); }
.call-slip-head .hint { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.call-slip-close {
  font-family: var(--font-ui); font-weight: 700; font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--hairline); color: var(--muted);
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.call-slip-close:hover { border-color: var(--rubric); color: var(--rubric); }
.call-slip input[type="search"] {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  font-family: var(--font-body);
  font-size: 1.15rem;
  padding: var(--u) 0;
}
.call-slip input[type="search"]:focus-visible { outline: none; border-bottom-color: var(--rubric); }
.call-slip .assembling {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--faculty, var(--muted));
  min-height: 1.4em;
  margin: var(--u) 0;
  white-space: nowrap;
  overflow: hidden;
}
.call-slip .assembling .caret { color: var(--rubric); }
.call-slip-results { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.call-slip-results li { border-top: 1px dotted var(--hairline); }
.call-slip-results a {
  display: grid;
  grid-template-columns: 9ch 1fr auto;
  gap: var(--u2);
  padding: var(--u) 2px;
  text-decoration: none;
  color: inherit;
  align-items: baseline;
}
.call-slip-results a .result-title { font-family: var(--font-display); font-weight: 600; font-size: 0.98rem; }
.call-slip-results li[aria-selected="true"] a,
.call-slip-results a:hover { background: color-mix(in srgb, var(--rubric) 9%, transparent); }
.call-slip-results .kind { font-family: var(--font-mono); font-size: 0.65rem; color: var(--muted); }
.call-slip-empty { color: var(--muted); font-style: italic; padding: var(--u2) 0; }

/* ---------- The Depth Dial — the same idea, younger or deeper ---------- */
.depth-dial {
  display: flex;
  align-items: center;
  gap: var(--u3);
  border: 1px solid var(--hairline);
  background: var(--stock);
  padding: var(--u2) var(--u3);
  margin: var(--u4) 0 var(--u2);
}
.depth-dial .dial {
  flex: none;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background:
    radial-gradient(circle at 50% 50%, var(--stock) 58%, transparent 59%),
    conic-gradient(var(--well) 0deg, var(--stock) 360deg);
  position: relative;
  cursor: pointer;
  touch-action: none;
}
.depth-dial .dial:focus-visible { outline: var(--focus-ring); outline-offset: 3px; }
.depth-dial .needle {
  position: absolute;
  left: 50%; top: 50%;
  width: 2px; height: 32px;
  background: var(--rubric);
  transform-origin: 50% 0%;
  transform: rotate(var(--dial-angle, 0deg));
}
.depth-dial .dial .tick {
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 36px;
  background: var(--hairline);
  transform-origin: 50% 0%;
}
.depth-dial .dial-label { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--muted); }
.depth-dial .dial-current { font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem; }
.depth-dial .bands { display: flex; gap: 2px; }
.depth-dial .bands button {
  border: 1px solid var(--hairline);
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--muted);
}
.depth-dial .bands button[aria-pressed="true"] {
  border-color: var(--rubric);
  color: var(--rubric);
  font-weight: 700;
}

/* ---------- Retrieval Gate — answer before you continue ---------- */
.gate {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--faculty, var(--gold));
  background: var(--stock);
  padding: var(--u3);
  margin: var(--u4) 0;
}
.gate legend, .gate .gate-title {
  font-family: var(--font-body);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.12em;
  color: var(--ink);
}
.gate .gate-progress { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }

/* ---------- Question widgets ---------- */
.question { margin: var(--u3) 0; }
.question .prompt { font-family: var(--font-body); margin-bottom: var(--u2); max-width: var(--measure); }
/* Breathing room: commit/mark/confidence controls never wedge the options above. */
.guess [data-guess-commit],
.question > button,
.question .confidence,
.question .verdict-slot,
.worked .running-head + .step { margin-top: var(--u3); }
.question .confidence { margin-bottom: var(--u); }
.guess .choices, .guess .numeric-entry { margin-bottom: var(--u2); }
.question .prompt .q-no { font-family: var(--font-mono); font-size: 0.75em; color: var(--muted); margin-right: var(--u); }

.choices { display: grid; gap: var(--u); list-style: none; padding: 0; margin: 0; }
.choice {
  display: flex; gap: var(--u2); align-items: flex-start;
  border: 1px solid var(--hairline);
  background: var(--paper);
  padding: var(--u2);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
}
.choice:hover { border-color: var(--rubric); color: inherit; }
.choice[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 2px 0 0 var(--ink); }
.choice.correct { border-color: var(--verdict-yes); }
.choice.incorrect { border-color: var(--verdict-not); }
.choice .marker { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); padding-top: 2px; }

/* IF-AT scratch-away (practice): wrong options rub out like erasures. */
.choice.rubbed-out {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--verdict-not) 60%, transparent);
  background: var(--well);
  cursor: default;
}

.show-why {
  border-top: 1px dotted var(--hairline);
  margin-top: var(--u2);
  padding-top: var(--u);
  font-size: 0.9rem;
  color: var(--muted);
}

.numeric-entry, .expression-entry { display: flex; gap: var(--u2); align-items: baseline; }
.numeric-entry input, .expression-entry input { font-family: var(--font-mono); max-width: 22ch; }
.numeric-entry .unit { color: var(--muted); font-family: var(--font-mono); font-size: 0.85rem; }

/* Drag-to-order / matching */
.order-list, .match-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--u); }
.order-item, .match-item {
  border: 1px solid var(--hairline);
  background: var(--paper);
  padding: var(--u) var(--u2);
  cursor: grab;
  display: flex;
  gap: var(--u2);
  align-items: baseline;
}
.order-item.dragging { opacity: 0.5; border-style: dashed; }
.order-item .grip { color: var(--muted); font-family: var(--font-mono); }
.match-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--u2); align-items: center; margin-bottom: var(--u); }
.match-item.static { display: flex; align-items: center; }
.match-select { width: 100%; }

/* Hotspot */
.hotspot-surface { position: relative; }
.hotspot-pin {
  position: absolute;
  width: 22px; height: 22px;
  border: 2px solid var(--rubric);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  transform: translate(-50%, -50%);
  cursor: pointer;
  padding: 0;
}
.hotspot-pin.placed { background: var(--rubric); }

/* ---------- Confidence — the brass indicator ---------- */
.confidence {
  display: inline-flex;
  border: 1px solid var(--gold);
  border-radius: 999px;
  overflow: hidden;
  margin-top: var(--u2);
}
.confidence button {
  border: 0;
  border-right: 1px solid var(--gold);
  background: transparent;
  padding: 3px 12px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.confidence button:last-child { border-right: 0; }
.confidence button[aria-pressed="true"] { background: var(--gold); color: var(--paper); }

/* ---------- Ink That Thinks — guess first; the answer draws itself ---------- */
.ink-widget { margin: var(--u4) 0; }
.ink-widget .ink-surface {
  border: 1px solid var(--hairline);
  background: var(--paper);
  touch-action: none;
  display: block;
  width: 100%;
}
.ink-widget .pencil { stroke: var(--muted); stroke-dasharray: 4 5; stroke-width: 2; fill: none; stroke-linecap: round; }
/* A clean plotted point (graphite dot with a paper halo), not a dashed ring. */
.ink-widget .pencil-pt { fill: var(--rubric); stroke: var(--paper); stroke-width: 2; }
.ink-widget .truth { stroke: var(--ink); stroke-width: 2.2; fill: none; stroke-linecap: round; }
.ink-widget .truth.faculty { stroke: var(--faculty, var(--ink)); }
.ink-widget .pdot { fill: var(--faculty, var(--gold)); stroke: var(--paper); stroke-width: 1.5; }
.ink-widget .ink-controls { display: flex; gap: var(--u2); margin-top: var(--u2); align-items: center; }
.ink-widget .ink-status { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }

/* ---------- Worked-example stepper (fading) ---------- */
.worked { border: 1px solid var(--hairline); background: var(--stock); padding: var(--u3); margin: var(--u4) 0; }
.worked .step { display: grid; grid-template-columns: 3ch 1fr; gap: var(--u2); padding: var(--u) 0; border-bottom: 1px dotted var(--hairline); }
.worked .step .no { font-family: var(--font-mono); color: var(--muted); font-size: 0.8rem; }
.worked .step .display { font-family: var(--font-mono); font-size: 0.95rem; }
.worked .step.blanked .display { color: transparent; border-bottom: 1px dashed var(--muted); user-select: none; }
.worked .step input { font-family: var(--font-mono); }

/* ---------- Review — the fading ink ---------- */
.review-card {
  border: 1px solid var(--hairline);
  background: var(--stock);
  padding: var(--u3);
  margin-bottom: var(--u3);
}
.review-card .front { opacity: var(--retrievability, 1); }
.review-card .card-meta { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); display: flex; gap: var(--u3); margin-bottom: var(--u); }
.self-grade { display: flex; gap: var(--u); flex-wrap: wrap; }
.self-grade button { min-width: 5.5ch; }

/* ---------- Cabinet ---------- */
.cabinet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--u3); }
.specimen {
  border: 1px solid var(--hairline);
  background: var(--stock);
  padding: var(--u2);
  text-align: center;
}
.specimen .mini-plate { height: 72px; display: grid; place-items: center; margin-bottom: var(--u); }
.specimen.mastered { border-color: var(--gold); }
.specimen.unmastered .mini-plate svg { stroke: var(--muted); opacity: 0.5; stroke-dasharray: 3 4; }
.specimen.fading { opacity: 0.62; }
.specimen .skill-name { font-size: 0.8rem; font-family: var(--font-ui); }
.specimen .state { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.1em; color: var(--muted); display: block; margin-top: 2px; }

/* ---------- Settings ---------- */
.setting-row {
  display: flex; justify-content: space-between; align-items: center; gap: var(--u4);
  padding: var(--u3) 0; border-bottom: 1px solid var(--hairline);
  max-width: var(--measure);
}
.setting-row .setting-label { font-family: var(--font-ui); font-weight: 600; }
.setting-row .setting-help { color: var(--muted); font-size: 0.85rem; display: block; font-weight: 400; }
.segmented { display: inline-flex; border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: 0; border-right: 1px solid var(--hairline); font-size: 0.8rem; padding: var(--u) var(--u2); color: var(--muted); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
input[type="range"] { accent-color: var(--rubric); width: 200px; }

/* ---------- Exam paper ---------- */
.exam-paper { background: var(--stock); border: 1px solid var(--hairline); padding: var(--u6) var(--u4); }
.exam-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: var(--u2); margin-bottom: var(--u4); align-items: baseline; flex-wrap: wrap; gap: var(--u2); }
.exam-head .seat { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.exam-section-title { font-variant-caps: all-small-caps; letter-spacing: 0.12em; border-bottom: 1px solid var(--hairline); padding-bottom: var(--u); }

/* ---------- Audio narration (Sprout: on every block) ---------- */
.narrate {
  border: 1px solid var(--hairline);
  background: var(--paper);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  padding: 0;
}
:root[data-band="sprout"] .narrate { width: 76px; height: 76px; }
.narrate svg { width: 55%; height: 55%; stroke: var(--ink); fill: none; stroke-width: 2; }
.narrate[aria-pressed="true"] svg { stroke: var(--rubric); }

/* ---------- Rubber stamp DONE (Sprout) ---------- */
.done-stamp {
  display: inline-block;
  border: 3px double var(--verdict-yes);
  color: var(--verdict-yes);
  font-family: var(--font-ui);
  font-weight: 800;
  letter-spacing: 0.2em;
  padding: var(--u) var(--u3);
  transform: rotate(-6deg);
  text-transform: uppercase;
}

/* ---------- Atelier instruments ---------- */
.instrument-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--u3); }
.instrument-grid textarea, .instrument-grid input[type="text"] { width: 100%; }
.palace-house { max-width: 100%; margin-top: var(--u2); }
.palace-chips { display: flex; flex-wrap: wrap; gap: var(--u); margin: var(--u2) 0; }
.palace-chip.primary { border-color: var(--rubric); color: var(--rubric); }

/* ---------- Certificate frame ---------- */
.certificate-frame {
  border: 1px solid var(--gold);
  background: #F6F1E5;
  padding: var(--u2);
  max-width: 980px;
}
.certificate-frame svg { display: block; width: 100%; height: auto; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper);
  padding: var(--u) var(--u2); z-index: 100;
}
.skip-link:focus { left: var(--u2); }

/* ---------- Reading music (ambient Chopin & Mozart) ---------- */
.ambience {
  position: fixed;
  right: clamp(.7rem, 2vw, 1.35rem);
  bottom: clamp(.7rem, 2vw, 1.35rem);
  z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: .55rem;
}
.ambience-toggle {
  width: 2.85rem; height: 2.85rem; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--paper); color: var(--muted);
  border: 1px solid var(--hairline); cursor: pointer;
  box-shadow: 0 2px 12px rgba(6, 18, 43, .16);
  transition: border-color .2s ease, color .2s ease, transform .18s ease;
}
.ambience-toggle:hover { transform: translateY(-1px); border-color: var(--rubric); color: var(--rubric); }
.ambience-toggle:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.ambience.playing .ambience-toggle { border-color: var(--gold); color: var(--gold); }

.ambience-note { display: block; transform-origin: 60% 70%; }
.ambience.playing .ambience-note { animation: note-bob 2.4s ease-in-out infinite; }
@keyframes note-bob { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-1.5px) rotate(-5deg); } 70% { transform: translateY(1px) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .ambience.playing .ambience-note { animation: none; } }

.ambience-panel {
  width: 15.5rem; max-width: 74vw;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: .55rem;
  box-shadow: 0 8px 28px rgba(6, 18, 43, .28);
  padding: .85rem .95rem; font-size: .8rem;
}
.ambience-head {
  font-family: var(--font-display); letter-spacing: .08em; text-transform: uppercase;
  font-size: .62rem; color: var(--muted); margin: 0 0 .3rem;
}
.ambience-now { margin: 0 0 .65rem; line-height: 1.4; color: var(--ink-soft); min-height: 2.2em; }
.ambience-buttons { display: flex; gap: .4rem; margin-bottom: .65rem; }
.ambience-buttons button {
  flex: 1; padding: .38rem .5rem; background: transparent; font: inherit;
  border: 1px solid var(--hairline); border-radius: .32rem; color: var(--ink); cursor: pointer;
  transition: border-color .18s ease, color .18s ease;
}
.ambience-buttons button:hover { border-color: var(--rubric); color: var(--rubric); }
.ambience-vol { display: flex; align-items: center; gap: .55rem; font-size: .72rem; color: var(--muted); }
.ambience-vol input { flex: 1; accent-color: var(--rubric); }
.ambience-credit { margin: .6rem 0 0; font-size: .64rem; color: var(--muted); letter-spacing: .02em; }

@media (prefers-reduced-motion: reduce) {
  .ambience.playing .ambience-eq i { animation: none; height: 62%; }
  .ambience-toggle:hover { transform: none; }
}
/* Keep the control clear of the intro overlay until you enter. */
:root[data-intro="show"] .ambience { display: none; }

/* ---------- Privacy notice (clean bottom banner) ---------- */
.cookie-notice { position: fixed; left: clamp(.7rem, 2vw, 1.4rem); right: clamp(.7rem, 2vw, 1.4rem); bottom: clamp(.7rem, 2vw, 1.4rem); z-index: 70; max-width: 660px; margin: 0 auto; display: flex; align-items: center; gap: var(--u3); background: var(--paper); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: 0 14px 36px -12px rgba(14, 27, 51, .34); padding: var(--u2) var(--u3); font-size: .86rem; color: var(--ink-soft); }
.cookie-notice[hidden] { display: none; }   /* the class display:flex must not override [hidden] */
.cookie-notice p { margin: 0; line-height: 1.5; }
.cookie-notice a { color: var(--rubric); text-decoration: none; white-space: nowrap; }
.cookie-notice a:hover { text-decoration: underline; }
.cookie-ok { flex: 0 0 auto; background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: 9px 20px; font-family: var(--font-ui); font-weight: 600; font-size: .84rem; cursor: pointer; transition: background .15s; }
.cookie-ok:hover { background: var(--rubric); color: #fff; border-color: var(--rubric); }
:root[data-intro="show"] .cookie-notice { display: none; }
@media (max-width: 560px) { .cookie-notice { flex-direction: column; align-items: stretch; text-align: center; } }

/* ---------- Legal pages ---------- */
.legal-page { max-width: 68ch; }
.legal-page h1 { margin-bottom: var(--u); }
.legal-page h2 { margin: var(--u6) 0 var(--u); font-size: 1.2rem; }
.legal-page p, .legal-page li { line-height: 1.65; color: var(--ink-soft); }
.legal-page ul { padding-left: var(--u3); }
.legal-page li { margin: var(--u) 0; }
.legal-foot { margin-top: var(--u8); padding-top: var(--u3); border-top: 1px solid var(--hairline); }
