/* ==========================================================================
   Sky Almanac. Dark theme locked for the whole page.
   Deliberate, not an oversight: the page is used at night, and amber on
   near-black preserves dark adaptation far better than a light theme. The
   year sheet does have white print styles.

   Radius system (one rule, applied everywhere):
     cards and panels ........... 16px
     controls and cells ......... 10px
     chips and indicators ....... 999px

   XD.
   ========================================================================== */

:root {
  --bg:          #0a0c11;
  --bg-raised:   #111520;
  --surface:     #161b27;
  --surface-hi:  #1d2331;
  --line:        rgb(255 255 255 / .09);
  --line-strong: rgb(255 255 255 / .16);
  --text:        #e8eaf0;
  --text-dim:    #99a1b3;
  --text-faint:  #7b8397;
  --row-hover:   rgb(255 255 255 / .022);

  /* A single accent colour for the whole page. */
  --accent:      #f2a83e;
  --accent-soft: rgb(242 168 62 / .13);
  --accent-line: rgb(242 168 62 / .34);
  --accent-text: #ffc775;

  --r-card: 16px;
  --r-ctl:  10px;
  --r-pill: 999px;

  --shadow: 0 18px 50px rgb(4 6 12 / .55);
  --ease:   cubic-bezier(.16, 1, .3, 1);

  --page:   1240px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --row-pad: .7rem;

  --font: 'Archivo', ui-sans-serif, system-ui, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.022em; line-height: 1.12; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.icon { width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: -.125em; }

.shell { width: 100%; max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }

/* --- Star field -----------------------------------------------------------
   Fixed canvas behind everything, no pointer events. Repainted on resize and, gently, while
   scrolling (parallax, see app.js).  */
#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .85;
}
body::after {
  /* Horizon gradient: adds depth and keeps the star field from competing with the
     text at the top of the page. */
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 78% -10%, rgb(242 168 62 / .09), transparent 62%),
    radial-gradient(100% 70% at 8% 4%, rgb(76 104 170 / .12), transparent 60%),
    linear-gradient(180deg, transparent 55%, rgb(10 12 17 / .85) 100%);
}
.page { position: relative; z-index: 1; }

/* --- Top bar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 68px;
  display: flex;
  align-items: center;
  background: rgb(10 12 17 / .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.topbar .shell { display: flex; align-items: center; gap: 1.5rem; }

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 32% 30%, #ffd79a, var(--accent) 42%, #8a5410 100%);
  box-shadow: 0 0 0 1px rgb(242 168 62 / .3), 0 0 18px rgb(242 168 62 / .35);
}
.brand-mark::after { content: ''; }

.topnav { display: flex; gap: .35rem; margin-left: auto; }
.topnav a {
  padding: .45rem .7rem;
  border-radius: var(--r-ctl);
  color: var(--text-dim);
  text-decoration: none;
  font-size: .875rem;
  white-space: nowrap;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.topnav a:hover { color: var(--text); background: var(--surface); }

.where {
  display: flex; align-items: center; gap: .4rem;
  padding: .35rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: .8rem;
  color: var(--text-dim);
  white-space: nowrap;
}
/* On narrow screens the brand text and the location chip go before the navigation:
   without it the page can no longer be navigated. */
