/* Moonlit history (/moonlit-history): famous nights and the Moon above them.
   Builds on fun-facts.css (hero, chapters, popovers, references, drawing
   classes) and its dark theme; this file adds the night cards, the date-order
   index and the method notes. Colors come from the Fun Facts variables, so
   light and dark both follow Settings. */

/* ---------- Index: every night in date order ---------- */

.mh-almanac { padding-top: 36px; scroll-margin-top: 12px; }
.mh-almanac h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); }
.mh-index {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 2px 18px;
}
.mh-index a {
  display: grid;
  grid-template-columns: 20px 4.6rem 1fr;
  gap: 10px;
  align-items: start;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.25;
}
.mh-index a:hover { background: var(--ff-wash); }
.mh-index svg { width: 20px; height: 20px; margin-top: -1px; }
.mh-year { padding-top: 2px; color: var(--ff-acc); font-variant-numeric: tabular-nums; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; }

/* ---------- Night cards ---------- */

.mh-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}
@media (min-width: 760px) {
  .mh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.mh-night {
  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);
}
.mh-night.is-picked { animation: ff-pick 1.8s ease-out; }
.mh-fig { margin: 0; padding: 14px 16px 6px; border-bottom: 1px solid var(--ff-rule); }
.mh-body { padding: 12px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.mh-body > p { margin-top: 8px; font-size: 0.95rem; line-height: 1.55; }
.mh-body > .mh-when { color: var(--muted); font-size: 0.85rem; }
.mh-cal {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border: 1px solid var(--ff-rule);
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  vertical-align: 1px;
}

/* The Moon that night: computed figures, then what it meant. */
.mh-moon {
  margin-top: auto;
  padding-top: 14px;
}
.mh-moon-h {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--ff-rule);
  color: var(--ff-acc);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.mh-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 10px 0 0;
  font-size: 0.85rem;
  line-height: 1.4;
}
.mh-facts dt { color: var(--muted); font-size: 0.78rem; }
.mh-facts dt span { display: block; font-size: 0.7rem; opacity: 0.85; }
.mh-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.mh-apsis { display: block; color: var(--muted); font-size: 0.78rem; }
.mh-moon-text {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 2px solid var(--ff-acc);
  background: var(--ff-wash);
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

/* A chapter with an odd count opens on a wide card, so the grid comes out even:
   the sky on the left, the story on the right. */
@media (min-width: 760px) {
  .mh-night.mh-lead { grid-column: span 2; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .mh-lead .mh-fig { display: flex; align-items: center; padding: 20px; border-bottom: 0; border-right: 1px solid var(--ff-rule); }
  .mh-lead .mh-fig svg { width: 100%; }
  .mh-lead .mh-body { padding: 18px 22px 20px; }
  .mh-lead h3 { font-size: 1.75rem; }
}

@media (max-width: 420px) {
  .mh-facts { grid-template-columns: 1fr; gap: 0; }
  .mh-facts dd { margin-bottom: 6px; }
}

/* ---------- How it was worked out ---------- */

.mh-method {
  margin-top: 48px;
  padding: 16px 20px;
  border: 1px solid var(--ff-rule);
  border-radius: 14px;
  background: var(--ff-card);
}
.mh-method summary { cursor: pointer; font-family: var(--ff-serif); font-size: 1.35rem; }
.mh-method summary:focus-visible { outline: 2px solid var(--ff-acc); outline-offset: 2px; }
.mh-method p { margin-top: 10px; color: var(--muted); font-size: 0.9rem; line-height: 1.6; max-width: 52rem; }
.mh-method a { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .mh-night.is-picked { animation: none; }
}

/* Small phase discs (the index and the hero's ring) in two flat tones;
   moonlit-dark.css swaps them so the lit side stays the bright one. */
.mh .p-lit { fill: var(--ff-wash); stroke: none; }
.mh .p-night { fill: var(--ff-ink); fill-opacity: 0.55; stroke: none; }
