@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 700 800; font-display: swap;
  src: url(/fonts/fraunces-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  --bg: #fbf6ee;
  --bg-glow: #ffe7c2;
  --surface: #ffffff;
  --text: #1f1b3a;
  --muted: #6b6788;
  --line: #ebe3d6;
  --accent: #ff7a1a;
  --accent-2: #ffb21a;
  --accent-ink: #1f1b3a;
  --focus: #c2410c;
  --shadow: 0 18px 50px -20px rgba(64, 40, 10, .35);
  --radius: 22px;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12102a;
    --bg-glow: #2c1f55;
    --surface: #1d1a3d;
    --text: #f4f0ff;
    --muted: #a9a3cc;
    --line: #2f2b58;
    --accent: #ff8a2e;
    --accent-2: #ffc23d;
    --accent-ink: #1a1030;
    --focus: var(--accent);
    --shadow: 0 18px 60px -20px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--ui);
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), transparent 70%), var(--bg);
  background-attachment: fixed;
  line-height: 1.55;
}
a { color: inherit; }
a:hover { color: var(--accent); }

/* ---------- header / footer ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 18px 16px;
}
.logo {
  font-family: var(--display); font-weight: 800; font-size: 1.35rem;
  text-decoration: none; letter-spacing: -.01em;
}
.logo span { color: var(--accent); }
.streak {
  font-size: .85rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
  background: var(--surface);
}
.streak[hidden] { display: none; }
.foot {
  max-width: 760px; margin: 48px auto 0; padding: 24px 16px 40px;
  text-align: center; color: var(--muted); font-size: .88rem;
  border-top: 1px solid var(--line);
}
.foot nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.foot a { text-decoration: none; }

/* ---------- layout with optional side rails ---------- */
.layout {
  display: grid; grid-template-columns: 1fr; gap: 24px;
  max-width: 1100px; margin: 0 auto; padding: 0 16px;
}
.rail { display: none; }
@media (min-width: 1180px) {
  /* 1150px leaves a 750px middle column, enough for a 728px banner. */
  .layout.has-rails { grid-template-columns: 160px minmax(0, 1fr) 160px; max-width: 1150px; }
  .layout.has-rails .rail { display: block; }
  .rail .ad-slot { position: sticky; top: 24px; min-height: 300px; }
}
.main { min-width: 0; }

/* ---------- home: the one button ---------- */
.stage {
  min-height: 62vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 0 8px;
}
.stage h1 {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.05; letter-spacing: -.02em;
  margin: 0 0 10px;
}
.stage .date { color: var(--muted); margin: 0 0 40px; }

.reveal-btn {
  --size: clamp(190px, 46vw, 240px);
  width: var(--size); height: var(--size); border-radius: 50%;
  border: 0; cursor: pointer;
  font: 800 1.25rem/1.15 var(--display); color: var(--accent-ink);
  background: radial-gradient(circle at 30% 25%, var(--accent-2), var(--accent) 70%);
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 18%, transparent),
              0 0 80px 10px color-mix(in srgb, var(--accent) 45%, transparent);
  animation: breathe 3.2s ease-in-out infinite;
  transition: transform .15s ease;
}
.reveal-btn small { display: block; font: 600 .8rem var(--ui); opacity: .8; margin-top: 6px; }
.reveal-btn:hover { transform: scale(1.04); }
.reveal-btn:active { transform: scale(.97); }
.reveal-btn:focus-visible { outline: 3px solid var(--text); outline-offset: 6px; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 18%, transparent), 0 0 60px 6px color-mix(in srgb, var(--accent) 35%, transparent); }
  50%      { box-shadow: 0 0 0 18px color-mix(in srgb, var(--accent) 12%, transparent), 0 0 100px 18px color-mix(in srgb, var(--accent) 50%, transparent); }
}
.stage.revealed .reveal-btn,
.stage.revealed .date { display: none; }

/* ---------- fact card ---------- */
.card {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 26px 22px; text-align: left;
}
.card[hidden] { display: none; }
.stage.revealed .card { animation: pop .55s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--cat, var(--accent)) 16%, transparent);
  color: color-mix(in srgb, var(--cat, var(--accent)) 50%, var(--text));
}
.fact-text {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.45rem, 4.2vw, 2rem); line-height: 1.2; letter-spacing: -.01em;
  margin: 14px 0 12px;
}
.fact-detail { color: var(--muted); margin: 0 0 16px; font-size: 1.02rem; }
.fact-meta { font-size: .85rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }

.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 22px 0 6px; }
.btn {
  font: 700 1rem var(--ui); cursor: pointer; text-decoration: none;
  padding: 12px 22px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); color: var(--accent-ink); }