@media (max-width: 900px) {
  .where { display: none; }
  .topbar .shell { gap: .75rem; }
  .topnav { margin-left: auto; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { padding: .4rem .5rem; font-size: .82rem; }
}
@media (max-width: 560px) {
  .brand { font-size: 0; gap: 0; }
  .brand-mark { font-size: 1rem; }
}

/* --- Sections ------------------------------------------------------------- */
section { padding-block: clamp(3.5rem, 8vw, 6rem); }
.sec-head { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.sec-head h2 { font-size: clamp(1.55rem, 3.2vw, 2.3rem); }
.sec-head p { color: var(--text-dim); font-size: .925rem; max-width: 46ch; margin-top: .5rem; }
.eyebrow {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .7rem;
}

.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* --- Now: clock + next event --------------------------------------------- */
.now { padding-top: clamp(2.5rem, 6vw, 4.5rem); }
.now-grid { display: grid; gap: clamp(1.5rem, 4vw, 3rem); grid-template-columns: 1.05fr .95fr; align-items: end; }
@media (max-width: 940px) { .now-grid { grid-template-columns: 1fr; align-items: stretch; } }

/* The clock column is centred under the dome, so the two read as one piece. */
.clock-block { text-align: center; }
.clock-meta { justify-content: center; }

.dome {
  position: relative;
  width: 100%;
  max-width: 26rem;
  height: clamp(7rem, 16vw, 9.5rem);
  margin: 0 auto .35rem;
}
.dome-arc { width: 100%; height: 100%; overflow: visible; }
.dome-path { fill: none; stroke: var(--line-strong); stroke-opacity: .7; stroke-width: 1; stroke-dasharray: 3 5; }
.dome-horizon { stroke: var(--line-strong); stroke-width: 1; }

.dome-body {
  position: absolute;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  translate: -50% -50%;
  line-height: 0;
  transition: top 1s linear, left 1s linear, opacity .4s var(--ease);
}
/* By day the Moon is there but sunlight nearly washes it out; at night it is the thing to look at. */
.dome-moon { opacity: .5; transition: top 1s linear, left 1s linear, opacity .6s var(--ease), filter .6s var(--ease); }
.dome[data-night] .dome-moon { opacity: 1; filter: drop-shadow(0 0 9px rgb(197 214 245 / .45)); }
/* A body that has set travels along the horizon line, dimmed and without glow. */
.dome .dome-body[data-resting] { opacity: .4; filter: none; }
/* A set Sun shrinks to a dot: there is no Sun at night, only its times on hover. */
.dome-sun[data-resting] { box-shadow: none; background: var(--text-faint); width: 6px; height: 6px; }
/* Near an edge, a centred label would spill out of the drawing. */
.dome-body[data-edge-l] .dome-when { left: 0; translate: 0 0; }
.dome-body[data-edge-r] .dome-when { left: auto; right: 0; translate: 0 0; }
/* Hit area: the disc is 20 px and would be awkward to aim at. */
.dome-body::after { content: ''; position: absolute; inset: -12px; border-radius: 50%; }

/* Rise and set times only appear on hover (or on press and hold, without a mouse). */
.dome-when {
  position: absolute;
  left: 50%; bottom: calc(100% + 10px);
  translate: -50% 0;
  padding: .2rem .5rem;
  border-radius: var(--r-pill);
  background: rgb(10 12 17 / .9);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono); font-size: .72rem; line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
}
/* When two bodies are close, one label stacks above the other. */
.dome-when[data-stack] { bottom: calc(100% + 34px); }
.dome-body:hover .dome-when,
.dome-body[data-held] .dome-when { opacity: 1; }
.dome-body:hover, .dome-body[data-held] { z-index: 2; }
@media (prefers-reduced-motion: reduce) { .dome-when { transition: none; } }
/* A 3% Moon is almost invisible on the background: the ring shows where it is even when unlit. */
.dome-moon .moon-disc { box-shadow: 0 0 0 1px var(--line-strong); }

.dome-sun {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, #ffe9bd, var(--accent) 55%, #c47c17 100%);
  box-shadow: 0 0 14px rgb(242 168 62 / .55), 0 0 34px rgb(242 168 62 / .3);
}
.dome[data-night] .dome-sun { box-shadow: none; }

/* Planets of a conjunction: dots in their own colour, together as they look in the sky. */
.dome-dots { display: flex; gap: 5px; }
/* Next to the Moon the dot would land on its disc: it moves to one side, still reading as a pair. */
.dome-conj[data-moon] .dome-dots { translate: 22px 0; }
.dome[data-south] .dome-conj[data-moon] .dome-dots { translate: -22px 0; }
.dome-planet {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--planet); box-shadow: 0 0 6px var(--planet), 0 0 14px color-mix(in srgb, var(--planet) 45%, transparent);
}
.dome-planet[data-body="mercury"] { --planet: #c9c2b8; }
.dome-planet[data-body="venus"]   { --planet: #fff4d6; }
.dome-planet[data-body="mars"]    { --planet: #ff8a5c; }
.dome-planet[data-body="jupiter"] { --planet: #f3dfb8; }
.dome-planet[data-body="saturn"]  { --planet: #e8cf8a; }

@media (prefers-reduced-motion: reduce) { .dome-body { transition: none; } }
@media (max-width: 940px) { .dome { max-width: 22rem; } }

.clock-date { color: var(--text-dim); font-size: .95rem; }
.clock-time {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.4rem, 11vw, 6.5rem);
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: .95;
  margin-block: .35rem .5rem;
}
.clock-time .sec { color: var(--text-faint); font-size: .42em; letter-spacing: -.02em; }
.clock-meta { display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--text-faint); font-size: .82rem; }
.clock-meta b { color: var(--text-dim); font-weight: 500; }

/* --- Location picker ------------------------------------------------------ */
.loc { max-width: 38rem; margin-bottom: clamp(1.5rem, 4vw, 2.5rem); }
.loc-field label {
  display: block; font-size: .68rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: .4rem;
}
.loc-input {
  display: flex; align-items: center; gap: .55rem;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: rgb(0 0 0 / .25); padding: .35rem .35rem .35rem .7rem;
}
.loc-input { position: relative; }
.loc-input:focus-within { border-color: var(--accent-line); }

/* Search match list. */
.loc-sug {
  position: absolute;
  z-index: 40;
  left: -1px; right: -1px; top: calc(100% + .4rem);
  margin: 0; padding: .25rem;
  list-style: none;
  max-height: 15rem; overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  box-shadow: var(--shadow);
}
.loc-sug[hidden] { display: none; }
.loc-sug li {
  padding: .5rem .65rem;
  border-radius: 8px;
  font-size: .9rem;
  color: var(--text-dim);
  cursor: pointer;
}
.loc-sug li:hover, .loc-sug li[aria-selected] { background: var(--surface); color: var(--text); }
.loc-input .icon { color: var(--text-faint); flex: none; }
.loc-input input {
  flex: 1; min-width: 0; background: none; border: 0; color: var(--text);
  font: inherit; font-size: .92rem; padding: .3rem 0;
}
.loc-input input:focus-visible { outline: none; }
.loc-input .chip { flex: none; }
.loc-status { margin-top: .4rem; font-size: .8rem; color: var(--text-faint); min-height: 1.2em; }
.loc-status[data-state='error'] { color: var(--accent-text); }
.loc-hint { font-size: .75rem; color: var(--text-faint); opacity: .8; }

.next {
  background: linear-gradient(158deg, var(--surface-hi), var(--surface) 62%);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: clamp(1.25rem, 3vw, 1.9rem);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.next::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
}
.next-label { font-family: var(--mono); font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--text-faint); }
.next-title { display: flex; align-items: start; gap: .7rem; margin-block: .7rem .35rem; }
.next-title .icon { font-size: 1.5rem; color: var(--accent); margin-top: .1rem; }
.next-title h3 { font-size: clamp(1.2rem, 2.4vw, 1.6rem); }
.next-when { color: var(--text-dim); font-size: .9rem; }

.countdown { display: flex; gap: .5rem; margin-top: 1.2rem; }
.cd-cell { flex: 1; text-align: center; background: rgb(0 0 0 / .28); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: .55rem .25rem; }
.cd-cell b { display: block; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: clamp(1.15rem, 3vw, 1.55rem); font-weight: 500; letter-spacing: -.03em; }
.cd-cell span { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }

/* --- Must-see carousel ---------------------------------------------------- */
.rail-head { display: flex; align-items: center; gap: .5rem; }
.rail-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl);
  cursor: pointer; font-size: 1.1rem; color: var(--text-dim);
  transition: background .2s var(--ease), color .2s var(--ease), transform .12s var(--ease);
}
.rail-btn:hover:not(:disabled) { background: var(--surface-hi); color: var(--text); }
.rail-btn:active:not(:disabled) { transform: scale(.94); }
.rail-btn:disabled { opacity: .32; cursor: default; }

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(88vw, 380px);
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  /* overflow-x: auto computes overflow-y to auto, so this scrollport clips vertically and cut off the
     hover lift and the focus ring. .5rem clears both (3px lift + 3px offset + 2px ring); the negative
     margin keeps the spacing around the carousel unchanged. */
  margin-top: -.5rem;
  padding-block: .5rem;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
}
.rail::-webkit-scrollbar { display: none; }
@media (max-width: 560px) { .rail { --rail-fade: 1.75rem; } }
/* The carousel is wider than the content, so cards used to be cut hard against the edge. The ends fade,
   but only on the side with more to scroll: app.js sets --fade-l / --fade-r while scrolling, so there is
   no fade at the ends and the first and last cards show whole. */
