/* El Trivia, quiz page: compact bar, meta line, status rail, stage,
   dialogs specific to play, and the shared board primitives quizzes use. */

/* Compact bar ------------------------------------------------------- */

.quizbar { padding-top: var(--s-3); }
.quizbar-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  padding-bottom: var(--s-3);
}
.quizbar-back { margin-left: calc(-1 * var(--s-3)); padding-inline: var(--s-3); }
.quiz-title { min-width: 0; }
.quiz-title .entry-name { font-size: var(--fs-title-l); line-height: 1.05; }
.quiz-title .entry-no { font-size: var(--fs-ui); }
.quizbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-1) var(--s-2);
}
@media (max-width: 899.98px) {
  .quizbar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "back tools" "title title";
  }
  .quizbar-back { grid-area: back; justify-self: start; }
  .quizbar-tools { grid-area: tools; }
  .quiz-title { grid-area: title; }
  .quiz-title .entry-name { font-size: var(--fs-title-m); }
}
@media (max-width: 599.98px) {
  .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .quizbar-tools .btn { padding: 0; width: var(--target); }
  .quizbar-row { grid-template-areas: "back tools" "title title" "theme theme"; }
  .quizbar-tools { display: contents; }
  .quizbar-tools .btn:first-child { grid-area: tools; justify-self: end; margin-right: calc(var(--target) + var(--s-2)); }
  .quizbar-tools .btn:nth-child(2) { grid-area: tools; justify-self: end; }
  .quizbar-tools .theme-control { grid-area: theme; }
}

/* Layout ------------------------------------------------------------ */

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-12);
  align-items: start;
}
.ad--rail { display: none; margin: 0; }
@media (min-width: 1280px) {
  .quiz-layout[data-stage-size="narrow"],
  .quiz-layout[data-stage-size="square"] {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
  .quiz-layout[data-stage-size="narrow"] .ad--rail,
  .quiz-layout[data-stage-size="square"] .ad--rail {
    display: grid;
    position: sticky;
    top: var(--s-6);
    margin-top: 88px;
  }
}

/* Meta line --------------------------------------------------------- */

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  min-height: 48px;
  padding-block: var(--s-3);
}
.meta-text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-3);
  font-size: var(--fs-small);
  color: var(--ink-2);
}
.variant { display: flex; align-items: center; gap: var(--s-3); }

/* Status rail ------------------------------------------------------- */

.rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  background: var(--sunken);
  border-radius: var(--radius);
  min-height: 64px;
}
.rail-figures {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.rail-slot {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding-right: var(--s-5);
  margin-right: var(--s-5);
  border-right: 1px solid var(--rule);
  min-width: 4.5rem;
}
.rail-slot:last-child { border-right: 0; margin-right: 0; }
.rail-slot.is-unused { visibility: hidden; }
.rail-slot .label { font-size: var(--fs-label); }
.rail-value {
  font-size: var(--fs-lead);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
}
.rail-actions { display: flex; gap: var(--s-2); }
.rail-actions .btn { background: var(--panel); }
.rail-actions .btn.is-unused { visibility: hidden; }
.rail-actions .btn[disabled] { background: transparent; }
.rail-note {
  flex: 1 0 100%;
  font-size: var(--fs-small);
  color: var(--ink-2);
  padding-bottom: var(--s-1);
}
@media (max-width: 599.98px) {
  .rail { padding: var(--s-2) var(--s-3); }
  .rail-figures { flex: 1 0 100%; }
  .rail-slot { flex: 1 1 0; padding-right: var(--s-3); margin-right: var(--s-3); min-width: 0; }
  .rail-actions { flex: 1 0 100%; }
  .rail-actions .btn { flex: 1 1 0; }
}

/* Stage ------------------------------------------------------------- */

.stage-wrap {
  position: relative;
  margin-top: var(--s-4);
  display: flex;
  justify-content: center;
}
.stage {
  position: relative;
  width: 100%;
  min-height: var(--stage-min, 480px);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--s-5);
  container-type: inline-size;
}
.stage[data-size="narrow"] { max-width: 380px; }
.stage[data-size="wide"] { max-width: 960px; }
.stage[data-size="square"] {
  width: min(92vw, 560px, 100%);
  min-height: 0;
  aspect-ratio: 1 / 1;
  padding: var(--s-3);
}
@media (max-width: 599.98px) {
  .stage { padding: var(--s-4); }
  .stage[data-size="square"] { padding: var(--s-2); }
}

