/* ============================================================
   Docket — Daily Evidence
   Editorial / longread foundation. Light parchment default.
   (Dark mode is a later refinement — see :root tokens.)
   ============================================================ */

:root {
  /* Palette — warm parchment, deep ink, oxblood + navy accents */
  --paper:        #f7f3ea;
  --paper-raised: #fffdf7;
  --ink:          #20242c;   /* body text */
  --ink-soft:     #555b66;
  --ink-faint:    #8a8f99;
  --navy:         #1f3350;   /* headings / structure */
  --oxblood:      #7a2e35;   /* primary accent */
  --oxblood-soft: #9a4a51;
  --rule:         #e4ddcc;   /* hairlines */
  --rule-strong:  #d4cab2;
  --gold:         #b08a3e;   /* subtle highlight */

  /* Type */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --serif:   "Newsreader", Georgia, "Times New Roman", serif;
  --ui:      "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Reading measure ~ 66ch */
  --measure: 40rem;

  --shadow: 0 1px 2px rgba(31, 36, 44, .04), 0 8px 24px rgba(31, 36, 44, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fbf8f0 0%, var(--paper) 60%) fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding-inline: 1.5rem;
}

/* ---------- Masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--rule);
  padding: 2.4rem 0 1.6rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  flex-wrap: wrap;
}
.brand-mark {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  letter-spacing: -.01em;
  color: var(--navy);
  line-height: 1;
}
.brand-sub {
  font-family: var(--ui);
  font-weight: 500;
  font-size: .82rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--oxblood);
  padding-bottom: .15rem;
}
.tagline {
  margin: .55rem 0 0;
  font-family: var(--ui);
  font-size: .92rem;
  color: var(--ink-soft);
  letter-spacing: .01em;
}

/* ---------- Day picker ---------- */
.picker {
  /* Static — sits at the top and scrolls away with the page (not pinned). */
  border-bottom: 1px solid var(--rule);
  padding: .9rem 0;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: .5rem;
}
.day-btn {
  position: relative;
  font-family: var(--ui);
  font-weight: 500;
  font-size: .95rem;
  color: var(--navy);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: .55rem;
  min-height: 2.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease,
              background .15s ease, color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.day-btn:hover { border-color: var(--navy); transform: translateY(-1px); }
.day-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.day-btn.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--paper-raised);
  box-shadow: var(--shadow);
}
.day-btn.is-locked {
  /* Recessive: lighter weight, fainter ink + border, dimmed — so the
     unlocked day(s) clearly carry the eye. */
  font-weight: 400;
  color: var(--ink-faint);
  background: transparent;
  border: 1px dashed var(--rule);
  cursor: not-allowed;
  opacity: .5;
}
.day-btn.is-locked:hover { transform: none; border-color: var(--rule); opacity: .5; }
.day-btn .lock {
  width: .72rem; height: .72rem;
  margin-left: .3rem;
  opacity: .75;
}

/* Newest unlocked day — a small accent dot that beckons the user back.
   JS only applies .is-newest when that day is NOT the active one. */
.day-btn.is-newest::after {
  content: "";
  position: absolute;
  top: .34rem;
  right: .34rem;
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--oxblood);
}

/* ---------- Reader ---------- */
.reader {
  padding-block: clamp(2rem, 5vw, 3.5rem) 4rem;
}
.article { max-width: var(--measure); margin: 0 auto; }

.article.swapping { opacity: 0; transform: translateY(6px); }
.article {
  opacity: 1;
  transform: none;
  transition: opacity .22s ease, transform .22s ease;
}

.eyebrow {
  font-family: var(--ui);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--oxblood);
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .9rem;
}
.eyebrow .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--gold);
}
.eyebrow .date { color: var(--ink-faint); font-weight: 500; letter-spacing: .08em; }

.topic {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2rem, 4.6vw, 3rem);
  line-height: 1.12;
  letter-spacing: -.015em;
  color: var(--navy);
  margin: 0 0 1.6rem;
}

.essay {
  /* Newsreader's default ligatures (ff, fi, fl, ffi, …) read as distracting
     in long body text — disable them so each letter renders separately.
     NOTE: body sets `text-rendering: optimizeLegibility`, which is INHERITED
     and force-enables ligatures, overriding font-variant-ligatures. We reset
     it to `auto` here (kerning is kept) so the ligature-off rules take effect. */
  text-rendering: auto;
  font-variant-ligatures: none;
  -webkit-font-feature-settings: "liga" 0, "clig" 0, "dlig" 0;
  font-feature-settings: "liga" 0, "clig" 0, "dlig" 0;
}
.essay > * + * { margin-top: 1.2rem; }
.essay p + p { margin-top: 1.5rem; }
.essay p {
  margin: 0;
  hyphens: auto;
}
.essay p.lead::first-letter {
  font-family: var(--display);
  font-weight: 600;
  float: left;
  font-size: 3.4rem;
  line-height: .82;
  padding: .18rem .6rem .1rem 0;
  color: var(--oxblood);
}
.essay h3 {
  font-family: var(--ui);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--oxblood);
  margin: 2.2rem 0 .2rem;
}
.essay blockquote {
  margin: 1.6rem 0;
  padding-left: 1.2rem;
  border-left: 3px solid var(--gold);
  color: var(--ink-soft);
  font-style: italic;
}
.essay em { font-style: italic; }
.essay strong { font-weight: 600; color: var(--ink); }

