/* ======================================================================
   HOW IT WORKS page. Same look as the landing page (product/landing.css);
   sky colours come from tokens.css.
   ====================================================================== */
:root {
  --page: #0e0e0f;
  --panel: #141416;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --text-soft: #a1a1a8;
  --text-faint: #6b6b73;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

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

.wrap {
  width: 100%;
  max-width: calc(760px + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---- Nav ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: env(safe-area-inset-top);
  background: rgba(14, 14, 15, 0.72);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
}

.back {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: -6px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.back:hover { background: rgba(255, 255, 255, 0.06); }

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

.nav__title { font-weight: 600; letter-spacing: -0.01em; }

.nav__link {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-soft);
  text-decoration: none;
}

.nav__link:hover { color: var(--text); }

/* ---- Content ---- */
main {
  padding-top: 72px;
  padding-bottom: max(48px, env(safe-area-inset-bottom));
}

h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 52px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 600;
}

.lead {
  max-width: 48ch;
  margin: 20px 0 0;
  font-size: 17px;
}

.lead a { color: var(--text); text-decoration: none; white-space: nowrap; }
.lead a:hover { text-decoration: underline; text-underline-offset: 3px; }

section {
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.sec__head { margin-bottom: 14px; }

.sec__head span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

h2 {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 30px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 600;
}

h3 {
  margin: 28px 0 0;
  font-size: 14px;
  font-weight: 500;
}

h3 span {
  margin-left: 8px;
  font-weight: 400;
  color: var(--text-faint);
}

p {
  max-width: 60ch;
  margin: 0 0 16px;
  line-height: 1.65;
  color: var(--text-soft);
}

p a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }

strong { color: var(--text); font-weight: 500; }

/* ---- Small skies ---- */
.tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
  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: 11px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--tile-ink, var(--ink));
}

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

.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;
}

/* 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;
}

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

.strip__label,
.strip__ticks {
  font-size: 12px;
  color: var(--text-soft);
}

.strip__ticks {
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.strip__bar {
  height: 28px;
  margin: 8px 0 6px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

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

.timeline__label {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  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) */
.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--grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 28px;
}

@media (max-width: 560px) { .legend--grid { grid-template-columns: 1fr; } }

.legend li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-soft);
  border-top: 1px solid var(--line);
}

.legend strong { display: block; }

.lg,
.ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  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(--panel); }
/* 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(--panel); }
.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%; }

/* ---- Tips ---- */
.tips {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tips li {
  padding: 11px 0;
  font-size: 14px;
  color: var(--text-soft);
  border-top: 1px solid var(--line);
}

.tips li:first-child { border-top: 0; padding-top: 0; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  font: 500 12px 'Inter', sans-serif;
  text-align: center;
  color: var(--text);
}

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

/* ---- Footer ---- */
footer {
  margin-top: 72px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.foot__btns { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, transform 0.2s var(--ease);
}

.btn:active { transform: scale(0.97); }
.btn--light { background: var(--text); color: var(--page); }
.btn--light:hover { background: #fff; }
.btn--ghost { box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.06); }

footer p {
  margin: 28px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---- 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; }
}
