/* Alt Text Quiz — VIMS & Batten School 2026 brand.
   Palette: Midnight #06263B · Marine #00677E · River #85B8C7 · WM Gold #B79257
   Type: Brother 1816 -> Calibri -> Arial (licensed brand font, named backups). */

:root {
  --midnight: #06263B;
  --marine: #00677E;
  --marine-700: #004f60;
  --marine-050: #eef6f8;
  --river: #85B8C7;
  --gold: #B79257;
  --gold-050: #f8f2e6;
  --gold-ink: #6F5730;
  --ink: #10171c;
  --slate-900: #232b31;
  --slate-700: #4a545c;
  --slate-300: #aab2b8;
  --slate-200: #d1d6da;
  --slate-050: #f5f6f7;
  --white: #ffffff;
  --correct: #1E6B4F;
  --correct-bg: #EAF4EF;
  --radius: 4px;
  --shadow-1: 0 1px 3px rgba(6, 38, 59, 0.10);
  --font-sans: "Brother 1816", "Brother1816", Calibri, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--slate-050);
  line-height: 1.5;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

/* --- Accessibility helpers ---------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--midnight); color: var(--white); padding: 0.6rem 1rem; z-index: 60;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--marine); outline-offset: 2px; }

/* --- Screens ------------------------------------------------------------ */
.screen {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-top: 4px solid var(--marine);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 1.75rem;
}
.screen--center { text-align: center; }

h1, h2, h3 { font-family: var(--font-sans); color: var(--midnight); }
h1 { font-size: 2rem; line-height: 1.15; margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 0.65rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }

a { color: var(--marine); }
a:hover { color: var(--midnight); }

.lede { font-size: 1.1rem; max-width: 48ch; margin: 0 auto 1.5rem; }

.flair {
  display: block; width: 100%; max-height: 260px; object-fit: cover;
  border: 1px solid var(--slate-200); margin: 0 0 1.25rem;
}
.flair--high { object-position: center 26%; }

/* --- Intro -------------------------------------------------------------- */
.intro-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  column-gap: 1.75rem;
  align-items: start;
  margin-bottom: 1.25rem;
}
.intro-head-text > :first-child { margin-top: 0; }
@media (max-width: 699px) { .intro-head { display: block; } }

.example { margin: 0; }
.example-img {
  display: block; width: 100%; max-width: 340px; height: auto;
  border: 1px solid var(--slate-200); background: var(--white);
}
.example-caption {
  max-width: 340px; margin-top: 0.5rem; font-style: italic;
  font-size: 0.9rem; line-height: 1.45; color: var(--slate-900);
}
.example-label { font-style: normal; font-weight: 700; color: var(--midnight); }
@media (max-width: 699px) { .example { margin: 1.25rem 0; } }

.caveat { margin: 1rem 0 0; font-style: italic; font-size: 0.95rem; color: var(--slate-900); }

.key-question {
  margin: 0 0 1.25rem; padding: 0.9rem 1.15rem;
  background: var(--marine-050); border-left: 4px solid var(--marine);
}
.key-question-label {
  margin: 0 0 0.35rem; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--marine-700);
}
.key-question-text {
  margin: 0; font-size: 1.3rem; line-height: 1.3; font-weight: 600;
  color: var(--midnight); text-wrap: pretty;
}

.primer {
  background: var(--slate-050); border: 1px solid var(--slate-200);
  border-radius: var(--radius); padding: 0.75rem 1rem; margin: 1.25rem 0;
}
.primer > summary { cursor: pointer; font-weight: 600; color: var(--marine); }
.primer-body { margin-top: 0.75rem; }
.primer-body ul { padding-left: 1.2rem; }

.cms-note {
  margin: 0.75rem 0 0.25rem; padding: 0.6rem 0.85rem;
  background: var(--gold-050); border-left: 3px solid var(--gold);
  font-size: 0.92rem;
}
.cms-note-label {
  margin: 0 0 0.2rem; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-ink);
}
.cms-note p:last-child { margin-bottom: 0; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  font: inherit; font-size: 1rem; font-weight: 600;
  border-radius: var(--radius); padding: 0.65rem 1.35rem; cursor: pointer;
  border: 2px solid transparent;
  transition: background-color 0.22s cubic-bezier(0.2, 0, 0, 1),
              border-color 0.22s cubic-bezier(0.2, 0, 0, 1);
}
.btn--primary { background: var(--marine); border-color: var(--marine); color: var(--white); }
.btn--primary:hover:not(:disabled) { background: var(--midnight); border-color: var(--midnight); }
.btn--primary:disabled { background: var(--slate-300); border-color: var(--slate-300); cursor: not-allowed; }
.btn--secondary { background: var(--white); color: var(--marine); border-color: var(--marine); }
.btn--secondary:hover { background: var(--marine-050); }
.btn--lg { font-size: 1.125rem; padding: 0.85rem 2.1rem; }