.rail {
  --rail-fade: 4rem;
  --fade-l: 0px;
  --fade-r: 0px;
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l),
              #000 calc(100% - var(--fade-r)), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l),
              #000 calc(100% - var(--fade-r)), transparent 100%);
}

.big-card {
  scroll-snap-align: start;
  display: flex; flex-direction: column;
  min-height: 320px;
  padding: 1.4rem;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: linear-gradient(165deg, var(--surface-hi), var(--bg-raised) 70%);
  cursor: pointer;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: border-color .3s var(--ease), transform .3s var(--ease);
}
.big-card:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.big-card:active { transform: translateY(-1px) scale(.995); }
@media (prefers-reduced-motion: reduce) { .big-card:hover, .big-card:active { transform: none; } }

.big-card .glyph {
  font-size: 2.4rem; color: var(--accent);
  filter: drop-shadow(0 0 22px rgb(242 168 62 / .3));
}
.big-card .when { font-family: var(--mono); font-size: .78rem; letter-spacing: .07em; color: var(--accent-text); text-transform: uppercase; margin-top: 1.1rem; }
.big-card h3 { font-size: 1.32rem; margin-top: .45rem; }
.big-card .blurb { color: var(--text-dim); font-size: .875rem; margin-top: .6rem; display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.big-card .more { margin-top: auto; padding-top: 1rem; font-size: .82rem; color: var(--text-faint); display: flex; align-items: center; gap: .35rem; }

.flag {
  position: absolute; top: 1.1rem; right: 1.1rem;
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .22rem .6rem;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-text);
  font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
}

