/* ==========================================================================
   Daylight: the day as a strip of sky. Colours in the ribbon and the year
   plot are computed from sun altitude in sun.js; the page itself is night.
   ========================================================================== */

:root {
  --night: #0b102c;
  --night-2: #141a3d;       /* raised surfaces */
  --line: #2c3563;
  --text: #eef1fa;
  --text-2: #a9b1d4;        /* 8.6:1 on night */
  --civil: #3a4c8a;
  --naut: #1b2452;
  --golden: #ecb070;
  --day: #d6e6f2;
  --font: "Bricolage Grotesque", system-ui, sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line) var(--night); }
body {
  margin: 0; min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -18%, rgb(var(--now-sky, 11 16 44) / .32), transparent 70%) no-repeat,
    var(--night);
  color: var(--text);
  font: 400 1.05rem/1.55 var(--font);
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums;
  caret-color: var(--golden);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--golden); color: var(--night); }
h1, h2, p, dl, dd { margin: 0; }
:focus-visible { outline: 2px solid var(--golden); outline-offset: 3px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { width: min(100% - 2rem, 64rem); margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) 0 3rem; }

/* ---------- Bar ---------- */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.3rem; letter-spacing: .01em; display: flex; align-items: center; gap: .6rem; }
.brand::before { content: ""; width: 1.4rem; height: .7rem; border-radius: .7rem .7rem 0 0; background: var(--golden); box-shadow: 0 .45rem 0 -.28rem var(--text-2); }
.where { display: flex; flex-wrap: wrap; gap: .5rem; }
#place, .locate {
  font: 600 1rem var(--font); color: var(--text);
  min-height: 2.75rem; border-radius: 999px; border: 1.5px solid var(--line);
  background-color: var(--night-2); cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
#place {
  appearance: none; -webkit-appearance: none;
  padding: .5rem 2.4rem .5rem 1.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23eef1fa' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center; background-size: .7rem;
}
.locate { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1rem; }
.locate svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#place:hover, .locate:hover { border-color: var(--text-2); }
.locate-msg { margin-top: .6rem; font-size: .92rem; color: var(--text-2); min-height: 1.4em; text-align: right; }

/* ---------- Today ---------- */
.today { margin-top: clamp(2rem, 7vw, 4.5rem); }
.length {
  font-size: clamp(3.6rem, 13vw, 7.5rem); font-weight: 800; line-height: .95; letter-spacing: -.035em;
  font-variation-settings: "opsz" 96;
}
.story { margin-top: 1.1rem; font-size: clamp(1.1rem, 2.4vw, 1.4rem); color: var(--text-2); max-width: 46ch; text-wrap: balance; }
.story strong { white-space: nowrap; }
.story strong { color: var(--text); font-weight: 600; }

/* ---------- Ribbon ---------- */
.ribbon-wrap { margin-top: clamp(2.25rem, 6vw, 3.5rem); }
.ribbon { position: relative; height: clamp(4.5rem, 12vw, 6.5rem); }
.ribbon canvas {
  display: block; width: 100%; height: 100%;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgb(255 255 255 / .06) inset, 0 20px 40px -24px rgb(0 0 0 / .9);
}
.ribbon::after, .year-plot::after { content: ""; position: absolute; inset: 0; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); pointer-events: none; }
.year-plot::after { border-radius: 8px; }
.marks { position: absolute; inset: 0; }
.mark { position: absolute; top: 0; bottom: 0; width: 0; }
.m-event::before { content: ""; position: absolute; top: 55%; bottom: -1.6rem; left: -.5px; width: 1px; background: var(--text-2); opacity: .7; }
.m-now::before { content: ""; position: absolute; top: -.5rem; bottom: -.5rem; left: -1px; width: 2px; background: var(--text); box-shadow: 0 0 0 1px rgb(11 16 44 / .55); }
.m-now b { position: absolute; bottom: 100%; margin-bottom: .75rem; translate: -50% 0; white-space: nowrap; color: var(--night); background: var(--text); padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }

