/* Thesis: white paper ground, one red accent (CLEAResult family), the Barlow
   superfamily only, Semi Condensed 700 for display and Barlow for text, one
   structural gesture: the red rule at the top. Ground 180deg in lightness from
   hunter2/pizza/greenic/brenergy, all near-black. */
:root {
  --paper: #ffffff;
  --surface: oklch(97% 0.004 60);
  --hairline: oklch(88% 0.006 60);
  --ink: oklch(25% 0.01 60);
  --ink-dim: oklch(48% 0.012 60);
  /* wordmark red sampled from CR.png, (215, 57, 39) */
  --red: #d73927;
  --red-deep: #b32f1f;
  --red-tint: #fcebe8;
  --good: oklch(45% 0.13 150);
  --nav-h: 64px;
  --radius-control: 4px;
  --font-body: "Barlow", system-ui, sans-serif;
  --font-display: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-bottom: var(--nav-h);
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  background: var(--paper);
  color: var(--ink);
  border-top: 4px solid var(--red);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 24px;
}

h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin: 32px 0 8px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

button {
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
.option-row:has(input:focus-visible) {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* slim header on the quiz and results screens */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
}

.topbar-logo {
  height: 18px;
  width: auto;
  display: block;
}

.logo {
  width: 180px;
  height: auto;
  display: block;
  margin: 24px 0 20px;
}

.topbar-right {
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* exit sits by the logo, dim and small, across the bar from Standards and
   well above the Next button's thumb zone */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.exit-btn {
  color: var(--ink-dim);
  font-weight: 500;
}

#exit-dialog {
  width: min(360px, calc(100% - 32px));
  padding: 24px;
  border: 0;
  border-top: 4px solid var(--red);
  border-radius: var(--radius-control);
  color: var(--ink);
  font-family: var(--font-body);
}

#exit-dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

#exit-dialog h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin: 0 0 8px;
}

#exit-dialog p {
  margin: 0 0 20px;
  color: var(--ink-dim);
}

.dialog-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-row .btn-primary {
  width: auto;
}

.start-standards {
  margin: 24px 0 0;
}

.start-standards .btn-text {
  padding: 0;
}

/* standards viewer: full-screen overlay, tab bar on top, one iframe per document */
#standards-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-top: 4px solid var(--red);
}

#standards-overlay[hidden] {
  display: none;
}

body.standards-open {
  overflow: hidden;
}

.standards-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--hairline);
}

.standards-tabs {
  display: flex;
  gap: 4px;
}

.standards-tabs button {
  min-height: 36px;
  padding: 0 7px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-dim);
  font-weight: 600;
  font-size: 14px;
}

.standards-tabs button.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

.standards-frames {
  flex: 1;
  position: relative;
}

.standards-frames iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
}

.standards-frames iframe.active {
  display: block;
}

.review-open {
  display: block;
  padding: 0;
  margin-top: 4px;
}

/* start screen */
.start-lede {
  margin: 0 0 16px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--red);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.seg-btn {
  min-height: 48px;
  background: var(--paper);
  color: var(--red);
  border: 0;
  border-left: 1px solid var(--red);
  font-weight: 600;
  padding: 0 8px;
}

.seg-btn:first-child {
  border-left: 0;
}

.seg-btn:hover,
.seg-btn:active {
  background: var(--red);
  color: var(--paper);
}

#pool-note {
  color: var(--ink-dim);
  font-size: 14px;
  margin: 12px 0 0;
}

/* quiz screen */
.progress-track {
  height: 4px;
  background: var(--hairline);
  margin: 0 0 24px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--red);
}

#question-domain {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  margin: 0 0 8px;
}

#question-stem {
  font-size: 18px;
  line-height: 1.4;
  margin: 0 0 24px;
}

#options-list {
  border-top: 1px solid var(--hairline);
}

.option-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 16px;
  align-items: start;
  min-height: 48px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
}

.option-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* 28px badge centered on the 24px first line of the option text */
.option-letter {
  width: 28px;
  height: 28px;
  margin-top: -2px;
  border: 1.5px solid var(--ink-dim);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
}

.option-row.selected {
  background: var(--red-tint);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.option-row.selected .option-letter {
  background: var(--red);
  border-color: var(--red);
  color: var(--paper);
}

.option-text {
  line-height: 24px;
}

.nav-row {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  padding: 8px 16px;
  background: var(--paper);
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-text {
  min-height: 48px;
  background: none;
  color: var(--red);
  border: 0;
  border-radius: var(--radius-control);
  font-weight: 600;
  padding: 0 12px;
}

.btn-text:disabled {
  color: var(--ink-dim);
  cursor: not-allowed;
}

.btn-text-small {
  min-height: 32px;
  font-size: 13px;
  padding: 0 4px;
}

.btn-primary {
  width: 100%;
  min-height: 48px;
  background: var(--red);
  color: var(--paper);
  border: 0;
  border-radius: var(--radius-control);
  font-weight: 600;
  padding: 0 24px;
}

.btn-primary:hover {
  background: var(--red-deep);
}

.btn-primary:disabled {
  background: var(--surface);
  color: var(--ink-dim);
  cursor: not-allowed;
}

/* scorecard */
.score-summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 16px 0 8px;
}

.score-pct {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 56px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-frac {
  color: var(--ink-dim);
}

.breakdown-row {
  display: grid;
  grid-template-columns: 88px 1fr 56px;
  align-items: center;
  gap: 16px;
  min-height: 40px;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}

.breakdown-row .frac {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 4px;
  background: var(--hairline);
}

.meter-fill {
  height: 100%;
  background: var(--red);
}

.review-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.review-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline);
}

.review-stem {
  margin: 0 0 8px;
}

.review-line {
  font-size: 14px;
  margin: 2px 0;
}

.pick-wrong {
  color: var(--red);
}

.pick-right {
  color: var(--good);
}

.review-source {
  color: var(--ink-dim);
  font-size: 13px;
  margin: 6px 0 0;
}

#review-empty {
  color: var(--ink-dim);
}

.restart-row {
  margin-top: 32px;
}

@media (min-width: 640px) {
  #app {
    padding-top: 32px;
    padding-bottom: 48px;
  }

  .nav-row {
    position: static;
    height: auto;
    padding: 24px 0 0;
    border-top: 0;
    display: flex;
    justify-content: space-between;
  }

  .btn-primary,
  .nav-row .btn-text {
    width: 160px;
  }

  .option-row.selected {
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
  }
}