/* --- Filters -------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  padding: .38rem .85rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: .82rem;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.chip:active { transform: scale(.96); }

/* --- Upcoming timeline ---------------------------------------------------- */
/* The line and the dots are drawn by unrelated rules, so they share one axis: each centres itself on
   --tl-axis and neither can drift from the other again. */
.timeline { --tl-axis: 7.5px; position: relative; padding-left: 2.1rem; }
.timeline::before { content: ''; position: absolute; left: var(--tl-axis); top: .6rem; bottom: .6rem; width: 1px; transform: translateX(-50%); background: var(--line); }

.tl-row {
  display: grid;
  grid-template-columns: 9.6rem 1fr auto;
  gap: 1rem;
  align-items: baseline;
  width: 100%;
  padding: .95rem var(--row-pad);
  border: 0; border-bottom: 1px solid var(--line);
  background: none; cursor: pointer; text-align: left;
  position: relative;
  transition: background .2s var(--ease);
}
.tl-row:hover { background: var(--row-hover); }
.tl-row::before {
  content: '';
  position: absolute; left: calc(var(--tl-axis) - 2.1rem); top: 1.35rem;
  width: 9px; height: 9px; border-radius: 50%;
  transform: translateX(-50%);
  background: var(--bg); border: 1px solid var(--line-strong);
}
.tl-row[data-key='1']::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px rgb(242 168 62 / .55); }
.tl-when { font-family: var(--mono); font-size: .8rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.tl-main { display: flex; align-items: baseline; gap: .6rem; min-width: 0; }
.tl-main .icon { font-size: 1.05rem; color: var(--text-dim); align-self: center; }
.tl-name { font-weight: 500; }
.tl-sub { color: var(--text-faint); font-size: .84rem; }
@media (max-width: 700px) {
  .tl-row { grid-template-columns: 1fr; gap: .3rem; }
  .tl-sub { display: none; }
}

.more-btn {
  margin-top: 1.5rem;
  padding: .6rem 1.2rem;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: .875rem;
  transition: background .2s var(--ease);
}
.more-btn:hover { background: var(--surface-hi); }
.more-btn:active { transform: translateY(1px); }

/* --- Calendar grid -------------------------------------------------------- */
.cal-bar { display: flex; align-items: center; gap: .5rem; }
.cal-month { font-family: var(--mono); font-size: 1rem; min-width: 11.5rem; text-align: center; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); text-align: center; padding-bottom: .35rem;
}
.cal-day {
  position: relative;
  min-height: 104px;
  padding: .5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: rgb(255 255 255 / .015);
  display: flex; flex-direction: column; gap: .3rem;
  text-align: left; cursor: default;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.cal-day.pad { opacity: .32; }
.cal-day.has { cursor: pointer; background: var(--surface); }
.cal-day.has:hover { border-color: var(--line-strong); }
.cal-day.today { border-color: var(--accent-line); box-shadow: inset 0 0 0 1px var(--accent-line); }
.cal-day.key { background: linear-gradient(160deg, var(--accent-soft), transparent 70%); }

.cal-top { display: flex; align-items: center; justify-content: space-between; }
.cal-n { font-family: var(--mono); font-size: .82rem; color: var(--text-dim); }
.cal-day.today .cal-n { color: var(--accent-text); font-weight: 500; }
.cal-ev { display: flex; align-items: center; gap: .32rem; font-size: .69rem; color: var(--text-dim); line-height: 1.25; }
.cal-ev .icon { font-size: .82rem; flex: none; }
.cal-ev.hi { color: var(--accent-text); }
.cal-ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-rest { font-size: .66rem; color: var(--text-faint); font-family: var(--mono); }

@media (max-width: 720px) {
  .cal { gap: 3px; }
  .cal-day { min-height: 62px; padding: .3rem; }
  .cal-ev span, .cal-rest { display: none; }
  .cal-ev { gap: .15rem; }
  .cal-day > .cal-ev + .cal-ev { margin-top: -.2rem; }
}

/* Moon phase disc: lit half-disc + terminator ellipse. */
.moon-disc {
  --lit: #dfe4ef;
  --dark: #2a3040;
  position: relative; display: inline-block;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--dark);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12);
  overflow: hidden; flex: none;
}
.moon-disc::before {
  content: ''; position: absolute; inset: 0; background: var(--lit);
  clip-path: inset(0 0 0 50%);
}
.moon-disc[data-waning]::before { clip-path: inset(0 50% 0 0); }
.moon-disc::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: var(--term);
  transform: scaleX(var(--k));
}