.axis { position: relative; height: 1.4rem; margin-top: .35rem; border-top: 1px solid var(--line); }
.axis span { position: absolute; left: calc(var(--x) * 100%); top: 0; translate: -50% 0; font-size: .75rem; color: var(--text-2); padding-top: .35rem; }
.axis span::before { content: ""; position: absolute; top: -1px; left: 50%; width: 1px; height: .3rem; background: var(--line); }
.axis span:first-child { translate: 0 0; } .axis span:first-child::before { left: 0; }
.axis span:last-child { translate: -100% 0; } .axis span:last-child::before { left: auto; right: 0; }
.axis span:empty::before { height: .2rem; }
.events { position: relative; height: 2.6rem; margin-top: .2rem; }
.event { position: absolute; top: 0; translate: -50% 0; display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: 1.05rem; white-space: nowrap; background: var(--night); padding: .15rem .45rem; border-radius: 999px; }
.event svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: var(--golden); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* one authored moment: the day sweeps in */
.ribbon canvas { clip-path: inset(0 0 0 0 round 12px); }
body:not(.ready) .ribbon canvas { clip-path: inset(0 100% 0 0 round 12px); }
body.ready .ribbon canvas { transition: clip-path 1.4s var(--ease-out) .1s; }

/* ---------- Facts ---------- */
.facts { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 1.75rem; border-top: 1px solid var(--line); }
.facts div { padding: 1.1rem 1rem 0 0; }
.facts div + div { padding-left: 1rem; border-left: 1px solid var(--line); }
.facts dt { font-size: .85rem; color: var(--text-2); }
.facts dd { font-size: clamp(1.5rem, 3.5vw, 2.1rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: .15rem; }
@media (max-width: 38rem) {
  .facts { grid-template-columns: 1fr 1fr; }
  .facts div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts div:nth-child(n + 3) { margin-top: 1rem; border-top: 1px solid var(--line); }
}

/* ---------- Year ---------- */
.year { margin-top: clamp(3.5rem, 9vw, 5.5rem); }
.year-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .35rem 1.5rem; margin-bottom: 1.1rem; }
.year-head h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 700; letter-spacing: -.01em; }
.year-head p { color: var(--text-2); font-size: .95rem; }
.year-plot { position: relative; }
.yaxis span { position: absolute; right: .5rem; top: calc(var(--y) * 100%); translate: 0 -50%; font-size: .7rem; font-weight: 600; color: var(--text); background: rgb(11 16 44 / .7); padding: 0 .35rem; border-radius: 999px; pointer-events: none; }
.year-plot canvas { display: block; width: 100%; height: clamp(11rem, 30vw, 17rem); image-rendering: pixelated; border-radius: 8px; }
.flag { position: absolute; top: -.4rem; bottom: -.4rem; width: 0; }
.flag::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--text); box-shadow: 0 0 0 1px rgb(11 16 44 / .5); }
.flag span {
  position: absolute; top: 0; left: 1px;
  background: var(--text); color: var(--night); font-weight: 700; font-size: .78rem;
  padding: .15rem .55rem .15rem .45rem;
  clip-path: polygon(0 0, 100% 0, calc(100% - .4rem) 50%, 100% 100%, 0 100%);
  padding-right: .85rem;
}
.flag.flip span { left: auto; right: 1px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, .4rem 50%); padding-left: .85rem; padding-right: .45rem; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); margin-top: .5rem; font-size: .78rem; color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; margin-top: 1.25rem; font-size: .88rem; color: var(--text-2); }
.k { display: inline-block; width: .85rem; height: .85rem; border-radius: 3px; margin-right: -.55rem; vertical-align: -.1em; }
.k-day { background: var(--day); } .k-civil { background: var(--civil); } .k-naut { background: var(--naut); } .k-night { background: #0b102c; box-shadow: inset 0 0 0 1px var(--line); }

.foot { margin-top: 3.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--text-2); font-size: .9rem; }
.foot p { max-width: 70ch; }

@media (max-width: 30rem) {
  .months span:nth-child(even) { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.legend-note { flex-basis: 100%; }