.fallback-note {
  font-family: var(--ui);
  font-size: .9rem;
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--gold);
  border-radius: .4rem;
  padding: .8rem 1rem;
  margin-bottom: 1.6rem;
}

/* ---------- Questions ---------- */
.questions {
  max-width: var(--measure);
  margin: 3.5rem auto 0;
  padding-top: 2.2rem;
  border-top: 1px solid var(--rule-strong);
}
.questions-head {
  font-family: var(--ui);
  font-weight: 700;
  font-size: .92rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1.6rem;
}
.q {
  margin-bottom: 2rem;
  padding-bottom: 1.8rem;
  border-bottom: 1px solid var(--rule);
}
.q:last-child { border-bottom: 0; }
.q-num {
  font-family: var(--ui);
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .12em;
  color: var(--oxblood);
}
.q-stem {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.55;
  margin: .35rem 0 1rem;
}
.choices { list-style: none; margin: 0; padding: 0; }
.choices li {
  font-family: var(--ui);
  font-size: .96rem;
  line-height: 1.45;
  padding: .55rem .7rem .55rem .55rem;
  border-radius: .4rem;
  display: flex;
  gap: .6rem;
  color: var(--ink-soft);
}
.choices li .letter {
  font-weight: 600;
  color: var(--ink-faint);
  min-width: 1.2rem;
}
.choices li.correct {
  background: rgba(122, 46, 53, .07);
  color: var(--ink);
}
.choices li.correct .letter { color: var(--oxblood); }
.choices li.correct::after {
  content: "✓";
  margin-left: auto;
  color: var(--oxblood);
  font-weight: 700;
}
.explanation {
  margin-top: .9rem;
  font-family: var(--serif);
  font-size: .98rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.explanation .label {
  font-family: var(--ui);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--navy);
  margin-right: .4rem;
}

/* ---------- Prev / Next day navigation (end of article) ---------- */
.daynav {
  display: flex;
  gap: 1rem;
  justify-content: center;          /* lone button sits centered */
  max-width: var(--measure);
  margin: 3.25rem auto 0;
  padding-top: 2.2rem;
  border-top: 1px solid var(--rule-strong);
}
.daynav--split { justify-content: space-between; }  /* both buttons: edges */
.daynav-btn {
  flex: 1 1 0;
  max-width: 23rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .95rem 1.2rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: .6rem;
  cursor: pointer;
  text-align: left;
  transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.daynav-btn:hover {
  border-color: var(--navy);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.daynav-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.daynav-next { text-align: right; align-items: flex-end; }
.daynav-dir {
  font-family: var(--ui);
  font-weight: 600;
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--oxblood);
}
.daynav-topic {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--navy);
}

/* ---------- Colophon ---------- */
.colophon {
  border-top: 1px solid var(--rule);
  padding: 1.8rem 0 2.6rem;
}
.colophon p {
  margin: 0;
  font-family: var(--ui);
  font-size: .82rem;
  color: var(--ink-faint);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(1.5rem);
  background: var(--navy);
  color: var(--paper-raised);
  font-family: var(--ui);
  font-size: .9rem;
  padding: .65rem 1.1rem;
  border-radius: .5rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Back to top ---------- */
.back-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
  width: 2.85rem;
  height: 2.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-raised);
  color: var(--navy);
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;            /* non-interactive while hidden */
  transform: translateY(.4rem);
  /* NB: 'bottom' is set inline by JS to ride above the prev/next nav, so it
     is intentionally NOT transitioned (would lag while tracking on scroll). */
  transition: opacity .25s ease, transform .25s ease, visibility .25s,
              border-color .15s ease, color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.back-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-top:hover { border-color: var(--navy); color: var(--oxblood); }
.back-top:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.back-top svg { width: 1.15rem; height: 1.15rem; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 1.12rem; line-height: 1.72; }
  .wrap { padding-inline: 1.15rem; }
  .picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(2.7rem, 1fr));
    gap: .4rem;
  }
  .day-btn { min-height: 3rem; font-size: .9rem; }
  .essay p.lead::first-letter { font-size: 3rem; }
  /* Stack prev/next full-width for easy thumbs */
  .daynav { flex-direction: column; }
  .daynav-btn { max-width: none; }
  .daynav-next { text-align: left; align-items: flex-start; }
}

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