/* --- Question: meta row + progress tracker ------------------------------ */
/* .q-meta is created by enhance.js: it wraps #progress and the segment track. */
.q-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.25rem; margin: 0 0 0.9rem;
}
.progress {
  color: var(--slate-700); font-weight: 700; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.1em; margin: 0;
}
.progress-track { display: flex; gap: 4px; flex: 0 0 auto; }
.progress-seg { width: 22px; height: 5px; border-radius: 2px; background: var(--slate-200); }
.progress-seg.is-done { background: var(--marine); }
.progress-seg.is-current { background: var(--gold); }

/* --- Question: figure + zoom ------------------------------------------- */
.q-figure { margin: 0 0 1rem; }
.q-zoom {
  display: block; width: 100%; padding: 0; line-height: 0;
  border: 1px solid var(--slate-200); background: var(--white); cursor: zoom-in;
  transition: border-color 0.22s cubic-bezier(0.2, 0, 0, 1);
}
.q-zoom:hover { border-color: var(--marine); }
.q-zoom img {
  display: block; width: 100%; max-height: 400px;
  object-fit: contain; object-position: top;
}
.q-zoom-hint {
  display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem;
  font-size: 0.85rem; font-weight: 600; color: var(--marine);
}
.q-zoom-hint svg { flex: 0 0 auto; }

.q-prompt {
  font-size: 1.3rem; line-height: 1.3; font-weight: 600;
  margin: 0 0 0.85rem; text-wrap: pretty;
}

/* --- Options ------------------------------------------------------------ */
.q-options-fieldset { border: 0; margin: 0; padding: 0; }
.q-options { display: flex; flex-direction: column; gap: 0.5rem; margin: 0 0 0.9rem; }

.option {
  display: flex; align-items: flex-start; gap: 0.65rem;
  border: 2px solid var(--slate-200); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; cursor: pointer; background: var(--white);
  font-size: 1rem; line-height: 1.35;
  transition: border-color 0.22s cubic-bezier(0.2, 0, 0, 1),
              background-color 0.22s cubic-bezier(0.2, 0, 0, 1);
}
.option:hover { border-color: var(--marine); background: var(--marine-050); }
.option input {
  margin-top: 0.15rem; flex: 0 0 auto; width: 1.1rem; height: 1.1rem;
  accent-color: var(--marine);
}
.option-text { flex: 1; }
.option:has(input:checked) { border-color: var(--marine); background: var(--marine-050); }

.option.is-correct { border-color: var(--correct); background: var(--correct-bg); }
.option.is-correct .option-text::after {
  content: " \2713 best answer"; font-weight: 700; color: var(--correct);
}
.option.is-wrong { border-color: var(--gold); background: var(--gold-050); }
.option.is-wrong .option-text::after {
  content: " \2190 your choice"; font-weight: 700; color: var(--gold-ink);
}
.option:has(input:disabled) { cursor: default; }
.option:has(input:disabled):hover { border-color: var(--slate-200); background: var(--white); }
.option.is-correct:hover { border-color: var(--correct); background: var(--correct-bg); }
.option.is-wrong:hover { border-color: var(--gold); background: var(--gold-050); }

/* --- Feedback ----------------------------------------------------------- */
.feedback {
  padding: 0.8rem 1rem; margin: 0 0 1rem;
  border-left: 4px solid var(--slate-300); background: var(--slate-050);
  font-size: 0.98rem;
}
.feedback.is-correct { border-left-color: var(--correct); background: var(--correct-bg); }
.feedback.is-wrong { border-left-color: var(--gold-ink); background: var(--gold-050); }
.feedback-heading { font-weight: 700; margin: 0 0 0.35rem; }
.feedback.is-correct .feedback-heading { color: var(--correct); }
.feedback.is-wrong .feedback-heading { color: var(--gold-ink); }
.feedback p:last-child { margin-bottom: 0; }

.cascade-note {
  margin: 0.85rem 0 0; padding: 0.55rem 0.8rem;
  border-left: 3px solid var(--gold); background: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
}
.cascade-note-label {
  margin: 0 0 0.2rem; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-ink);
}
.cascade-note p:last-child { margin-bottom: 0; }

.q-actions { display: flex; align-items: center; gap: 0.6rem; }
.q-actions-spacer { flex: 1; }

/* --- Lightbox (built by enhance.js) ------------------------------------- */
.lb {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.9rem; padding: 1.75rem;
  background: rgba(6, 38, 59, 0.94); cursor: zoom-out;
}
/* In embed mode the parent tells us where the visible strip is, so the overlay
   lands on screen instead of in the middle of a very tall iframe. */
