/* Fun Facts, the grown-up fact pages (/sun-facts, /moon-facts). An engraved,
   editorial look: hairline drawings, one accent color, a serif for display.
   This is the light theme; fun-facts-dark.css overrides it (linked like
   css/dark.css, so it follows the OS or the theme chosen in Settings). */

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2");
}

.ff {
  --ff-serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --ff-ink: #24262c;
  --ff-muted: #858994;
  --ff-acc: #a07a35;
  --ff-wash: rgb(160 122 53 / 0.1);
  --ff-paper: var(--bg);
  --ff-card: var(--surface);
  --ff-rule: var(--line);
}
.ff-moon {
  --ff-acc: #4f5f8f;
  --ff-wash: rgb(79 95 143 / 0.09);
}

/* ---------- Drawings (classes from tools/fact-pages/fine.py) ---------- */

.ff .ff-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ff svg { display: block; width: 100%; height: auto; }
.p-ink { fill: none; stroke: var(--ff-ink); stroke-width: 0.8; stroke-linecap: round; stroke-linejoin: round; }
.p-fine { fill: none; stroke: var(--ff-muted); stroke-width: 0.55; stroke-linecap: round; stroke-linejoin: round; }
.p-dash { fill: none; stroke: var(--ff-muted); stroke-width: 0.6; stroke-dasharray: 2 2; }
.p-acc { fill: none; stroke: var(--ff-acc); stroke-width: 0.9; stroke-linecap: round; stroke-linejoin: round; }
.p-bold { stroke-width: 1.3; }
.p-inkf { fill: var(--ff-ink); stroke: none; }
.p-accf { fill: var(--ff-acc); stroke: none; }
.p-wash { fill: var(--ff-wash); stroke: none; }
.p-paper { fill: var(--ff-paper); stroke: none; }
.p-hatch { fill: url(#pHatch); stroke: none; }
.p-hatch-acc { fill: url(#pHatchAcc); stroke: none; }
.p-dots { fill: url(#pDots); stroke: none; }
.p-shade { fill: var(--ff-ink); fill-opacity: 0.16; stroke: none; }
.p-hatch-line { stroke: var(--ff-muted); stroke-width: 0.45; }
.p-hatch-acc-line { stroke: var(--ff-acc); stroke-width: 0.55; }
.p-dot { fill: var(--ff-muted); }
.p-star { fill: var(--ff-muted); opacity: 0.8; }
.p-ray { opacity: 0.55; }
.p-lbl { fill: var(--ff-muted); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 500; letter-spacing: 0.08em; }
.p-num { fill: var(--ff-ink); font-family: var(--ff-serif); font-weight: 500; letter-spacing: 0; }
.p-it { font-style: italic; }
.p-mark { fill: var(--ff-ink); font-weight: 600; letter-spacing: 0; }

.p-spin { transform-box: view-box; transform-origin: 200px 200px; animation: ff-spin 240s linear infinite; }
@keyframes ff-spin { to { transform: rotate(360deg); } }

/* ---------- Hero ---------- */

.ff-hero {
  display: grid;
  gap: 8px 40px;
  align-items: center;
  padding: 12px 0 28px;
}
.ff-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  font-size: 0.9rem;
  margin-bottom: 26px;
}
.ff-switch a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 1px solid transparent; }
.ff-switch a:hover { color: var(--text); }
.ff-switch a[aria-current="page"] { color: var(--text); border-bottom-color: var(--ff-acc); }
.ff-switch .ff-kids { margin-left: auto; font-size: 0.85rem; }
.ff-kicker {
  color: var(--ff-acc);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.ff h1, .ff h2, .ff h3 { font-family: var(--ff-serif); font-weight: 500; }
.ff h1 {
  margin-top: 10px;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 1;
  letter-spacing: -0.01em;
}
.ff-lede { margin-top: 18px; max-width: 34rem; color: var(--muted); font-size: 1.06rem; line-height: 1.6; }
.ff-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.ff-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid var(--ff-acc);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.ff-btn:hover { background: var(--ff-wash); }
.ff-btn[hidden] { display: none; }
.ff-btn-quiet { border-color: var(--ff-rule); }
.ff-plate { max-width: 440px; width: 100%; justify-self: center; }
.ff-plate svg { --ff-paper: var(--bg); }

@media (min-width: 860px) {
  .ff-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 420px); }
}

/* ---------- Contents ---------- */

.ff-contents {
  list-style: none;
  margin: 0 0 8px;
  padding: 14px 0;
  border-top: 1px solid var(--ff-rule);
  border-bottom: 1px solid var(--ff-rule);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 4px 16px;
}
.ff-contents a {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: baseline;
  padding: 6px 4px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
}
.ff-contents a:hover { background: var(--ff-wash); }
.ff-numeral { font-family: var(--ff-serif); color: var(--ff-acc); font-size: 1.2rem; }
.ff-contents small { grid-column: 2; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.06em; }

/* ---------- Chapters and facts ---------- */

.ff-chapter { padding-top: 44px; scroll-margin-top: 12px; }
.ff-chapter-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; align-items: baseline; margin-bottom: 20px; }
.ff-chapter-head .ff-numeral { font-size: 2.6rem; line-height: 1; }
.ff h2 { font-size: clamp(1.7rem, 3.4vw, 2.2rem); line-height: 1.1; }
.ff-chapter-head p { grid-column: 2; color: var(--muted); }

.ff-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}
@media (min-width: 620px) {
  .ff-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Three across, with each chapter's first fact as a wide lead: eight facts fill three rows. */
@media (min-width: 940px) {
  .ff-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ff-fact:first-child { grid-column: span 2; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .ff-fact:first-child .ff-fig { display: flex; align-items: center; border-bottom: 0; border-right: 1px solid var(--ff-rule); padding: 20px; }
  .ff-fact:first-child .ff-body { align-self: center; padding: 22px 24px; }
  .ff-fact:first-child h3 { font-size: 1.75rem; }
  .ff-fact:first-child .ff-body p { font-size: 1rem; }
}
.ff-fact {
  display: flex;
  flex-direction: column;
  background: var(--ff-card);
  border: 1px solid var(--ff-rule);
  border-radius: 14px;
  scroll-margin-top: 24px;
  --ff-paper: var(--ff-card);
}
.ff-fig { margin: 0; padding: 16px 16px 8px; border-bottom: 1px solid var(--ff-rule); }
.ff-body { padding: 12px 18px 18px; }
.ff-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ff-no { color: var(--ff-acc); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.ff h3 { margin-top: 4px; font-size: 1.45rem; line-height: 1.15; }
.ff-body p { margin-top: 8px; font-size: 0.95rem; line-height: 1.55; }
.ff-fact.is-picked { animation: ff-pick 1.8s ease-out; }
@keyframes ff-pick {
  0%, 30% { box-shadow: 0 0 0 2px var(--ff-acc); }
  100% { box-shadow: 0 0 0 2px transparent; }
}

/* (i): the sources behind a fact, in a popover. Without script the browser
   centers it; the facts island anchors it under the button. */
.ff-info {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ff-rule);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: var(--ff-serif);
  font-size: 1rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}
.ff-info:hover, .ff-info[aria-expanded="true"] { color: var(--text); border-color: var(--ff-acc); }
.ff-info:focus-visible, .ff-btn:focus-visible, .ff a:focus-visible { outline: 2px solid var(--ff-acc); outline-offset: 2px; }
.ff-pop {
  width: min(320px, calc(100vw - 24px));
  padding: 14px 16px;
  border: 1px solid var(--ff-rule);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.18);
  font-size: 0.85rem;
  line-height: 1.45;
}
.ff-pop.is-anchored { position: fixed; inset: auto; margin: 0; }
.ff-pop::backdrop { background: transparent; }
.ff-pop-h { color: var(--ff-acc); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.ff-pop ol { margin: 8px 0 0; padding-left: 1.6em; }
.ff-pop li + li { margin-top: 6px; }
.ff-pop li::marker { color: var(--muted); }
.ff-pop a { color: var(--text); }
.ff-pop span { display: block; color: var(--muted); }
.ff-pop .ff-all { display: inline-block; margin-top: 10px; color: var(--muted); font-size: 0.8rem; }

/* ---------- Next page, references ---------- */

.ff-next {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 20px;
  align-items: center;
  margin-top: 56px;
  padding: 20px 24px;
  border: 1px solid var(--ff-rule);
  border-radius: 14px;
  background: var(--ff-card);
  color: var(--text);
  text-decoration: none;
  --ff-paper: var(--ff-card);
}
.ff-next:hover { border-color: var(--ff-acc); }
.ff-next .ff-no { display: block; }
.ff-next-title { display: block; margin-top: 2px; font-family: var(--ff-serif); font-size: 1.7rem; line-height: 1.1; }
.ff-next-text { display: block; margin-top: 6px; color: var(--muted); }

.ff-refs { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--ff-rule); scroll-margin-top: 12px; }
.ff-refs h2 { font-size: 1.6rem; }
/* Closed until asked for (the shared .refs row in site.css), in the page's accent. */
.ff-refs > summary::after { color: var(--ff-acc); }
.ff-refs > summary:focus-visible { outline-color: var(--ff-acc); }
.ff-refs > p { margin-top: 10px; color: var(--muted); font-size: 0.9rem; }
.ff-ref-list { margin: 18px 0 0; padding-left: 2em; columns: 2 300px; column-gap: 40px; font-size: 0.82rem; line-height: 1.45; }
.ff-ref-list li { break-inside: avoid; margin-bottom: 8px; color: var(--muted); }
.ff-ref-list li::marker { color: var(--ff-acc); }
.ff-ref-list a { color: var(--text); }
.ff-ref-list li:target { color: var(--text); }

@media (max-width: 560px) {
  .ff-switch .ff-kids { margin-left: 0; flex-basis: 100%; }
  .ff-next { grid-template-columns: 96px 1fr; padding: 16px; }
  .ff-next-title { font-size: 1.4rem; }
  .ff-chapter-head .ff-numeral { font-size: 2.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .p-spin, .ff-fact.is-picked { animation: none; }
}
