/* RingLink — ringlink.taptorapp.com
   Palette and type mirror the iOS app (RL tokens in RingLinkApp.swift).
   No web fonts, no third-party requests. */

:root {
  --night: #090C12;
  --night-2: #0D111A;
  --plate: #121720;
  --track: #252B35;
  --platinum: #E8EBEF;
  --slate: #8B93A1;
  --dim: #5A6270;
  --photon: #3FD8F2;
  --pulse: #46E39B;
  --oxygen: #FF5A67;
  --amber: #FFB547;
  --coral: #FF8F6B;
  --deep: #4C56E8;
  --light: #7FA7FF;
  --rem: #B48CFF;
  --awake: #F2B86B;

  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wide: 125%;
  --measure: 62ch;
  --gutter: clamp(20px, 5vw, 56px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--night); }
body {
  margin: 0;
  background: var(--night);
  color: var(--platinum);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--photon); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--platinum); }
:focus-visible { outline: 2px solid var(--photon); outline-offset: 3px; border-radius: 4px; }
::selection { background: rgba(63, 216, 242, .28); }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 12px; top: 12px; z-index: 10; background: var(--platinum); color: var(--night); padding: 8px 12px; border-radius: 8px; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px var(--gutter);
  background: rgba(9, 12, 18, .78);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.top.scrolled { border-bottom-color: var(--track); }
.brand { display: inline-flex; align-items: center; }
.brand img { height: 24px; width: auto; }
.home .top .brand { opacity: 0; transform: translateY(-4px); transition: opacity .35s, transform .35s; pointer-events: none; }
.home .top.scrolled .brand { opacity: 1; transform: none; pointer-events: auto; }
.top nav { display: flex; gap: clamp(14px, 3vw, 28px); font-size: 15px; }
.top nav a { color: var(--slate); text-decoration: none; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--platinum); }

/* ---------- Type ---------- */
h1, h2, h3 { text-wrap: balance; font-stretch: var(--wide); font-weight: 300; letter-spacing: -0.012em; margin: 0; }
h1 { font-size: clamp(30px, 4.4vw, 48px); line-height: 1.12; }
h2 { font-size: clamp(26px, 3.2vw, 38px); line-height: 1.15; }
h3 { font-size: 19px; line-height: 1.3; font-weight: 500; letter-spacing: 0; }
p { margin: 0 0 1em; }
.lede { font-size: clamp(18px, 1.6vw, 20px); color: var(--slate); max-width: var(--measure); }
.small { font-size: 14px; color: var(--slate); }

/* ---------- Home: hero ---------- */
.hero {
  position: relative;
  min-height: min(92vh, 860px);
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 0 var(--gutter) clamp(40px, 7vh, 80px);
  overflow: hidden;
  background:
    radial-gradient(60% 55% at 50% 42%, rgba(22, 24, 59, .85) 0%, rgba(13, 15, 34, .35) 55%, rgba(9, 12, 18, 0) 100%);
}
.hero-stage { position: relative; min-height: 300px; }
.hero-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.hero-copy { max-width: 760px; margin: 0 auto; text-align: center; }
.hero-copy h1 { margin-bottom: 18px; }
.hero-copy .lede { margin: 0 auto 22px; }
.facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin: 0; padding: 0; list-style: none; font-size: 15px; color: var(--slate); }
.facts li { display: inline-flex; align-items: center; gap: 8px; }
.facts li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.facts li:nth-child(1)::before { background: var(--pulse); }
.facts li:nth-child(2)::before { background: var(--oxygen); }
.replay {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  font: inherit; font-size: 13px; color: var(--dim);
  background: none; border: 1px solid var(--track); border-radius: 999px;
  padding: 5px 12px; cursor: pointer;
}
.replay:hover { color: var(--platinum); border-color: var(--slate); }

.reveal { opacity: 1; transform: none; }
.js .hero .reveal { opacity: 0; transform: translateY(10px); transition: opacity .8s ease, transform .8s ease; }
.js .hero.ready .reveal { opacity: 1; transform: none; }
.js .hero.ready .reveal.late { transition-delay: .18s; }

/* ---------- Home: sections ---------- */
.band { padding: clamp(64px, 11vw, 140px) var(--gutter); }
.band + .band { padding-top: 0; }
.wrap { max-width: 1120px; margin: 0 auto; }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 88px); align-items: center; }
.split.flip { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
.split h2 { margin-bottom: 20px; }
.split p { color: var(--slate); max-width: 52ch; }
.split p strong { color: var(--platinum); font-weight: 500; }

/* Hypnogram */
.night {
  background: linear-gradient(180deg, #16183B 0%, #0D0F22 100%);
  border-radius: 28px;
  padding: clamp(20px, 3vw, 32px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.night-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.night-head .total { font-stretch: var(--wide); font-weight: 200; font-size: clamp(34px, 4vw, 46px); line-height: 1; }
.night-head .total span { font-size: .5em; color: var(--slate); margin-left: 2px; }
.night-head .tag { font-size: 13px; color: var(--slate); }
.hypno { width: 100%; height: auto; }
.hypno text { fill: var(--dim); font: 12px var(--sans); }
.legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 20px 0 0; padding: 0; list-style: none; }
.legend li { font-size: 13px; color: var(--slate); }
.legend b { display: block; font-weight: 300; font-stretch: var(--wide); font-size: 20px; color: var(--platinum); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.cite { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--track); font-size: 14px; color: var(--slate); }
.cite a { color: var(--slate); }

/* Turntable */
.turn { position: relative; }
.turn-canvas { width: min(460px, 100%); aspect-ratio: 1; margin: 0 auto; touch-action: pan-y; cursor: grab; }
.turn-canvas:active { cursor: grabbing; }
.swatches { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.swatch {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 14px; color: var(--slate);
  background: var(--plate); border: 1px solid var(--track); border-radius: 999px;
  padding: 7px 14px 7px 8px; cursor: pointer;
}
.swatch::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.swatch[aria-pressed="true"] { color: var(--platinum); border-color: var(--slate); }
.turn-hint { text-align: center; font-size: 13px; color: var(--dim); margin-top: 10px; }
.checks { margin: 24px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.checks li { display: grid; grid-template-columns: 12px 1fr; gap: 14px; align-items: baseline; color: var(--slate); }
.checks li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--photon)); transform: translateY(-1px); }
.checks strong { color: var(--platinum); font-weight: 500; }

/* Apple Health rows */
.health-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 88px); }
.rows { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--track); }
.rows li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--track); }
.rows li span:first-child { display: inline-flex; align-items: center; gap: 12px; }
.rows li span:first-child::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.rows li span:last-child { color: var(--dim); font-size: 14px; text-align: right; }