/* --- Year sheet ----------------------------------------------------------- */
.sheet-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.year-tabs { display: flex; gap: .25rem; padding: .22rem; border: 1px solid var(--line); border-radius: var(--r-pill); }
.year-tabs button {
  padding: .3rem .9rem; border: 0; background: transparent; border-radius: var(--r-pill);
  font-family: var(--mono); font-size: .82rem; color: var(--text-dim); cursor: pointer;
  transition: all .2s var(--ease);
}
.year-tabs button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent-text); }

.sheet { border-top: 1px solid var(--line-strong); }
.sheet-month { break-inside: avoid; }
.sheet-month h3 {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); padding: 1.6rem 0 .55rem;
}
.sheet table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.sheet th { text-align: left; font-weight: 500; color: var(--text-faint); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; padding-bottom: .4rem; }
.sheet td { padding: .5rem .6rem .5rem 0; vertical-align: top; border-top: 1px solid var(--line); }
/* The end cells carry the padding so the row keeps it on both sides; the header cells get it too,
   or the column heading would no longer line up with its own values. */
.sheet tr:hover td { background: var(--row-hover); }
.sheet th:first-child, .sheet td:first-child { padding-left: var(--row-pad); }
.sheet th:last-child, .sheet td:last-child { padding-right: var(--row-pad); }
.sheet .c-date { width: 5.2rem; font-family: var(--mono); color: var(--text-dim); white-space: nowrap; }
.sheet .c-icon { width: 1.9rem; color: var(--text-faint); font-size: 1.05rem; }
.sheet .c-name { font-weight: 500; }
.sheet .c-note { color: var(--text-dim); font-size: .82rem; }
.sheet .c-tag { width: 1.6rem; text-align: right; color: var(--accent); }
@media (max-width: 780px) { .sheet .c-note { display: none; } }

/* --- Empty and error states ----------------------------------------------- */
.blank {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-dim);
}
.blank .icon { font-size: 2rem; color: var(--text-faint); margin-bottom: .7rem; }
.blank strong { display: block; color: var(--text); font-weight: 500; margin-bottom: .35rem; }
.blank code {
  display: inline-block; margin-top: .9rem; padding: .4rem .7rem;
  background: rgb(0 0 0 / .4); border: 1px solid var(--line); border-radius: var(--r-ctl);
  font-family: var(--mono); font-size: .8rem; color: var(--accent-text);
}