.countdown { color: var(--muted); font-size: .9rem; margin: 10px 0 0; }
.countdown[hidden], .actions[hidden] { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* ---------- ads ----------
   app.js marks a slot .ad-pending (space reserved while loading) and then
   .ad-filled once an ad appears. Unfilled slots stay hidden: no empty boxes. */
.ad-wrap { margin: 0 auto; max-width: 728px; text-align: center; }
.ad-wrap:has(.ad-pending, .ad-filled) { margin: 36px auto; }
.ad-label {
  display: none; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.ad-wrap:has(.ad-filled) .ad-label { display: block; }
.ad-slot { display: none; align-items: center; justify-content: center; overflow: hidden; }
.ad-slot.ad-pending, .ad-slot.ad-filled { display: flex; }
/* ?ads=preview shows every slot as a dashed box (ads are not loaded) */
.ad-preview .ad-wrap { margin: 36px auto; }
.ad-preview .ad-label { display: block; }
.ad-preview .ad-slot {
  display: flex; min-height: 90px; border: 2px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: .8rem; background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.ad-preview .ad-slot::after { content: "Ad slot: " attr(data-slot); }
.ad-preview .rail .ad-slot { min-height: 300px; }
/* ---------- content pages ---------- */
.page { max-width: 680px; margin: 0 auto; padding: 8px 0; }
.page h1 { font-family: var(--display); font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.1; letter-spacing: -.02em; margin: 10px 0 18px; }
.page h2 { font-family: var(--display); margin-top: 36px; }
.crumbs { font-size: .85rem; color: var(--muted); }
.crumbs a { text-decoration: none; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; font-size: .92rem; }
.pager a { text-decoration: none; max-width: 48%; }
.cat-group { margin-top: 30px; }
.cat-group ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.cat-group li a {
  display: block; text-decoration: none; padding: 12px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.cat-group li a:hover { border-color: var(--accent); }
.about-line { text-align: center; color: var(--muted); max-width: 560px; margin: 8px auto 0; font-size: .95rem; }

@media (prefers-reduced-motion: reduce) {
  .reveal-btn, .stage.revealed .card { animation: none; }
}

/* ---------- "that's all for today" ---------- */
.done {
  margin: 22px auto 0; max-width: 460px; padding: 20px 22px;
  border-radius: var(--radius); border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.done[hidden] { display: none; }
.done p { margin: 0; }
.done-title { font-family: var(--display); font-weight: 800; font-size: 1.35rem; }
.done-sub { color: var(--muted); margin-top: 4px !important; }
.done-sub strong { color: var(--text); font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.done-streak { margin-top: 10px !important; font-weight: 600; }
.done-streak[hidden] { display: none; }
.pager a:last-child { margin-left: auto; }



/* ---------- 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;
}
.fact-text:focus { outline: none; }
.fact-text:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.load-error { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-top: 18px; max-width: 460px; }
.load-error[hidden] { display: none; }
/* Fact pages use a 680px text column; let ads use the full main column (up to 728px). */
.page .ad-wrap { width: 728px; max-width: calc(100vw - 32px); position: relative; left: 50%; transform: translateX(-50%); }
.page .ad-wrap, .page .ad-wrap:has(.ad-pending, .ad-filled) { margin-left: 0; margin-right: 0; }

.ad-note { display: none; margin: 6px auto 0; max-width: 520px; font-size: .75rem; line-height: 1.4; color: var(--muted); }
.ad-wrap:has(.ad-filled) .ad-note, .ad-preview .ad-note { display: block; }

/* ---------- save / add to home screen ---------- */
/* Save sits next to the logo (top-left): ad networks float their in-page ads in the top-right corner. */
.top-left { display: flex; align-items: center; gap: 12px; }
.save-btn {
  font: 700 .85rem var(--ui); cursor: pointer; color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line)); border-radius: 999px;
  padding: 0 16px; min-height: 40px; background: var(--surface);
}
.save-btn:hover { border-color: var(--accent); }
.save-btn:focus-visible, .save-inline:focus-visible, .save-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.save-btn[hidden], .save-inline[hidden] { display: none; }
.save-inline { margin-top: 14px; font-size: .92rem; padding: 10px 18px; }

.save-tip {
  position: fixed; z-index: 50; width: 320px;
  top: 64px; left: max(16px, calc((100vw - 1150px) / 2 + 16px));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 18px 20px 20px; animation: tipIn .18s ease-out;
}
.save-tip[hidden] { display: none; }
.save-title { font-family: var(--display); font-weight: 800; font-size: 1.15rem; margin: 0 28px 8px 0; }
.save-body { margin: 0 0 4px; color: var(--muted); font-size: .95rem; }
.save-body strong { color: var(--text); }
.save-tip kbd {
  font: 700 .85rem var(--ui); padding: 1px 7px; border-radius: 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--bg); color: var(--text);
}
.save-tip .btn { margin-top: 12px; width: 100%; }
.save-tip .btn[hidden] { display: none; }
.save-close {
  position: absolute; top: 8px; right: 10px; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.save-close:hover { background: var(--bg); color: var(--text); }
@keyframes tipIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Phones: slide-up panel at the bottom, within thumb reach. */
@media (max-width: 599px) {
  .save-tip {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
    animation-name: sheetIn; animation-duration: .22s;
  }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
}
@media (prefers-reduced-motion: reduce) { .save-tip { animation: none; } }

@media (max-width: 420px) {
  .streak-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* "Wed, Oct 15 · Fact #9" above the headline */
.today-line {
  margin: 0 0 10px; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.today-line[hidden] { display: none; }
