@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif-latin-400-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

/* Palette: a clear night sky rather than black, the Moon's own grey for text, and two
   lights with meaning: sunlight (gold) for anything lit by the Sun, earthshine (blue)
   for the Earth. Nothing else gets color. */
:root {
  --sky: #0e1525;
  --sky-deep: #0a0f1c;
  --sky-raised: #16203a;
  --rule: #26324f;
  --regolith: #e4ddd0;
  --dust: #98a1b5;
  --sun: #f2c46b;
  --earth: #82b4ea;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(120% 70% at 30% 0%, #17223d 0%, transparent 60%),
    var(--sky);
  background-attachment: fixed;
  color: var(--regolith);
  font: 400 1rem/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; border-radius: 4px; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--earth); }

/* ------------------------------------------------------------ header */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 1.5rem;
  padding: max(env(safe-area-inset-top), .9rem) var(--gutter) .9rem;
}
.wordmark {
  margin: 0;
  font: italic 400 2rem/1 var(--serif);
  letter-spacing: .01em;
}
.status { flex-basis: 100%; margin: 0; color: var(--sun); font-size: .875rem; }
.bar-controls { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; }
.field { display: inline-flex; align-items: center; gap: .5rem; }
.field-label { color: var(--dust); font-size: .875rem; }
select, input[type="datetime-local"] {
  background: var(--sky-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: .45rem .6rem;
  font-size: 1rem; /* 16px keeps iOS Safari from zooming */
  min-height: 2.5rem;
}
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; background: var(--sky-deep); }
.seg button {
  border: 0; background: transparent; border-radius: 999px;
  padding: .4rem .85rem; font-size: .875rem; color: var(--dust); cursor: pointer; min-height: 2.25rem;
}
.seg button[aria-checked="true"] { background: var(--sky-raised); color: var(--regolith); box-shadow: inset 0 0 0 1px var(--rule); }

/* ------------------------------------------------------------ stage */
main { padding: 0 var(--gutter) 3rem; max-width: 84rem; margin: 0 auto; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 1fr);
  gap: clamp(1rem, 3vw, 3rem);
  align-items: center;
  min-height: min(78vh, 52rem);
}
.moon-wrap { position: relative; aspect-ratio: 1; width: 100%; max-width: 46rem; justify-self: center; }
#moon { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.labels span {
  position: absolute; transform: translate(-50%, -50%);
  font-size: .75rem; line-height: 1.1; white-space: nowrap;
  color: #fff; text-shadow: 0 0 3px #000, 0 0 6px #000;
}
.labels span.crater::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--sun); margin-right: 4px; vertical-align: middle; }
.labels span.site { color: var(--sun); }
.labels span.dim { opacity: .55; }
.moon-tools { position: absolute; left: 0; bottom: 0; display: flex; flex-direction: column; align-items: flex-start; }
.check { display: inline-flex; align-items: center; gap: .4rem; color: var(--dust); font-size: .875rem; cursor: pointer; min-height: 2.25rem; }
.check input { accent-color: var(--sun); width: 1.05rem; height: 1.05rem; }
.horizon-note {
  position: absolute; right: 0; bottom: 0; margin: 0;
  color: var(--dust); font-size: .875rem; text-align: right; max-width: 16rem;
}
.gl-error { position: absolute; inset: 35% 10% auto; text-align: center; color: var(--dust); }

.when { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.now {
  border: 1px solid var(--rule); background: transparent; border-radius: 999px;
  padding: .45rem 1rem; min-height: 2.5rem; cursor: pointer; color: var(--dust);
}
.now.live { color: var(--sky); background: var(--sun); border-color: var(--sun); }

.phase-name {
  margin: 1.25rem 0 .25rem;
  font: italic 400 clamp(3rem, 6.4vw, 5.5rem)/0.95 var(--serif);
  letter-spacing: -.01em;
  text-wrap: balance;
}
.phase-line { margin: 0 0 1.75rem; color: var(--dust); font-size: 1.0625rem; }

.facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.5rem; margin: 0 0 2rem;
}
.facts div { border-top: 1px solid var(--rule); padding-top: .5rem; }
.facts dt { color: var(--dust); font-size: .875rem; }
.facts dd { margin: .1rem 0 0; font-size: 1.125rem; }
.facts dd small { display: block; color: var(--dust); font-size: .8125rem; }