/* --- Detail dialog -------------------------------------------------------- */
dialog {
  width: min(560px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(4 6 12 / .72); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: start; gap: .85rem; padding: 1.4rem 1.4rem 1rem; border-bottom: 1px solid var(--line); }
/* Direct child only: this styles the event icon, not the one inside the close button. */
.dlg-head > .icon { font-size: 1.7rem; color: var(--accent); margin-top: .1rem; }
.dlg-head h3 { font-size: 1.3rem; }
.dlg-head .when { color: var(--text-dim); font-size: .875rem; margin-top: .2rem; }
.dlg-x {
  margin-left: auto; width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: transparent; cursor: pointer; color: var(--text-dim);
}
.dlg-x:hover { background: var(--surface); color: var(--text); }
.dlg-body { padding: 1.2rem 1.4rem 1.4rem; }
.dlg-body > p { color: var(--text-dim); font-size: .925rem; max-width: 62ch; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-top: 1.2rem; }
.fact { background: rgb(0 0 0 / .25); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: .6rem .75rem; }
.fact dt { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); }
.fact dd { margin: .2rem 0 0; font-family: var(--mono); font-size: .95rem; }
/* Long texts (visibility regions, parent body): full width and in the text font. */
.fact.wide { grid-column: 1 / -1; }
.fact.wide dd { font-family: inherit; font-size: .9rem; line-height: 1.45; }

.dlg-actions { margin-top: 1.2rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.dlg-actions .chip { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; }

/* Location-based visibility follows the single-accent rule: told apart by intensity
   (accent / dimmed), never by traffic-light colours. */
.fact[data-vis='yes'] { border-color: var(--accent-line); background: var(--accent-soft); }
.fact[data-vis='yes'] dd, .tl-sub[data-vis='yes'], .card-vis[data-vis='yes'], .next-vis[data-vis='yes'] { color: var(--accent-text); }
.fact[data-vis='no'] dd, .tl-sub[data-vis='no'], .card-vis[data-vis='no'], .next-vis[data-vis='no'] { opacity: .55; }
.cal-ev[data-vis='no'] { opacity: .45; }
.card-vis, .next-vis { font-size: .8rem; color: var(--text-dim); margin-top: .35rem; }
.chip-here { display: inline-flex; align-items: center; gap: .35rem; }
.foot-kofi a { color: var(--accent-text); text-decoration: underline; }
/* Release version: plain and quiet, it is for bug reports, not for visitors. */
.foot-version { margin-right: 1rem; font-family: var(--mono); font-size: .75rem; color: var(--text-faint); }

/* --- Footer --------------------------------------------------------------- */
footer { border-top: 1px solid var(--line); padding-block: 2.5rem 3.5rem; color: var(--text-faint); font-size: .82rem; }
/* Fixed grid: with flex and wrap each paragraph landed wherever it fitted and the Ko-fi link floated
   half-way down. Last row: IP status on the left, Ko-fi on the right, aligned. */
footer .shell {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 3rem; align-items: start;
  grid-template-areas: "src gen" "privacy ." "consent kofi";
}
footer p { max-width: 58ch; margin: 0; }
#foot-src { grid-area: src; }
#foot-gen { grid-area: gen; }
#foot-privacy { grid-area: privacy; }
.foot-consent { grid-area: consent; align-self: center; }
.foot-kofi { grid-area: kofi; justify-self: end; align-self: center; }
@media (max-width: 720px) {
  footer .shell { grid-template-columns: 1fr; grid-template-areas: "src" "gen" "privacy" "consent" "kofi"; }
  .foot-kofi { justify-self: start; }
}

/* --- Language selector in the top bar ------------------------------------ */
.lang-selector {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}

.lang-btn:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line-strong);
}

.lang-btn:active {
  transform: scale(0.96);
}

.lang-btn[aria-expanded="true"] {
  background: var(--surface-hi);
  color: var(--text);
}

.lang-label {
  font-weight: 500;
  letter-spacing: -0.01em;
}

.icon-caret {
  font-size: 0.85em;
  transition: transform 0.2s var(--ease);
}

