/* Birthday moon (/birthday-moon, ADR 0045): a form, the poster and the
   moment's facts. The poster is an SVG with its own colors (presentation
   attributes), the same in both themes, since it is what gets printed. This
   is the light theme; birthday-moon-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");
}

.bm-page {
  --bm-serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --bm-acc: #8e6a2e;
  --bm-acc-soft: rgb(142 106 46 / 0.1);
  --bm-lit: #f3ecd9;
  --bm-dark: #2a3046;
  --bm-ring: #8b8f9c;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.bm-page h2 { font-family: var(--bm-serif); font-weight: 500; font-size: 1.65rem; line-height: 1.15; margin: 0; }

/* ---------- Hero and form ---------- */

.bm-hero { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 4px; }
.bm-switch { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.9rem; margin-bottom: 10px; }
.bm-switch a { color: var(--muted); text-decoration: none; }
.bm-switch a[aria-current="page"] { color: var(--text); text-decoration: underline; text-decoration-color: var(--bm-acc); text-underline-offset: 6px; }
.bm-kicker { margin: 0; color: var(--bm-acc); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.bm-hero h1 { font-family: var(--bm-serif); font-weight: 500; font-size: clamp(2.1rem, 5.4vw, 3.4rem); line-height: 1.04; letter-spacing: -0.01em; margin: 0; }
.bm-lede { margin: 0; max-width: 62ch; font-size: 1.08rem; color: var(--text); }
.bm-now { color: var(--muted); font-size: 0.98rem; }
.bm-warn { margin: 0; color: var(--warn-text); font-weight: 600; }

.bm-form {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(120px, 0.7fr) minmax(220px, 1.6fr) auto;
  gap: 14px 16px;
  align-items: start;
  margin-top: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.bm-field label, .bm-name label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bm-form input, .bm-name input {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
.bm-form input:focus-visible, .bm-name input:focus-visible { outline: 2px solid var(--accent-moon); outline-offset: 1px; }
.bm-hint { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.bm-go {
  align-self: end;
  margin-bottom: 22px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.bm-go:hover { background: var(--bm-acc); color: #fff; }
.bm-go:focus-visible { outline: 2px solid var(--accent-moon); outline-offset: 3px; }
/* Place suggestions (the placesearch island), under the place field. */
.bm-field-place .place-results {
  position: absolute;
  top: 74px;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow: auto;
}
.bm-field-place .place-results a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.bm-field-place .place-results a:hover, .bm-field-place .place-results a.is-active { background: var(--accent-moon-soft); }
.bm-field-place .place-where { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 799px) {
  .bm-form { grid-template-columns: 1fr 1fr; }
  .bm-field-place { grid-column: 1 / -1; }
  .bm-go { grid-column: 1 / -1; margin-bottom: 0; }
}
@media (max-width: 420px) {
  .bm-form { grid-template-columns: 1fr; padding: 16px; }
}

/* ---------- The poster and its controls ---------- */

.bm-studio {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 1fr);
  gap: 28px;
  align-items: start;
  scroll-margin-top: 90px;
}
.bm-frame {
  margin: 0;
  padding: clamp(14px, 3vw, 34px);
  background: linear-gradient(160deg, #e7e2d6, #d9d3c5);
  border-radius: var(--radius);
}
.bm-poster {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.12), 0 18px 40px rgb(0 0 0 / 0.22);
}
.bm-controls { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 96px; }
.bm-choice { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.bm-choice-l { flex-basis: 100%; margin: 0 0 2px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bm-choice a {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.bm-choice a span { font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.bm-choice a:hover { border-color: var(--bm-acc); }
.bm-choice a[aria-current="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.bm-name { display: flex; flex-direction: column; gap: 6px; }
/* Shown by the birthday island; without JavaScript the browser's Print does the job. */
.bm-name[hidden], .bm-actions[hidden] { display: none; }
.bm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bm-btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.bm-btn-quiet { background: transparent; color: var(--text); border-color: var(--line); }
.bm-btn:hover { border-color: var(--bm-acc); }
.bm-btn:focus-visible { outline: 2px solid var(--accent-moon); outline-offset: 2px; }
.bm-btn[disabled] { opacity: 0.55; cursor: progress; }
.bm-status { flex-basis: 100%; margin: 0; min-height: 1.2em; font-size: 0.85rem; color: var(--muted); }

@media (max-width: 799px) {
  .bm-studio { grid-template-columns: 1fr; }
  .bm-controls { position: static; }
}

/* ---------- Cards ---------- */

.bm-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bm-card h2 { display: flex; align-items: center; gap: 8px; }
.bm-note { margin: 0; color: var(--muted); max-width: 70ch; }
.bm-muted { color: var(--muted); font-size: 0.9rem; }
.bm-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 0.9rem; }

.bm-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 28px; margin: 0; }
.bm-facts > div { border-top: 1px solid var(--line); padding-top: 10px; min-width: 0; }
.bm-facts dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bm-acc); }
.bm-facts dd { margin: 4px 0 0; font-size: 1.02rem; }
.bm-more { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0 0; font-size: 0.95rem; }

/* The lunar month strip. */
.bm-month-scroll { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.bm-month { display: block; width: 100%; min-width: 560px; max-width: 760px; height: auto; }
.bm-m-axis { stroke: var(--line); stroke-width: 2; }
.bm-g-dark { fill: var(--bm-dark); }
.bm-g-lit { fill: var(--bm-lit); }
.bm-g-ring { fill: none; stroke: var(--bm-ring); stroke-width: 0.8; }
.bm-m-label { fill: var(--text); font-size: 14px; font-weight: 600; text-anchor: middle; }
.bm-m-date { fill: var(--muted); font-size: 13px; text-anchor: middle; }
.bm-m-birth { stroke: var(--bm-acc); stroke-width: 2; }
.bm-m-birthf { fill: var(--bm-acc); }
.bm-m-you { fill: var(--bm-acc); font-size: 13px; font-weight: 700; text-anchor: middle; letter-spacing: 0.06em; text-transform: uppercase; }

/* Every birthday Moon. */
.bm-years {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 640px;
}
.bm-years li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0 3px;
  border-radius: 8px;
}
.bm-years svg { width: 26px; height: 26px; display: block; }
.bm-years .bm-g-ring { stroke-width: 0.6; }
.bm-age { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bm-years li.is-same { background: var(--bm-acc-soft); box-shadow: inset 0 0 0 1px var(--bm-acc); }
.bm-years li.is-same .bm-age { color: var(--bm-acc); font-weight: 700; }
.bm-years li.is-next { box-shadow: inset 0 0 0 2px var(--accent-moon); }
.bm-legend { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 0.85rem; }
.bm-key { display: inline-block; width: 16px; height: 16px; border-radius: 4px; }
.bm-key.is-same { background: var(--bm-acc-soft); box-shadow: inset 0 0 0 1px var(--bm-acc); }
.bm-key.is-next { box-shadow: inset 0 0 0 2px var(--accent-moon); margin-left: 8px; }
@media (max-width: 480px) {
  .bm-years { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Famous nights under the same Moon. */
.bm-nights { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.bm-nights a {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 12px;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
}
.bm-nights a:hover { border-color: var(--bm-acc); }
.bm-nights svg { grid-row: 1 / span 3; width: 34px; height: 34px; }
.bm-night-year { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; color: var(--bm-acc); }
.bm-night-title { font-family: var(--bm-serif); font-size: 1.25rem; line-height: 1.15; }
.bm-night-moon { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
/* The Moonlit history glyphs' classes (tools/moonlit-history/sky_art.py). */
.bm-nights .p-lit { fill: var(--bm-lit); stroke: none; }
.bm-nights .p-night { fill: var(--bm-dark); stroke: none; }
.bm-nights .p-fine { fill: none; stroke: var(--bm-ring); stroke-width: 0.6; }
.bm-nights .p-paper { fill: var(--surface); stroke: none; }
.bm-nights .p-acc { fill: none; stroke: var(--bm-acc); stroke-width: 0.9; }
.bm-nights .p-hatch-acc { fill: var(--bm-acc-soft); }

.bm-eclipses { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }
.bm-eclipses span { display: block; color: var(--muted); font-size: 0.92rem; }
.bm-method p { margin: 0; max-width: 78ch; }

/* ---------- Sources: (i) popovers and the list ---------- */

.bm-info {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font: italic 600 0.75rem/1 Georgia, serif;
  vertical-align: 2px;
  cursor: pointer;
}
.bm-info:hover, .bm-info[aria-expanded="true"] { color: var(--text); border-color: var(--bm-acc); }
.bm-info:focus-visible { outline: 2px solid var(--accent-moon); outline-offset: 2px; }
.bm-pop {
  width: min(360px, calc(100vw - 32px));
  margin: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.18);
  font-size: 0.86rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.45;
}
.bm-pop.is-anchored { position: fixed; inset: auto; margin: 0; }
.bm-pop::backdrop { background: transparent; }
span.bm-pop .bm-pop-h { display: block; color: var(--bm-acc); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
span.bm-pop .bm-pop-note { display: block; margin-top: 6px; color: var(--muted); }
span.bm-pop .bm-pop-list { display: block; margin-top: 8px; }
span.bm-pop .bm-pop-item { display: grid; grid-template-columns: 1.6em 1fr; }
span.bm-pop .bm-pop-item + .bm-pop-item { margin-top: 6px; }
span.bm-pop .bm-pop-n { grid-row: 1 / span 2; color: var(--muted); }
span.bm-pop .bm-pop-item > span:last-child { grid-column: 2; color: var(--muted); }
span.bm-pop .bm-all { display: block; margin-top: 10px; font-size: 0.82rem; }
.bm-refs { padding: 4px 4px 0; }
.bm-ref-list { margin: 12px 0 0; padding-left: 1.6em; display: flex; flex-direction: column; gap: 6px; }
.bm-ref-list li > span { display: block; color: var(--muted); font-size: 0.9rem; }
.bm-ref-pub { color: var(--text); }
.bm-sources .note { color: var(--muted); font-size: 0.9rem; }

/* ---------- Printing: the poster alone, edge to edge ---------- */

@media print {
  @page { margin: 0; }
  html, body { background: #fff !important; }
  body > :not(main), .circumstances, .bm-page > :not(.bm-studio), .bm-controls, .bm-studio > h2 { display: none !important; }
  main.page { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .bm-page, .bm-studio { display: block; gap: 0; }
  .bm-frame { padding: 0; background: none; border-radius: 0; }
  .bm-poster {
    width: 100vw;
    height: 100vh;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    break-inside: avoid;
  }
}