/* Privacy promise */
.promise { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 clamp(20px, 3vw, 40px); margin-top: 40px; }
.promise div { border-top: 2px solid var(--c); padding-top: 18px; }
.promise h3 { margin-bottom: 8px; }
.promise p { color: var(--slate); font-size: 15px; margin: 0; }

/* Price */
.price { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 24px; padding: clamp(28px, 4vw, 44px); border-radius: 28px; background: var(--plate); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.price h2 { max-width: 18ch; }
.price p { color: var(--slate); max-width: 46ch; margin: 0; }

/* ---------- Documents ---------- */
.doc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(32px, 6vw, 80px); max-width: 1120px; margin: 0 auto; padding: clamp(40px, 7vw, 88px) var(--gutter) 96px; }
.doc-title { grid-column: 1 / -1; }
.doc-title h1 { margin-bottom: 12px; }
.doc-title p { color: var(--slate); margin: 0; }
.toc { position: sticky; top: 84px; align-self: start; font-size: 14px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--track); }
.toc a { display: block; padding: 5px 0 5px 14px; color: var(--slate); text-decoration: none; margin-left: -1px; border-left: 1px solid transparent; }
.toc a:hover { color: var(--platinum); border-left-color: var(--slate); }
.prose { max-width: var(--measure); }
.prose section { scroll-margin-top: 84px; padding-bottom: 8px; }
.prose h2 { font-size: 24px; font-weight: 400; margin: 40px 0 14px; }
.prose section:first-child h2 { margin-top: 0; }
.prose h3 { margin: 26px 0 8px; }
.prose p, .prose li { color: #C9CED6; }
.prose ul { padding-left: 20px; margin: 0 0 1em; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--platinum); font-weight: 600; }
.summary { background: var(--plate); border-radius: 20px; padding: 22px 24px; margin-bottom: 36px; }
.summary p:last-child, .summary ul:last-child { margin-bottom: 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 0 0 1.2em; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--track); color: #C9CED6; }
.prose th { color: var(--platinum); font-weight: 500; }

/* Support */
.contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; background: var(--plate); border-radius: 20px; padding: 22px 24px; margin-bottom: 40px; }
.contact p { margin: 0; color: var(--slate); }
.contact strong { color: var(--platinum); font-weight: 500; }
.button {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--platinum); color: var(--night);
  font-weight: 600; font-size: 15px; text-decoration: none;
  padding: 11px 20px; border-radius: 999px;
}
.button:hover { background: #fff; color: var(--night); }
details { border-bottom: 1px solid var(--track); }
details:first-of-type { border-top: 1px solid var(--track); }
summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 16px 0; color: var(--platinum); font-weight: 500; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--photon)); }
summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 1.5px solid var(--dim); border-bottom: 1.5px solid var(--dim); transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
details[open] summary::after { transform: rotate(-135deg) translate(-2px, -1px); }
details > div { padding: 0 0 18px 24px; }
details ol { margin: 0 0 10px; padding-left: 20px; }
details .note { font-size: 14px; color: var(--slate); }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--track); padding: 40px var(--gutter) 48px; color: var(--dim); font-size: 13px; }
.foot .wrap { display: grid; grid-template-columns: auto 1fr; gap: 20px 48px; }
.foot img { height: 22px; width: auto; opacity: .9; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: flex-end; font-size: 14px; }
.foot nav a { color: var(--slate); text-decoration: none; }
.foot nav a:hover { color: var(--platinum); }
.foot p { grid-column: 1 / -1; margin: 0; max-width: 90ch; line-height: 1.55; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .split, .split.flip, .health-grid { grid-template-columns: 1fr; }
  .split.flip .turn { order: -1; }
  .promise { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; }
  .doc { grid-template-columns: 1fr; }
  .toc { position: static; }
  .toc ol { display: flex; flex-wrap: wrap; gap: 4px 0; border-left: 0; }
  .toc a { padding: 4px 14px 4px 0; border: 0; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .top nav { gap: 14px; font-size: 14px; }
  .home .top .brand { display: none; }
  .hero { min-height: 0; }
  .hero-stage { min-height: 220px; }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .promise { grid-template-columns: 1fr; }
  .foot .wrap { grid-template-columns: 1fr; }
  .foot nav { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
