/* Fact pages (/sun-facts, /moon-facts): a hero picture, then forty
   illustrated fact cards in five themed sections. Loaded only on those
   pages. The dark theme is facts-dark.css, which follows the OS
   or the theme chosen in Settings, like the rest of the site. Fonts:
   Fredoka and Nunito, SIL Open Font License (wwwroot/fonts). */

@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/fredoka-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/nunito-latin-400.woff2") format("woff2");
}

.facts {
  --f-heading: Fredoka, Nunito, system-ui, sans-serif;
  --f-card: var(--surface);
  --f-line: var(--line);
  --f-text2: #3a4163;
  --f-ink: #1b2350;            /* labels and outlines in the drawings */
  --f-hero-ink: #141a3d;
  --f-pill: rgb(255 255 255 / 0.6);
  --f-shadow: rgb(20 26 61 / 0.2);
  font-family: Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
}

.facts-sun {
  --f-sky1: #79c7ff; --f-sky2: #bfe6ff; --f-sky3: #fff1c4;
  --f-btn: #ffc93c; --f-btn-ink: #141a3d; --f-btn-shadow: #e09a00; --f-focus: #2563eb;
  --f-a1: #ffe39a; --f-b1: #fff6d6;
  --f-a2: #ffcfae; --f-b2: #ffeadb;
  --f-a3: #bfe3ff; --f-b3: #e8f5ff;
  --f-a4: #e2d6ff; --f-b4: #f4efff;
  --f-a5: #ffd3e1; --f-b5: #fff0f5;
  --f-next1: #0b1130; --f-next2: #2a2f72; --f-next-ink: #f6efe2;
}

.facts-moon {
  --f-sky1: #8e9bff; --f-sky2: #c7c6ff; --f-sky3: #ffdbe8;
  --f-btn: #4f5ce0; --f-btn-ink: #ffffff; --f-btn-shadow: #3540b0; --f-focus: #4f5ce0;
  --f-a1: #d9deff; --f-b1: #f0f2ff;
  --f-a2: #e6ddf7; --f-b2: #f5f0fc;
  --f-a3: #d3e6ff; --f-b3: #edf5ff;
  --f-a4: #ffdce8; --f-b4: #fff0f5;
  --f-a5: #ffecc4; --f-b5: #fff7e2;
  --f-next1: #ffc94d; --f-next2: #ff8a4c; --f-next-ink: #2a1606;
}

.facts-t1 { --f-ta: var(--f-a1); --f-tb: var(--f-b1); }
.facts-t2 { --f-ta: var(--f-a2); --f-tb: var(--f-b2); }
.facts-t3 { --f-ta: var(--f-a3); --f-tb: var(--f-b3); }
.facts-t4 { --f-ta: var(--f-a4); --f-tb: var(--f-b4); }
.facts-t5 { --f-ta: var(--f-a5); --f-tb: var(--f-b5); }

.facts :focus-visible { outline: 3px solid var(--f-focus); outline-offset: 3px; border-radius: 12px; }
.facts-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- Hero ---- */
.facts-hero {
  position: relative;
  overflow: hidden;
  margin-top: 4px;
  padding: clamp(16px, 3vw, 30px) 16px 0;
  border-radius: 28px;
  text-align: center;
  color: var(--f-hero-ink);
  background: linear-gradient(180deg, var(--f-sky1), var(--f-sky2) 55%, var(--f-sky3));
}
.facts-tabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  margin: 0 auto 18px;
  padding: 4px;
  border-radius: 999px;
  background: var(--f-pill);
}
.facts-tabs a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  font: 600 1rem/1 var(--f-heading);
}
.facts-tabs a[aria-current="page"] { background: var(--f-card); color: var(--text); box-shadow: 0 2px 8px -3px var(--f-shadow); }
.facts-kicker {
  width: fit-content;
  margin: 0 auto 12px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--f-pill);
  font: 600 1rem/1.2 var(--f-heading);
}
.facts-hero h1 { font: 600 clamp(2.2rem, 6vw, 3.8rem)/1.05 var(--f-heading); text-wrap: balance; }
.facts-lede { max-width: 33em; margin: 14px auto 0; font-size: 1.06rem; }
.facts-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 22px; }
.facts-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font: 600 1.06rem/1 var(--f-heading);
  background: var(--f-btn);
  color: var(--f-btn-ink);
  box-shadow: 0 4px 0 var(--f-btn-shadow);
  transition: transform 0.12s;
}
.facts-btn[hidden] { display: none; }
.facts-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--f-btn-shadow); }
.facts-btn-plain { background: var(--f-card); color: var(--text); box-shadow: 0 4px 0 var(--f-line); }
.facts-heroart {
  display: block;
  width: calc(100% + 32px);
  height: clamp(220px, 33vw, 380px);
  margin: clamp(4px, 2vw, 18px) -16px 0;
}
.facts-heroart .f-caption { fill: var(--f-hero-ink); font-family: var(--f-heading); font-weight: 600; }