.lang-btn[aria-expanded="true"] .icon-caret {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 51;
  margin-top: 0.5rem;
  min-width: 13rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lang-menu[hidden] {
  display: none;
}

.lang-menu {
  list-style: none; padding: 0;
}

.lang-menu li {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border-bottom: 1px solid var(--line);
}

.lang-menu li:last-child {
  border-bottom: none;
}

.lang-menu li:hover, .lang-menu li:focus {
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.lang-menu li[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 500;
}

@media (max-width: 560px) {
  .lang-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }
  
  .lang-label {
    font-size: 0.75rem;
  }
  
  .lang-menu {
    min-width: 11rem;
  }
}

/* --- CJK: system font fallbacks for zh-Hans, ja and ko ------------------- */
:lang(zh-Hans) {
  font-family: 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', 
               'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.65;
}

:lang(ja) {
  font-family: 'Hiragino Sans', 'Noto Sans CJK JP', 
               'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.65;
}

:lang(ko) {
  font-family: 'Noto Sans KR', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.65;
}

:lang(ru) {
  line-height: 1.6;
}

/* --- Today's event animation ------------------------------------------------ */
.event-animation-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.event-animation-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.event-animation-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
}

.event-animation-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* Solar eclipse: the Moon (dark disc) crosses in front of the Sun. The variant follows what is seen from
   the visitor's location: total, annular (smaller Moon) or partial (passes off-centre). */
.eclipse-sun {
  position: absolute; width: 400px; height: 400px; border-radius: 50%;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fff6dc 0%, #ffd27a 55%, #f2a83e 100%);
  box-shadow: 0 0 80px rgba(255, 200, 100, 0.55), 0 0 160px rgba(255, 150, 50, 0.3);
}
.eclipse-annular { width: 360px; height: 360px; }
.eclipse-partial { margin-top: -140px; }
.eclipse-container {
  position: absolute;
  width: 150%;
  height: 200%;
  top: -50%;
  left: -25%;
}

.eclipse {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(20, 20, 20, 0.95), rgba(0, 0, 0, 0.98));
  box-shadow:
    0 0 60px rgba(255, 200, 100, 0.4),
    0 0 120px rgba(255, 150, 50, 0.2),
    inset -20px -20px 60px rgba(0, 0, 0, 0.5),
    inset 20px 20px 80px rgba(50, 30, 10, 0.3);
  top: 50%;
  left: -25%;
  transform: translateY(-50%);
}

@keyframes eclipse-solar-total {
  0% {
    left: -25%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    left: 125%;
    opacity: 0;
  }
}

body:not(.reduced-motion) .eclipse {
  animation: eclipse-solar-total 5s ease-in-out forwards;
}

/* Lunar eclipse (any kind): reddish pulse */
.lunar-eclipse {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle at 40% 40%,
    rgba(180, 80, 40, 0.8),
    rgba(80, 20, 10, 0.95)
  );
  box-shadow:
    0 0 40px rgba(180, 80, 40, 0.5),
    0 0 80px rgba(120, 40, 20, 0.3),
    inset -15px -15px 40px rgba(0, 0, 0, 0.4);
}

@keyframes lunar-eclipse-pulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 0.9;
  }
}

body:not(.reduced-motion) .lunar-eclipse {
  animation: lunar-eclipse-pulse 4s ease-in-out infinite;
}

/* Meteor shower: single shooting star with trail */
.meteor-shower {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.shooting-star {
  position: absolute;
  width: 4px;
  height: 120px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 200, 100, 0.1));
  box-shadow: 0 0 15px rgba(255, 200, 100, 0.8), 0 0 30px rgba(255, 150, 50, 0.4);
  transform: rotate(-45deg);
  top: 10%;
  left: 20%;
}

@keyframes shooting-star-fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(-45deg);
  }
  100% {
    opacity: 0;
    transform: translate(600px, 800px) rotate(-45deg);
  }
}