.stage-board { height: 100%; }

.stage-skeleton {
  display: grid;
  gap: var(--s-3);
  align-content: start;
}
.sk {
  display: block;
  background: var(--sunken);
  border-radius: 2px;
}
.sk--line { height: 12px; width: 40%; }
.sk--title { height: 28px; width: 75%; margin-bottom: var(--s-3); }
.sk--block { height: 52px; }
.stage[data-size="square"] .stage-skeleton { height: 100%; grid-template-rows: auto auto repeat(4, 1fr); }

.stage-noscript { color: var(--ink); }

/* Pause cover */
.stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.stage-overlay-inner {
  pointer-events: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-6);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}
.stage-wrap[data-size="narrow"] .stage-overlay-inner { max-width: 380px; }
.stage-wrap[data-size="wide"] .stage-overlay-inner { max-width: 960px; }
.stage-wrap[data-size="square"] .stage-overlay-inner { max-width: min(92vw, 560px, 100%); }
.overlay-title {
  font-family: var(--font-display);
  font-size: var(--fs-title-s);
  font-weight: 500;
  line-height: var(--lh-tight);
}

/* Messages inside the stage: errors, done today */
.stage-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
  padding-top: var(--s-2);
}
.stage-message h2 {
  font-family: var(--font-display);
  font-size: var(--fs-title-s);
  font-weight: 500;
  line-height: var(--lh-tight);
}
.stage-message p { color: var(--ink-2); }
.stage-message .btn { margin-top: var(--s-2); }

.done-today {
  padding-bottom: var(--s-5);
  margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.done-today .result-headline { font-size: var(--fs-title-s); }
.done-today .result-record { margin-block: var(--s-3) var(--s-2); }
.done-today .result-time { font-size: 3rem; }
.done-today-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}
.finished-board { opacity: 1; }

/* Notes: About and More in ------------------------------------------ */

.notes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: var(--s-8) var(--s-10);
  margin-top: var(--s-10);
  padding-top: var(--s-4);
  border-top: 1px solid var(--ink);
}
.notes .section-title { margin-bottom: var(--s-3); }
.notes-about .prose { max-width: 60ch; color: var(--ink); }
@media (max-width: 767.98px) {
  .notes { grid-template-columns: minmax(0, 1fr); }
}

.index-list--compact { border-top: 1px solid var(--rule); }
.index-list--compact .index-link {
  grid-template-columns: 3.75rem minmax(0, 1fr) auto;
  padding-inline: var(--s-1);
}
.index-list--compact .ix-name .entry-name { font-size: var(--fs-lead); }
.index-list--compact .ix-time { color: var(--ink-2); }
@media (max-width: 719.98px) {
  .index-list--compact { border-top: 1px solid var(--rule); }
  .index-list--compact .ix-time { margin-left: 0; }
}

.ad--below { margin-top: var(--s-12); }

/* Dialogs ----------------------------------------------------------- */

.dialog-entry { margin-bottom: var(--s-1); }
.dialog-entry .entry-name { font-size: var(--fs-lead); }

.howto-list {
  display: grid;
  gap: var(--s-3);
  padding-left: 1.4em;
  font-size: var(--fs-body);
}
.howto-list li::marker {
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ink-2);
  font-weight: 500;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  margin: 0 0 var(--s-5);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.stats-cell {
  padding: var(--s-2) var(--s-3) var(--s-3);
  border-left: 1px solid var(--rule);
}
.stats-cell:first-child { border-left: 0; padding-left: 0; }
.stats-cell dd {
  margin: 2px 0 0;
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.15;
}
.dist-title { margin-bottom: var(--s-2); }
.dist {
  list-style: none;
  display: grid;
  gap: 6px;
}
.dist li {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-small);
}
.dist-n { color: var(--ink-2); text-align: right; }
.dist-bar {
  display: block;
  width: var(--w, 0%);
  min-width: 2rem;
  padding: 3px var(--s-2);
  background: var(--ink);
  color: var(--paper);
  text-align: right;
  font-weight: 600;
  border-radius: 2px;
}
.dist-bar.is-zero { background: var(--sunken); color: var(--ink); }
.stats-empty { display: grid; gap: var(--s-4); justify-items: start; }

