/* Colours change with the sky. Registered so the changes can fade. */
@property --sky-top   { syntax: "<color>"; inherits: true; initial-value: #0b1030; }
@property --sky-bot   { syntax: "<color>"; inherits: true; initial-value: #14305a; }
@property --ink       { syntax: "<color>"; inherits: true; initial-value: #eef2ff; }
@property --ink-soft  { syntax: "<color>"; inherits: true; initial-value: #a9b4d6; }
@property --line      { syntax: "<color>"; inherits: true; initial-value: #3a4a78; }
@property --accent    { syntax: "<color>"; inherits: true; initial-value: #5eead4; }
@property --ridge-far { syntax: "<color>"; inherits: true; initial-value: #101b3d; }
@property --ridge-near{ syntax: "<color>"; inherits: true; initial-value: #060a1c; }

@font-face {
  font-family: "Gentium Plus"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/GentiumPlus-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Gentium Plus"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/GentiumPlus-Italic.woff2") format("woff2");
}

:root {
  /* Gentium Plus is built for extended Latin and stacked tone marks */
  --serif: "Gentium Plus", "Iowan Old Style", Georgia, "Noto Serif", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --en: #fcd34d;
  --gutter: 20px;
}

body[data-phase="night"] {
  --sky-top: #070b24; --sky-bot: #143a5c; --ink: #eef2ff; --ink-soft: #a3b0d6;
  --line: #34476f; --accent: #5eead4; --ridge-far: #0d1a3a; --ridge-near: #050816;
  --cloud: rgba(150,170,210,.38); --cloud-dark: rgba(70,82,115,.6); --rain: #9cc4ff;
}
body[data-phase="dawn"] {
  --sky-top: #2b2a63; --sky-bot: #f3a27a; --ink: #fff7f0; --ink-soft: #f7d9c8;
  --line: #a9739a; --accent: #ffe08a; --ridge-far: #5a3b6b; --ridge-near: #1f1638;
  --cloud: rgba(255,232,222,.5); --cloud-dark: rgba(110,80,120,.6); --rain: #ffd9c9;
}
body[data-phase="day"] {
  --sky-top: #7fb7e6; --sky-bot: #eaf4fb; --ink: #0f1d3a; --ink-soft: #3b4d73;
  --line: #8faed0; --accent: #0b6b78; --ridge-far: #5f86a3; --ridge-near: #1d3a4e;
  --en: #9a3412;
  --cloud: rgba(255,255,255,.85); --cloud-dark: rgba(110,125,150,.75); --rain: #2f5d8f;
}
body[data-phase="dusk"] {
  --sky-top: #1d1a4f; --sky-bot: #e8765f; --ink: #fff4ec; --ink-soft: #f4cdbd;
  --line: #9a5a8a; --accent: #ffd37a; --ridge-far: #54305f; --ridge-near: #190f2e;
  --cloud: rgba(255,225,210,.5); --cloud-dark: rgba(100,70,110,.6); --rain: #ffd9c9;
}

* { box-sizing: border-box; }
[lang="gwi"] { font-family: var(--serif); }
html { background: #070b24; }
body {
  margin: 0; min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column;
  font-family: var(--sans); color: var(--ink); line-height: 1.4;
  background: linear-gradient(var(--sky-top), var(--sky-bot)) fixed;
  transition: --sky-top 4s, --sky-bot 4s, --ink 4s, --ink-soft 4s, --line 4s,
              --accent 4s, --ridge-far 4s, --ridge-near 4s;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scene ---------- */
.scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.stars { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 4s; }
.stars circle { fill: #fff; }
body[data-phase="night"] .stars { opacity: 1; }
body[data-phase="dawn"] .stars, body[data-phase="dusk"] .stars { opacity: .35; }

.aurora { position: absolute; inset: 0; opacity: 0; transition: opacity 4s; }
body[data-phase="night"] .aurora { opacity: 1; }
.aurora i {
  position: absolute; left: -10%; width: 120%; height: 30%;
  filter: blur(46px); opacity: .55; mix-blend-mode: screen;
  background: linear-gradient(90deg, transparent, #34d399 25%, #22d3ee 55%, #a78bfa 80%, transparent);
  animation: sway 18s ease-in-out infinite alternate;
}
.aurora i:nth-child(1) { top: 6%; }
.aurora i:nth-child(2) { top: 16%; height: 22%; opacity: .35; animation-duration: 26s; animation-delay: -9s; }
.aurora i:nth-child(3) { top: 28%; height: 16%; opacity: .25; animation-duration: 33s; animation-delay: -14s; }
@keyframes sway {
  from { transform: translateX(-6%) skewX(-8deg) scaleY(.8); }
  to   { transform: translateX(6%) skewX(8deg) scaleY(1.2); }
}
@media (prefers-reduced-motion: reduce) { .aurora i { animation: none; } body { transition: none; } }

/* ---------- Layout ---------- */
.wrap {
  flex: 1; width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 18px var(--gutter) 28px;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.greeting { margin: 0; font-family: var(--serif); font-size: clamp(1.15rem, 4.8vw, 1.5rem); font-style: italic; }
.greeting .en { font-style: normal; }

.en-toggle {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font: 600 .9rem var(--sans); color: var(--ink); background: transparent;
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 9px 16px 9px 12px;
  transition: background .2s, color .2s;
}
.en-toggle .dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor; position: relative; }
.en-toggle[aria-pressed="true"] { background: var(--en); border-color: var(--en); color: #1c1203; }
.en-toggle[aria-pressed="true"] .dot { background: currentColor; }
.en-toggle:focus-visible, a:focus-visible, .wx-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- Sun / moon path ---------- */
.path { margin: 14px 0 6px; }
.arc { display: block; width: 100%; height: auto; overflow: visible; }
.horizon { stroke: var(--line); stroke-width: 1.5; }
.track { fill: none; stroke: var(--ink-soft); stroke-width: 1.5; stroke-dasharray: 2 9; stroke-linecap: round; opacity: .8; }
#orb { fill: #ffe9a8; }
body[data-phase="day"] #orb { fill: #f59e0b; }
.is-moon #orb { fill: #eef2ff; mask: url(#crescent); }
.is-moon #glow { opacity: .25; }
.path-ends { display: flex; justify-content: space-between; gap: 12px; }
.path-ends p { margin: 0; font-size: .85rem; color: var(--ink-soft); max-width: 46%; }
.path-ends p:last-child { text-align: right; }
.path-ends .t { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

/* Weather animation, drawn inside the sun path */
#body { transition: opacity 2s; }
.arc[data-cover="light"] #body { opacity: .7; }
.arc[data-cover="heavy"] #body { opacity: .3; }
#fx { pointer-events: none; }
#fx .cloud { fill: var(--cloud); filter: blur(5px); animation: drift var(--d) linear var(--delay) infinite; }
#fx .cloud.dark { fill: var(--cloud-dark); }
#fx .rain { stroke: var(--rain); stroke-width: 1.6; stroke-linecap: round; opacity: .75; animation: rain var(--d) linear var(--delay) infinite; }
#fx .snow { fill: #fff; opacity: .9; animation: snow var(--d) linear var(--delay) infinite; }
#fx .fog { fill: var(--cloud); filter: blur(12px); animation: sway var(--d) ease-in-out var(--delay) infinite alternate; }
#fx .wind { stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; opacity: .35; animation: gust var(--d) linear var(--delay) infinite; }
#fx .flash { fill: #fff; opacity: 0; animation: flash 9s linear infinite; }
@keyframes drift { from { transform: translateX(-260px); } to { transform: translateX(1160px); } }
@keyframes rain  { from { transform: translate(0, -20px); } to { transform: translate(-34px, 260px); } }
@keyframes snow  { 0% { transform: translate(0, -12px); } 50% { transform: translate(16px, 120px); } 100% { transform: translate(-8px, 250px); } }
@keyframes sway  { from { transform: translateX(-50px); } to { transform: translateX(50px); } }
@keyframes gust  { from { transform: translateX(-140px); } to { transform: translateX(1100px); } }
@keyframes flash { 0%, 92%, 95%, 100% { opacity: 0; } 93% { opacity: .55; } 96% { opacity: .35; } 97% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  #fx * { animation: none !important; }
  #fx .cloud { transform: translateX(var(--x, 400px)); }
  #fx .flash, #fx .wind { display: none; }
}

/* ---------- Content ---------- */
.main { display: grid; gap: 28px; margin-top: 18px; }
.label {
  margin: 0 0 10px; font: 700 .72rem var(--sans); text-transform: uppercase;
  letter-spacing: .18em; color: var(--accent);
}
.label .en { text-transform: none; letter-spacing: .03em; }

.digits {
  margin: 0; font-family: var(--serif); font-weight: 400; line-height: .9;
  font-size: clamp(5.5rem, 31vw, 15rem); letter-spacing: -.04em;
  font-variant-numeric: lining-nums tabular-nums;
}
.time-words { margin: 18px 0 0; font-family: var(--serif); font-size: clamp(1.25rem, 5vw, 1.9rem); line-height: 1.3; overflow-wrap: anywhere; }

.side { display: grid; gap: 28px; }
.weather { border-top: 1px solid var(--line); padding-top: 18px; }
.date { padding-top: 4px; }
.day-name { margin: 0; font-family: var(--serif); font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: 1.05; }
.date-words { margin: 8px 0 0; font-family: var(--serif); font-size: clamp(1.05rem, 4vw, 1.3rem); overflow-wrap: anywhere; }

.wx-main { margin: 0; font-family: var(--serif); font-size: clamp(1.8rem, 7.5vw, 2.8rem); line-height: 1.1; }
.wx-temp { margin: 14px 0 0; display: flex; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; }
.wx-temp strong { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 12vw, 4rem); line-height: 1; font-variant-numeric: lining-nums; }
.wx-temp > span { font-family: var(--serif); font-size: 1.1rem; }
.wx-list { margin: 14px 0 0; padding: 0; list-style: none; }
.wx-list li { padding: 6px 0; font-family: var(--serif); color: var(--ink-soft); }
.wx-note { margin: 0 0 14px; color: var(--ink-soft); font-size: .95rem; }
.wx-hint { margin: 12px 0 0; color: var(--ink-soft); font-size: .82rem; }
.wx-ask { display: grid; gap: 12px; justify-items: start; }
.wx-search { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.wx-search input {
  flex: 1; min-width: 0; font: 1rem var(--sans); color: var(--ink); background: transparent;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 11px 16px;
}
.wx-search input::placeholder { color: var(--ink-soft); }
.wx-search input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wx-go {
  cursor: pointer; font: 700 .95rem var(--sans); color: var(--ink); background: transparent;
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 18px;
}
.wx-foot { margin: 10px 0 0; font-size: .82rem; color: var(--ink-soft); }
.wx-link { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.wx-link:focus-visible, .wx-go:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.wx-btn {
  cursor: pointer; font: 700 1rem var(--sans); color: var(--sky-top, #070b24);
  background: var(--ink); border: 0; border-radius: 999px; padding: 13px 24px;
}
body[data-phase="day"] .wx-btn { color: #fff; }
.wx-btn:disabled { opacity: .6; }

.en { display: none; color: var(--en); font: italic .82em/1.35 var(--sans); margin-top: 3px; }
.show-en .en { display: block; }

/* Legend */
.legend { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); max-width: 760px; }
.legend-lead { margin: 0 0 18px; font-size: .98rem; max-width: 62ch; }
.legend-eg-title { margin: 0 0 8px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; color: var(--ink-soft); }
.eg { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.part { display: flex; flex-wrap: wrap; gap: 8px 14px; padding-top: 8px; border-top: 3px solid var(--accent); }
.part.mins { border-top-color: #a78bfa; }
.part.join { border-top-color: transparent; }
body[data-phase="day"] .part.mins { border-top-color: #6d28d9; }
.chunk { display: grid; gap: 2px; }
.chunk .gw { font-family: var(--serif); font-size: 1.35rem; line-height: 1.15; }
.chunk .gl { font-size: .78rem; color: var(--ink-soft); }
.legend-list { margin: 20px 0 0; padding-left: 1.1em; display: grid; gap: 6px; font-size: .92rem; max-width: 62ch; }
.legend-list b { font-family: var(--serif); font-size: 1.05em; }

footer { margin-top: 28px; color: var(--ink-soft); font-size: .78rem; }
.privacy summary { cursor: pointer; width: max-content; }
.privacy summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.privacy p { margin: 8px 0 0; max-width: 62ch; }
.credit { margin: 14px 0 0; }
footer a { color: inherit; }

/* ---------- Ridge ---------- */
.ridge { line-height: 0; margin-top: -1px; }
.ridge svg { display: block; width: 100%; height: clamp(80px, 15vw, 190px); }
.ridge .far { fill: var(--ridge-far); }
.ridge .near { fill: var(--ridge-near); }

/* ---------- Mobile ---------- */
@media (max-width: 899px) {
  .wrap { padding-bottom: 90px; }
  /* Toggle floats at the bottom where a thumb reaches it */
  .en-toggle {
    position: fixed; z-index: 10; left: 50%; transform: translateX(-50%);
    bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--sky-top); box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
    padding: 12px 22px 12px 16px;
  }
  body[data-phase="day"] .en-toggle { background: #fff; }
  .en-toggle[aria-pressed="true"] { background: var(--en); }
  .bar { justify-content: flex-start; }
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  :root { --gutter: 56px; }
  .wrap { padding-top: 30px; }
  .path { margin-top: 20px; }
  .main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 96px; margin-top: 30px; align-items: start; }
  .side { gap: 32px; padding-top: 10px; }
  .weather { padding-top: 24px; }
  .time-words { max-width: 22ch; }
  .time { padding-bottom: 20px; }
}