body:not(.reduced-motion) .shooting-star {
  animation: shooting-star-fall 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.event-animation-hint {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  color: rgba(232, 234, 240, 0.6);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}

@keyframes hint-fade {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

body:not(.reduced-motion) .event-animation-hint {
  animation: hint-fade 5s ease 1s forwards;
}

.event-animation-info {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(22, 27, 39, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(242, 168, 62, 0.3);
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  text-align: center;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.event-animation-info.show {
  opacity: 1;
  pointer-events: auto;
}

.event-animation-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.event-animation-info p {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  body {
    --motion-disable: true;
  }

  .event-animation-overlay {
    transition: none;
  }

  @keyframes eclipse-solar-total {
    0% { left: 30%; opacity: 1; }
    100% { left: 30%; opacity: 1; }
  }

  @keyframes lunar-eclipse-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
  }

  @keyframes shooting-star-fall {
    0% { opacity: 1; }
    100% { opacity: 1; }
  }

  .eclipse-container,
  .meteor-shower,
  .lunar-eclipse {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .event-animation-hint {
    display: none;
  }
}

body.reduced-motion {
  --motion-disable: true;
}

/* Ko-fi: at rest it is just the logo. On hover (or on the first tap on touch screens, which app.js
   marks with .is-open) it grows to the right and reveals the text, so the visitor knows where it
   leads before clicking. */
.kofi-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding-inline: .45rem;
  border-radius: var(--r-pill);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease);
  margin: 0 0.25rem;
}

/* The logo keeps its brand colours; the cup's white outline already separates it from the dark background. */
.kofi-logo { display: block; width: 22px; height: auto; flex: none; }

.kofi-text {
  /* Without flex: none the text would shrink on narrow screens and show cut off ("Lea"): the navigation,
     already scrollable there, is what gives up space when it expands. */
  flex: none;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  font-size: .8rem;
  transition: max-width .35s var(--ease), opacity .25s var(--ease), margin-left .35s var(--ease);
}

.kofi-link:hover .kofi-text,
.kofi-link:focus-visible .kofi-text,
.kofi-link.is-open .kofi-text {
  max-width: min(14rem, 45vw);
  opacity: 1;
  margin-left: .4rem;
}

.kofi-link.is-open { background: var(--accent-soft); color: var(--accent-text); }

@media (prefers-reduced-motion: reduce) { .kofi-text { transition: none; } }

.kofi-link:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.kofi-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- Print: only the year sheet, on white paper */
@media print {
  :root { --text: #111; --text-dim: #444; --text-faint: #666; --line: #ddd; --accent: #000; }
  body { background: #fff; color: #111; font-size: 10.5pt; }
  /* Without this, printing before scrolling down to the sheet would print it blank:
     the scroll reveal keeps it at opacity 0 until it enters the screen. */
  .reveal { opacity: 1 !important; transform: none !important; }
  #sky, body::after, .topbar, .now, #imperdibles, #proximos, #calendario, footer, .sheet-bar, .eyebrow, dialog, .foot-kofi { display: none !important; }
  section { padding: 0; }
  .sheet-month h3 { color: #000; page-break-after: avoid; }
  .sheet td { border-top: 1px solid #ddd; }
  .sheet .c-note { display: table-cell; }
  a { text-decoration: none; }
}

/* Without JavaScript there is no calendar: explain why, without breaking the design. */
.noscript { position: relative; z-index: 1; max-width: 40rem; margin: 2rem auto; padding: 1rem 1.25rem; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text); }

/* 404 page */
.notfound {
  min-height: 100vh; max-width: 34rem; margin: 0 auto; padding: 2rem 1.5rem;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 1rem;
}
.notfound .brand { color: var(--text); text-decoration: none; }
.notfound-code { font-family: var(--mono); font-size: clamp(4rem, 18vw, 7rem); line-height: 1; color: var(--text-faint); margin: 1rem 0 0; }
.notfound h1 { margin: 0; font-size: 1.6rem; }
.notfound p { margin: 0; color: var(--text-dim); }
.notfound .chip { margin-top: .5rem; text-decoration: none; }

/* Location notice on the first visit. Accept and decline carry the same weight on purpose. */
/* Initial focus goes to the title, not a button, so neither answer is highlighted. */
.consent h2 { font-size: 1.25rem; margin: 0 0 .9rem; outline: none; }
.consent p { color: var(--text-dim); font-size: .925rem; line-height: 1.55; margin: 0 0 .75rem; }
.consent-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.consent-actions .chip { min-width: 8rem; justify-content: center; padding: .6rem 1rem; font-size: .95rem; }

/* Button styled as a link, for the footer. */
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.linklike:hover { color: var(--text); }

/* IP status in the footer: shows at a glance whether the page is using it. */
.foot-consent { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.ip-state { display: inline-flex; align-items: center; gap: .4rem; padding: .15rem .6rem; border: 1px solid var(--line-strong); border-radius: var(--r-pill); font-size: .8rem; color: var(--text-dim); }
.ip-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.ip-state[data-shared="true"] { border-color: var(--accent-line); color: var(--accent-text); }
.ip-state[data-shared="true"]::before { background: var(--accent); }