.lb.is-positioned { position: absolute; inset: auto 0 auto 0; }
.lb img {
  max-width: 94vw; max-height: 82vh; object-fit: contain;
  background: var(--white); border: 1px solid #5b7d92;
}
.lb-close {
  font: inherit; font-size: 0.95rem; font-weight: 600;
  background: transparent; color: var(--white);
  border: 2px solid var(--river); border-radius: var(--radius);
  padding: 0.5rem 1.1rem; cursor: pointer;
}
.lb-close:hover { background: #0c3350; }

/* --- Results ------------------------------------------------------------ */
.final-score { font-size: 3.25rem; font-weight: 800; line-height: 1; color: var(--marine); margin: 0.25rem 0 0.4rem; }
.score-label { margin: 0 0 1rem; font-size: 0.95rem; color: var(--slate-700); }
.results-message { font-size: 1.1rem; max-width: 46ch; margin: 0 auto 1rem; text-wrap: pretty; }
.results-learn {
  text-align: left; max-width: 36rem; margin: 1.5rem auto 0;
  padding-top: 0.9rem; border-top: 2px solid var(--gold);
}
.learn-heading {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--slate-700); margin: 0 0 0.6rem;
}
.resources { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.resources a { font-weight: 600; }
.results-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.5rem; }
.share-status { min-height: 1.2em; margin: 0.7rem 0 0; color: var(--marine); font-weight: 600; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 520px) {
  .app { padding: 1rem 0.75rem 2rem; }
  .screen { padding: 1.25rem; }
  h1 { font-size: 1.6rem; }
  .q-meta { flex-wrap: wrap; gap: 0.5rem; }
  .q-actions { flex-wrap: wrap; }
  .q-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =========================================================================
   EMBED MODE — ?embed=1, inside the iframe on the Cascade page.
   The host page owns the title, the intro copy and the primer; the parent
   script sizes the iframe to this content, so every pixel here is page
   height. Trim hard, keep the screenshots big.
   ========================================================================= */

html.is-embed body { display: flow-root; background: var(--white); }

html.is-embed .screen {
  background: transparent; border: 0; border-radius: 0;
  box-shadow: none; padding: 0;
}

html.is-embed .app {
  padding: 1rem 1.25rem 1.5rem;
  max-width: 1140px;
}

/* The intro screen is one button: the explainer, the key question and the
   primer all live on the Cascade page now. Markup stays for the standalone
   version. */
html.is-embed .intro-content { display: none; }
html.is-embed #screen-intro { text-align: center; padding: 0.5rem 0 0.75rem; }

html.is-embed #screen-results { max-width: 1000px; margin: 0 auto; }

html.is-embed .q-prompt { font-size: 1.25rem; }
html.is-embed .option { font-size: 1rem; }

/* Results: photo and resources in a side column so the photo can breathe
   without a hard banner crop. The left column is one block (.results-main),
   so the side column's height can't stretch gaps into it. */
@media (min-width: 820px) {
  /* :not([hidden]) is load-bearing here too — display:grid would otherwise beat
     the UA stylesheet's [hidden] { display: none } and show the results screen
     underneath the live question. */
  html.is-embed #screen-results:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
    column-gap: 2.1rem;
    align-items: start;
    text-align: left;
  }
  html.is-embed #screen-results > .flair {
    grid-column: 2; grid-row: 1;
    height: 215px; max-height: none; margin: 0;
  }
  html.is-embed #screen-results > .results-main {
    grid-column: 1; grid-row: 1 / span 2;
  }
  html.is-embed #screen-results > .results-learn {
    grid-column: 2; grid-row: 2; margin: 1.1rem 0 0; max-width: none;
  }
  html.is-embed .results-message { margin-left: 0; margin-right: 0; }
  html.is-embed .results-actions { justify-content: flex-start; }
}

/* Question screen: screenshot beside the question, not above it. Reading
   order on screen matches DOM order for screen-reader users. */
@media (min-width: 820px) {
  /* :not([hidden]) is load-bearing — it must out-specify the UA stylesheet's
     [hidden] { display: none }, or the hidden screen shows as an empty grid. */
  html.is-embed #screen-question:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 462px);
    column-gap: 1.75rem;
    align-items: start;
  }
  html.is-embed #screen-question > .q-meta { grid-column: 1 / -1; grid-row: 1; }
  html.is-embed #screen-question > .q-figure {
    grid-column: 2; grid-row: 2; margin-bottom: 0;
  }
  html.is-embed #screen-question .q-zoom img { max-height: 520px; }
  html.is-embed #screen-question > .q-main { grid-column: 1; grid-row: 2; }
  html.is-embed #screen-question > .q-main > .q-prompt { margin-top: 0; }
}