.minor { font: 400 .875rem/1.4 var(--sans); color: var(--dust); margin: 0 0 .5rem; }
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { border-top: 1px solid var(--rule); }
.upcoming li:last-child { border-bottom: 1px solid var(--rule); }
.upcoming .glyph { width: 1.1rem; height: 1.1rem; align-self: center; }
.upcoming .kind { font-family: var(--serif); font-style: italic; font-size: 1.25rem; }
.upcoming time { color: var(--dust); font-size: .9375rem; text-align: right; }
.upcoming button {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 1.75rem 1fr auto; align-items: baseline; gap: .6rem;
  padding: .4rem 0;
}
.upcoming button:hover .kind { color: var(--sun); }
.upcoming button:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ timeline */
.timeline { margin-top: 1.5rem; }
.strip {
  display: block; width: 100%; height: 112px;
  cursor: grab; touch-action: pan-y;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.strip.dragging { cursor: grabbing; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .9rem; justify-content: center; }
.t-btn {
  border: 1px solid var(--rule); background: var(--sky-deep); border-radius: 999px;
  min-width: 2.75rem; min-height: 2.75rem; padding: 0 .9rem; cursor: pointer;
}
.t-btn svg { display: block; margin: auto; }
.t-btn:hover { border-color: var(--dust); }
.t-btn.play { min-width: 3.5rem; background: var(--sky-raised); }
.t-btn.play[aria-pressed="true"] { background: var(--sun); color: var(--sky); border-color: var(--sun); }
.speed { margin-left: .75rem; }

/* ------------------------------------------------------------ why */
.why {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 30rem);
  gap: clamp(1rem, 4vw, 4rem); align-items: center;
  margin-top: 4.5rem;
}
.orbit-wrap { aspect-ratio: 1; width: 100%; max-width: 40rem; justify-self: center; }
.orbit { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.section-title { font: italic 400 clamp(2rem, 4vw, 2.75rem)/1.05 var(--serif); margin: 0 0 1rem; }
.why-text p { margin: 0 0 1rem; max-width: 34em; }
.why-now { color: var(--sun); }
.hint { color: var(--dust); }
.fine { color: var(--dust); font-size: .875rem; }

/* ------------------------------------------------------------ calendar */
.month { margin-top: 4.5rem; }
.month-head { display: flex; align-items: center; gap: 1rem; }
.month-head .section-title { margin: 0; min-width: 9ch; text-align: center; }
.calendar {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px; margin-top: 1rem;
}
.calendar .dow { color: var(--dust); font-size: .8125rem; text-align: center; padding: .3rem 0; }
.calendar button {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .45rem .2rem .55rem; min-height: 6.25rem;
  background: var(--sky-deep); border-radius: 6px; position: relative;
}
.calendar button:hover { background: var(--sky-raised); }
.calendar button:focus-visible { outline: 2px solid var(--sun); }
.calendar button.other { opacity: .38; }
.calendar button.today .num { color: var(--sky); background: var(--regolith); }
.calendar button.selected { box-shadow: inset 0 0 0 1px var(--sun); }
.calendar .num { font-size: .875rem; min-width: 1.6rem; text-align: center; border-radius: 999px; padding: 0 .3rem; align-self: flex-start; }
.calendar canvas { width: 44px; height: 44px; }
.calendar .event { font-size: .6875rem; line-height: 1.2; color: var(--sun); text-align: center; }

/* ------------------------------------------------------------ footer */
.credits { padding: 2rem var(--gutter) max(env(safe-area-inset-bottom), 2rem); max-width: 84rem; margin: 0 auto; color: var(--dust); font-size: .875rem; }
.credits summary { cursor: pointer; }
.credits p { max-width: 44em; }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; min-height: 0; }
  .moon-wrap { max-width: 34rem; }
  .phase-name { margin-top: .5rem; }
  .why { grid-template-columns: 1fr; margin-top: 3rem; }
  /* the diagram takes every touch for dragging, so leave margins to scroll past it */
  .orbit-wrap { max-width: min(82vw, 30rem); }
  .month { margin-top: 3rem; }
  .calendar button { min-height: 4.75rem; padding: .3rem .1rem .4rem; }
  .calendar canvas { width: 34px; height: 34px; }
  .calendar .event { font-size: .625rem; }
  .speed { margin-left: 0; }
}
@media (max-width: 480px) {
  .wordmark { font-size: 1.75rem; }
  .status { flex-basis: 100%; margin: 0; color: var(--sun); font-size: .875rem; }
.bar-controls { width: 100%; justify-content: space-between; }
  .seg button { padding: .4rem .6rem; }
  .facts { gap: .75rem 1rem; }
  .calendar .event .t { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