/* Result */
.result-dialog { width: min(440px, calc(100vw - 2 * var(--s-4))); }
.result-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-3);
}
.result-entry .entry-name { font-size: var(--fs-title-s); }
.result-puzzle { margin-top: 2px; }
.result-headline {
  position: relative;
  margin-top: var(--s-6);
  padding-bottom: var(--s-3);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-title-m);
  line-height: 1.15;
  font-optical-sizing: auto;
}
/* The only celebration: one rule drawn under the headline. */
.result-headline::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--ink);
  transform-origin: left center;
}
.result-headline.is-drawing::after { animation: draw-rule var(--dur-rule) var(--ease) both; }
@keyframes draw-rule {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.result-record {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  margin-block: var(--s-4) var(--s-3);
}
.result-time {
  font-family: var(--font-display);
  font-size: var(--fs-record);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-optical-sizing: auto;
}
.result-lines {
  list-style: none;
  display: grid;
  gap: var(--s-1);
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule);
  font-size: var(--fs-ui);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums lining-nums;
}
.result-lines strong { color: var(--ink); font-weight: 600; }
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  margin-top: var(--s-6);
}
.result-actions > :first-child { grid-column: 1 / -1; }
.result-next {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target);
  font-size: var(--fs-small);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0 var(--s-2);
  text-align: center;
}
.result-next time { color: var(--ink); font-weight: 600; margin-left: 0.35em; }

/* Board primitives quizzes may use ---------------------------------- */

/* A lettered tile with a feedback state. Colour is never the only cue:
   each state adds a corner mark, and partial adds a hatch. */
.tile {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1.5px solid var(--line-strong);
  border-radius: 2px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1;
  text-transform: uppercase;
}
.tile[data-state] { border-color: transparent; color: var(--on-state); }
.tile[data-state="correct"] { background: var(--state-correct); }
.tile[data-state="partial"] {
  background-color: var(--state-partial);
  /* Diagonal hatch as a second, non-colour cue. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M-2 2l4-4M0 8l8-8M6 10l4-4' stroke='%23fff' stroke-opacity='.18' stroke-width='1.5'/%3E%3C/svg%3E");
}
.tile[data-state="wrong"] { background: var(--state-wrong); }
.tile[data-state="absent"] { background: var(--state-absent); }
.tile-cue {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  stroke-width: 2;
}
.tile[data-state="absent"] .tile-cue-bar {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 16px;
  height: 2px;
  margin-left: -8px;
  background: currentColor;
}
.tile[data-state="partial"] .tile-cue-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

/* ================================================================== */
/* DEMO: removable. Styles for js/quizzes/demo.js only.                */
/* ================================================================== */

.demo { display: flex; flex-direction: column; gap: var(--s-4); }
.demo-kicker { font-size: var(--fs-label); }
.demo-question {
  font-family: var(--font-display);
  font-size: var(--fs-title-s);
  font-weight: 500;
  line-height: var(--lh-tight);
}
.demo-choices { list-style: none; display: grid; gap: var(--s-2); }
.demo-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  min-height: 48px;
  padding: 0 var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 500;
  text-align: left;
}
.demo-choice:hover:not([aria-disabled="true"]) { border-color: var(--ink); background: var(--signal-wash); }
.demo-choice[data-state] { color: var(--on-state); border-color: transparent; }
.demo-choice[data-state="correct"] { background: var(--state-correct); }
.demo-choice[data-state="wrong"] { background: var(--state-wrong); }
.demo-choice[aria-disabled="true"] { cursor: default; }
.demo-choice .icon { flex: none; }
.demo-choice-cue { font-size: var(--fs-small); font-weight: 600; display: inline-flex; align-items: center; gap: var(--s-1); }
.demo-feedback { min-height: 1.6em; font-size: var(--fs-ui); color: var(--ink-2); }
.demo-next { align-self: flex-start; }
.demo-summary { display: grid; gap: var(--s-2); list-style: none; font-size: var(--fs-ui); }
.demo-summary li { display: flex; justify-content: space-between; gap: var(--s-3); border-bottom: 1px solid var(--rule); padding-bottom: var(--s-2); }

.specimen {
  margin-top: var(--s-2);
  padding-top: var(--s-4);
  border-top: 1px dashed var(--line-strong);
}
.specimen-title { margin-bottom: var(--s-3); }
.specimen-row {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-2);
}
.specimen-row li { display: grid; justify-items: center; gap: var(--s-1); font-size: var(--fs-label); color: var(--ink-2); text-align: center; }
@container (max-width: 300px) {
  .specimen-row .tile { width: 44px; height: 44px; font-size: 1.25rem; }
}