/* ---- Section chips ---- */
.facts-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 6px;
  padding: 12px 0;
  scrollbar-width: none;
}
.facts-chips::-webkit-scrollbar { display: none; }
/* Centered when the chips fit, scrollable from the first one when they don't. */
.facts-chips a:first-child { margin-left: auto; }
.facts-chips a:last-child { margin-right: auto; }
.facts-chips a {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px 0 7px;
  border: 1px solid var(--f-line);
  border-radius: 999px;
  background: var(--f-card);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font: 600 0.95rem/1 var(--f-heading);
}
.facts-chip-n {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  background: linear-gradient(160deg, var(--f-ta), var(--f-tb));
}
@media (min-width: 900px) {
  .facts-chips {
    position: sticky;
    top: 0;
    z-index: 5;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
  }
}

/* ---- Sections and cards ---- */
.facts-section { padding-top: clamp(22px, 4vw, 44px); scroll-margin-top: 72px; }
.facts-section-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.facts-badge { flex: none; width: 68px; height: 68px; border-radius: 20px; background: linear-gradient(160deg, var(--f-ta), var(--f-tb)); }
.facts-badge svg { display: block; width: 100%; height: 100%; }
.facts-section h2 { font: 600 clamp(1.6rem, 3.4vw, 2.1rem)/1.1 var(--f-heading); text-wrap: balance; }
.facts-section-head p { margin-top: 4px; color: var(--f-text2); }
.facts-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 228px), 1fr));
  gap: 18px;
}
.fact {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: var(--f-card);
  box-shadow: 0 0 0 1px var(--f-line), 0 12px 26px -18px var(--f-shadow);
  scroll-margin-top: 80px;
  transition: transform 0.2s;
}
.fact:hover { transform: translateY(-3px); }
.fact-art { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(160deg, var(--f-ta), var(--f-tb)); }
.fact-art svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fact-num {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--f-card);
  color: var(--text);
  font: 600 1rem/1 var(--f-heading);
  box-shadow: 0 2px 6px -2px var(--f-shadow);
}
.fact-text { padding: 14px 18px 20px; }
.fact h3 { margin-bottom: 6px; font: 600 1.2rem/1.15 var(--f-heading); text-wrap: balance; }
.fact p { color: var(--f-text2); }
/* "Surprise me" lands here. */
.fact.is-picked { animation: facts-pop 1.3s ease-out; box-shadow: 0 0 0 4px var(--f-focus), 0 18px 30px -18px var(--f-shadow); }
@keyframes facts-pop {
  0% { transform: scale(1); }
  12% { transform: scale(1.04) rotate(-1.5deg); }
  26% { transform: scale(1.04) rotate(1.5deg); }
  40% { transform: scale(1.02) rotate(-0.6deg); }
  60%, 100% { transform: none; }
}

/* ---- Drawings ---- */
.facts .f-lbl { fill: var(--f-ink); font-family: var(--f-heading); font-weight: 600; }
.facts .f-dk { fill: #1b2350; font-family: var(--f-heading); font-weight: 600; }
.facts .f-lt { fill: #fff7e6; font-family: var(--f-heading); font-weight: 600; }
.facts .f-ink { fill: var(--f-ink); }
.facts .f-ink-line { stroke: var(--f-ink); fill: none; }
.facts .f-dark-only { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .facts .f-spin { animation: facts-spin 90s linear infinite; transform-box: view-box; transform-origin: 600px 560px; }
  .facts .f-tw { animation: facts-twinkle 3.2s ease-in-out infinite; }
  .facts .f-d1 { animation-delay: 0.6s; }
  .facts .f-d2 { animation-delay: 1.3s; }
  .facts .f-d3 { animation-delay: 2s; }
  .facts .f-d4 { animation-delay: 2.7s; }
}
@keyframes facts-spin { to { transform: rotate(360deg); } }
@keyframes facts-twinkle { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .fact, .facts-btn { transition: none; }
  .fact.is-picked { animation: none; }
}

/* ---- The other page, sources ---- */
.facts-next {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  margin-top: clamp(30px, 5vw, 56px);
  padding: clamp(18px, 3vw, 34px);
  border-radius: 30px;
  background: linear-gradient(135deg, var(--f-next1), var(--f-next2));
  color: var(--f-next-ink);
  text-decoration: none;
}
.facts-next svg { display: block; width: 100%; height: auto; max-height: 240px; }
.facts-next-text { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.facts-next-title { font: 600 clamp(1.7rem, 3.6vw, 2.4rem)/1.1 var(--f-heading); }
.facts-next-lede { margin-bottom: 8px; font-size: 1.06rem; opacity: 0.9; }
.facts-sources { margin-top: 28px; color: var(--muted); font-size: 0.9rem; }
.facts-sources h2 { margin-bottom: 6px; color: var(--text); font: 600 1rem/1.2 var(--f-heading); }
.facts-sources ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.facts-sources a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 600px) {
  .facts-hero { border-radius: 22px; }
  .facts-heroart .f-caption { font-size: 30px; }
  .facts-badge { width: 56px; height: 56px; border-radius: 16px; }
  .facts-next { grid-template-columns: minmax(0, 1fr); }
}
