/* ======================================================================
   HOW IT WORKS page. Colours come from tokens.css only.
   ====================================================================== */
:root {
  --gutter: max(20px, env(safe-area-inset-left), env(safe-area-inset-right));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

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

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Montserrat', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* the loading-screen gradient, pinned behind the page (background-attachment:
   fixed doesn't work on iOS) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(-65deg, var(--bg-raised), var(--bg));
}

a { color: inherit; }

:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 4px;
  border-radius: 6px;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--scrim);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
  transition: background-color 0.2s ease;
}

.back:hover { background: var(--glass-hover); }

.back svg,
.ic svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* ---- Content ---- */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 28px var(--gutter) max(40px, env(safe-area-inset-bottom));
}

h1 {
  margin: 12px 0 14px;
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.lead {
  font-size: 16px;
  color: var(--ink);
}

section { margin-top: 48px; }

h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

h2 span {
  font-weight: 400;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

p {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-soft);
}

strong { color: var(--ink); font-weight: 600; }

/* ---- Demo tiles: small skies ---- */
.tiles {
  display: grid;
  gap: 10px;
  margin: 18px 0 8px;
}

.tiles--3 { grid-template-columns: repeat(3, 1fr); }
.tiles--4 { grid-template-columns: repeat(4, 1fr); }
.tiles--5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 520px) {
  .tiles { gap: 8px; }
  .tiles--5 { grid-template-columns: repeat(3, 1fr); }
}

.tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
  isolation: isolate;
}

.tile canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.tile__veil {
  position: absolute;
  inset: 0;
  background: var(--veil);
}

.tile__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  z-index: 2;
  padding: 0 6px;
  text-align: center;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--tile-ink, var(--ink));
}

.tile__caption small {
  display: block;
  font-weight: 400;
  opacity: 0.8;
}

/* Steps: a grid that wraps, every tile fully visible */
h3 {
  margin: 26px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h3 span {
  margin-left: 8px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 12px 0 8px;
}

/* mini sun and moon: same drawing as the app, smaller */
.orb {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 34%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 0;
}

.orb--sun { background: var(--sun); }

.orb--sun.is-shining::before {
  content: '';
  position: absolute;
  inset: -110%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--sun-glow-inner) 30%, var(--sun-glow-outer) 55%, var(--sun-glow-end) 100%);
}

.orb--sun.is-veiled { background: var(--sun-veiled); filter: blur(1px); }

.orb--moon {
  box-shadow: inset 0 0 0 3px var(--sun);
  background: var(--moon-fill);
  animation: opacityMoon 3s ease-out infinite;
}

.orb i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--sun);
  animation: pulse 3s ease-out infinite;
}

.orb i.big { animation-name: pulse2x; }
.orb--sun.is-blazing::before { inset: -150%; }

/* ice halo ring, same drawing as the app's .halo */
.tile__halo {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 98.6%; /* 2.9 x the orb */
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side,
    transparent 80%, var(--halo-warm) 85%, var(--halo-white) 88.5%, var(--halo-cool) 92%, transparent 96%);
  pointer-events: none;
}

/* ---- Colour strips ---- */
.strip { margin: 18px 0; }

.strip__label,
.strip__ticks {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.strip__bar {
  height: 28px;
  margin: 8px 0 6px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
}

.strip__ticks {
  display: flex;
  justify-content: space-between;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

/* ---- Mini timeline ---- */
.timeline {
  margin: 20px 0 22px;
  padding: 16px 16px 18px;
  border-radius: 18px;
  background: var(--glass-row);
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
}

.timeline__label {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}

.timeline__track {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 82px;
  padding: 14px 0 12px;
  touch-action: none;
  cursor: ew-resize;
}

.timeline__track::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  height: 2px;
  background: var(--night, none);
}

.bar {
  position: relative;
  flex: 1;
  min-height: 4px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--bar-stroke);
  transition: transform 0.2s var(--ease);
  transform-origin: bottom;
}

.bar.is-selected {
  box-shadow: inset 0 0 0 1px var(--bar-stroke-selected), 0 0 0 1.5px var(--ink);
  transform: scaleY(1.1);
}

.bar__wx {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}

.bar__wx i { width: 1px; height: 6px; background: var(--ink-soft); }
.bar__wx.is-snow { flex-direction: column; align-items: center; }
.bar__wx.is-snow i { width: 3px; height: 3px; border-radius: 50%; }

.timeline__night {
  position: relative;
  height: 0;
}

.night-mark {
  position: absolute;
  top: -10.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.night-mark--moon { box-shadow: inset 0 0 0 1.2px var(--ink-soft); transform: translateX(calc(-100% - 2px)); }
.night-mark--sun { background: var(--ink-soft); transform: translateX(2px); }

/* Odometer roll for changing numbers (js/roll.js). Clipped vertically
   only, so letter spacing and glows aren't cut */
.roll {
  position: relative;
  display: inline-block;
  white-space: pre;
  vertical-align: bottom;
  clip-path: inset(0 -0.6em);
}

.roll__in { display: inline-block; }

.roll__out {
  position: absolute;
  left: 0;
  top: 0;
}

/* ---- Legend lists ---- */
.legend {
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.legend li + li { box-shadow: 0 -1px 0 var(--glass-row); }

.lg,
.ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
  color: var(--ink);
  font-style: normal;
}

.ic--text { font-size: 15px; font-weight: 600; }

/* legend glyphs drawn with tokens */
.lg--sky { background: linear-gradient(to top, var(--time-dusk), var(--temp-very-hot)); }
.lg--height { background: linear-gradient(to right, transparent 30%, var(--ink-soft) 30% 42%, transparent 42% 58%, var(--ink-soft) 58% 70%, transparent 70%) bottom / 100% 60% no-repeat, var(--glass); }
/* moon (ring) - line - sun (dot), as under the timeline */
.lg--night { position: relative; background: linear-gradient(var(--ink-soft), var(--ink-soft)) center / 34% 2px no-repeat, var(--glass); }
.lg__moon, .lg__sun { position: absolute; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; }
.lg__moon { left: 6px; box-shadow: inset 0 0 0 1.2px var(--ink-soft); }
.lg__sun { right: 6px; background: var(--ink-soft); }

/* rain ticks / snow dots, same drawing as the timeline marks */
.mk { display: inline-flex; align-items: flex-end; gap: 2px; }
.mk i { width: 1px; height: 7px; background: currentColor; }
.mk[data-kind="snow"] { flex-direction: column; align-items: center; }
.mk[data-kind="snow"] i { width: 3px; height: 3px; border-radius: 50%; }

.marks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mark-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px;
  border-radius: 12px;
  background: var(--glass-row);
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink);
}

.mark-chip .mk { min-width: 9px; justify-content: center; color: var(--ink-soft); }

/* the mark each rain / snow step gets, in the tile corner */
.tile__mark {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  color: var(--tile-ink, var(--ink));
  opacity: 0.85;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--glass-stroke);
  font: 600 12px 'Montserrat', sans-serif;
  text-align: center;
  color: var(--ink);
}

@media (hover: none) { .only-keys { display: none !important; } }

/* ---- Footer ---- */
footer {
  margin-top: 56px;
  text-align: center;
}

.cta {
  display: inline-block;
  padding: 15px 28px;
  border-radius: 26px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--glass-stroke-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.cta:hover { background: var(--glass-hover); }

footer p {
  margin-top: 22px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- Animations (same as the app) ---- */
@keyframes pulse {
  0%   { transform: scale(0);   opacity: 0; }
  45%  { transform: scale(0.9); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes pulse2x {
  0%   { transform: scale(0);   opacity: 0; }
  45%  { transform: scale(0.9); opacity: 0.5; }
  100% { transform: scale(2.4); opacity: 0; }
}

@keyframes opacityMoon {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.9; }
  60%      { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
