/*
 * recollectapp.co.uk — the public landing page.
 * Colours, type and motion mirror the app's "stoic monochrome" tokens
 * (mobile/ReCollectApp/src/theme/tokens.ts): warm paper neutrals, Spectral for
 * display and quotes, system sans for chrome, brass reserved for Premium only.
 *
 * Motion: every animation is gated on `html.motion`, which site.js sets only when
 * the visitor hasn't asked for reduced motion. Only opacity / transform / filter
 * animate, so nothing reflows. Content is fully visible without JS.
 */

:root {
  --background: #F7F4EC;
  --background-elevated: #EFEBE0;
  --surface: #FBF9F3;
  --border: #E3DED3;
  --border-strong: #D6D0C3;
  --text: #1A1916;
  --text-muted: #403C34;
  --text-subtle: #8C8678;
  --accent: #1A1916;
  --on-accent: #F7F4EC;
  --premium-fill: #F3EBD8;
  --premium-text: #7A5E2A;
  --premium-border: #D9C9A3;
  --premium-sheen: #FFFFFF;
  --ring-outer: #E3DED3;
  --ring-inner: #B7B2A6;
  --shadow: rgba(26, 25, 22, 0.16);

  --serif: 'Spectral', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  /* motion.duration.{fast,base,slow}, motion.translate.enter, motion.stagger.item */
  --fast-ms: 260ms;
  --base-ms: 500ms;
  --slow-ms: 800ms;
  --enter-travel: 12px;
  --stagger-ms: 90ms;
  /* motion.sheen / motion.invitation */
  --sheen-delay: 450ms;
  --sheen-ms: 1100ms;
  --breathe-ms: 2800ms;
  /* How long each example quote stays before the next one resurfaces. */
  --quote-interval: 9s;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #15140F;
    --background-elevated: #1A1916;
    --surface: #211F1A;
    --border: #2E2B24;
    --border-strong: #403C34;
    --text: #F7F4EC;
    --text-muted: #D6D0C3;
    --text-subtle: #8C8678;
    --accent: #F7F4EC;
    --on-accent: #15140F;
    --premium-fill: #2A2316;
    --premium-text: #D4B77C;
    --premium-border: #6E5932;
    --premium-sheen: #D4B77C;
    --ring-outer: #2E2B24;
    --ring-inner: #5C584E;
    --shadow: rgba(0, 0, 0, 0.55);
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--text); color: var(--background); }

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 24px; }

.overline {
  margin: 0;
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 0;
  border-bottom: 1px solid transparent;
  transition:
    background-color var(--base-ms) ease,
    border-color var(--base-ms) ease,
    padding var(--base-ms) var(--ease-out);
}
.site-header.is-scrolled {
  padding: 12px 0;
  background: color-mix(in srgb, var(--background) 84%, transparent);
  border-bottom-color: var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 32px; height: 32px; transition: transform var(--slow-ms) var(--ease-out); }
.brand:hover img { transform: rotate(-8deg) scale(1.04); }
.brand span { font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: 0.01em; }
.lang { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.lang a, .lang span {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text-muted);
  transition: background-color var(--fast-ms) ease, color var(--fast-ms) ease;
}
.lang a:hover { background: var(--background-elevated); color: var(--text); }
.lang [aria-current="true"] { background: var(--accent); color: var(--on-accent); }

/* Header marks follow the colour scheme. */
.mark-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .mark-light { display: none; }
  .mark-dark { display: inline; }
}

/* ── Hero ───────────────────────────────────────────────── */
.hero { position: relative; overflow: hidden; padding: 56px 0 88px; text-align: center; }
.hero .wrap { position: relative; z-index: 1; }

/* Faint concentric rings behind the mark — the widget art's motif. */
.hero-field {
  position: absolute;
  left: 50%;
  top: 112px;
  width: 960px;
  height: 960px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at center, #000 28%, transparent 68%);
  mask-image: radial-gradient(circle at center, #000 28%, transparent 68%);
}
.hero-field circle {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
}
.hero-field .orbit { stroke: var(--border-strong); stroke-dasharray: 1 9; }

.hero-mark { display: block; width: 112px; height: 112px; margin: 0 auto 28px; overflow: visible; }
.hero-mark .ring { fill: none; stroke-width: 1.6; transform-box: fill-box; transform-origin: center; transform: rotate(-90deg); }
.hero-mark .ring-outer { stroke: var(--ring-outer); }
.hero-mark .ring-inner { stroke: var(--ring-inner); }
.hero-mark .book { transform-box: fill-box; transform-origin: center; }
.hero-mark .book path { fill: var(--surface); stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.hero-mark .book line { stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; }

.hero h1 {
  margin: 16px auto 20px;
  max-width: 14ch;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 7vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.lead { margin: 0 auto; max-width: 34em; font-size: 18px; line-height: 1.6; color: var(--text-muted); }
.status {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 12px;
  margin-top: 32px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
}
.status small { font-weight: 400; opacity: 0.75; font-size: 13px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Today card ─────────────────────────────────────────── */
.today { padding: 0 0 96px; }
.today-card {
  max-width: 580px;
  margin: 0 auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.today-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dots { display: flex; gap: 2px; }
.dot {
  position: relative;
  width: 30px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.dot::before, .dot::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 11px;
  height: 2px;
  border-radius: 999px;
  background: var(--border);
  transition: background-color var(--base-ms) ease;
}
.dot::after { background: var(--text); transform-origin: left; transform: scaleX(0); }
.dot:hover::before { background: var(--border-strong); }
.dot[aria-current="true"]::after { transform: scaleX(1); }

.dots { align-items: center; }
.carousel-toggle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--text-subtle);
  cursor: pointer;
  transition: color var(--fast-ms) ease, border-color var(--fast-ms) ease, transform var(--fast-ms) var(--ease-out);
}
.carousel-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.carousel-toggle:active { transform: scale(0.94); }
.carousel-toggle svg { width: 10px; height: 10px; overflow: visible; }
.carousel-toggle .icon-pause { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.carousel-toggle .icon-play { fill: currentColor; display: none; }
.carousel-toggle[aria-pressed="true"] .icon-pause { display: none; }
.carousel-toggle[aria-pressed="true"] .icon-play { display: inline; }

.slides { display: grid; }
.slide { grid-area: 1 / 1; margin: 0; visibility: hidden; }
.slide.is-current { visibility: visible; }
/* Reduced motion: quotes still change, as a quick fade with no travel. */
.js:not(.motion) .slide { opacity: 0; transition: opacity 200ms ease, visibility 0s linear 200ms; }
.js:not(.motion) .slide.is-current { opacity: 1; transition: opacity 200ms ease; }
.slide blockquote { margin: 16px 0 20px; }
.slide blockquote p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 30px);
  line-height: 1.35;
  text-wrap: balance;
}
.attribution { margin: 0; font-size: 14px; font-weight: 600; }
.attribution span { display: block; font-weight: 400; font-style: italic; color: var(--text-subtle); font-size: 13px; }
.reading {
  margin-top: 24px;
  padding: 20px;
  background: var(--background-elevated);
  border-radius: var(--radius-md);
}
.reading p:last-child { margin: 8px 0 0; color: var(--text-muted); line-height: 1.6; }

/* ── Sections ───────────────────────────────────────────── */
section h2 {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 4.5vw, 40px);
  line-height: 1.15;
  text-wrap: balance;
}
.section { padding: 80px 0; border-top: 1px solid var(--border); }
.section-head { max-width: 36em; margin-bottom: 40px; }
.section-head .overline { display: flex; align-items: center; gap: 12px; }
.section-head .overline::before {
  content: '';
  width: 32px;
  height: 1px;
  background: currentColor;
  transform-origin: left;
}
.section-head p { margin: 16px 0 0; color: var(--text-muted); font-size: 17px; line-height: 1.6; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.feature, .plan, .today-card {
  transition:
    transform var(--slow-ms) var(--ease-out),
    box-shadow var(--slow-ms) var(--ease-out),
    border-color var(--base-ms) ease;
}
@media (hover: hover) {
  .feature:hover, .plan:hover, .today-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: 0 24px 48px -28px var(--shadow);
  }
  .plan.premium:hover { border-color: var(--premium-text); }
}
.feature {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.feature .overline { transition: color var(--base-ms) ease, letter-spacing var(--slow-ms) var(--ease-out); }
.feature:hover .overline { color: var(--text); letter-spacing: 0.24em; }
.feature h3 { margin: 12px 0 8px; font-family: var(--serif); font-weight: 500; font-size: 21px; line-height: 1.25; }
.feature p { margin: 0; color: var(--text-muted); font-size: 15px; line-height: 1.6; }

/* ── Plans ──────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.plan {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.plan h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 26px; }
.plan .price { margin: 6px 0 20px; color: var(--text-subtle); font-size: 15px; }
.plan ul { margin: 0; padding: 0; list-style: none; }
.plan li {
  position: relative;
  padding: 10px 0 10px 26px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-muted);
}
.plan li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 17px;
  width: 10px;
  height: 5px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
}
.premium-pill {
  position: relative;
  overflow: hidden;
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--premium-border);
  border-radius: 999px;
  background: var(--premium-fill);
  color: var(--premium-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.premium-pill::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -18px;
  width: 18px;
  background: linear-gradient(90deg, transparent, var(--premium-sheen), transparent);
  opacity: 0;
  pointer-events: none;
}
.plan.premium { border-color: var(--premium-border); }
.plan.premium h3 { margin-top: 12px; }
.plan-note { margin: 24px 0 0; color: var(--text-subtle); font-size: 14px; line-height: 1.6; }

/* ── Principles ─────────────────────────────────────────── */
.principles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 32px; }
.principle { padding-top: 20px; border-top: 1px solid var(--border); }
.principle p:first-child { margin: 0 0 8px; font-family: var(--serif); font-size: 20px; line-height: 1.35; }
.principle p:last-child { margin: 0; color: var(--text-muted); font-size: 15px; line-height: 1.6; }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer { padding: 48px 0 56px; border-top: 1px solid var(--border); color: var(--text-subtle); font-size: 14px; }
.site-footer .wrap { display: grid; gap: 16px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.site-footer nav a {
  color: var(--text-muted);
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) left bottom / 0% 1px no-repeat;
  transition: background-size var(--base-ms) var(--ease-out), color var(--fast-ms) ease;
}
.site-footer nav a:hover { color: var(--text); background-size: 100% 1px; }
.site-footer p { margin: 0; line-height: 1.6; }

/* ════════════════════════════════════════════════════════
 * Motion — only when html.motion is set (no reduced-motion preference).
 * ════════════════════════════════════════════════════════ */

@keyframes page-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(var(--enter-travel)); } }
@keyframes rise-soft { from { opacity: 0; transform: translateY(6px); } }
@keyframes word-in { from { opacity: 0; transform: translateY(0.35em); filter: blur(8px); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes book-in { from { opacity: 0; transform: translateY(4px) scale(0.92); } }
@keyframes breathe { 50% { transform: scale(1.035); } }
@keyframes field-in { from { opacity: 0; transform: scale(0.88); } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes dot-breathe { to { opacity: 0.35; } }
@keyframes line-in { from { transform: scaleX(0); } }
@keyframes sheen { from { left: -18px; opacity: 0.35; } to { left: 100%; opacity: 0.35; } }
@keyframes dot-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes quote-in { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } }
@keyframes quote-out { to { opacity: 0; transform: translateY(-6px); filter: blur(4px); } }
@keyframes drift { to { opacity: 0.15; transform: translateY(48px) scale(0.86); } }

.motion body { animation: page-in 320ms ease-out both; }
.motion.is-leaving body { opacity: 0.15; transition: opacity 160ms ease-in; }

/* Scroll-in entrances: hidden until revealed, then rise once. `backwards` fill
   means the finished state is the element's own style, so hover transforms
   still work afterwards. */
.motion .reveal:not(.words):not(.is-visible) { opacity: 0; }
.motion .reveal.is-visible:not(.words) {
  animation: rise var(--base-ms) var(--ease-out) backwards;
  animation-delay: calc(var(--base, 0ms) + var(--i, 0) * var(--stagger-ms));
}
.motion .hero { --base: 650ms; }

/* Headline: word by word, out of a soft blur. */
.words .w { display: inline-block; }
.motion .words:not(.is-visible) .w { opacity: 0; }
.motion .words.is-visible .w {
  animation: word-in var(--slow-ms) var(--ease-out) backwards;
  animation-delay: calc(var(--base, 0ms) + var(--i, 0) * var(--stagger-ms) + var(--w, 0) * 80ms);
}

/* The mark draws itself: rings trace round, the book settles, then breathes. */
.motion .hero-mark .ring { stroke-dasharray: 1; animation: draw 1.6s var(--ease-in-out) both; }
.motion .hero-mark .ring-inner { animation-delay: 0.25s; }
.motion .hero-mark .book {
  animation:
    book-in 0.9s var(--ease-out) 0.6s both,
    breathe 6s ease-in-out 1.8s infinite;
}
.motion .hero-field circle { animation: field-in 2.4s var(--ease-out) both; }
.motion .hero-field circle:nth-child(2) { animation-delay: 0.15s; }
.motion .hero-field circle:nth-child(3) {
  animation: field-in 2.4s var(--ease-out) 0.3s both, orbit 180s linear infinite;
}
.motion .hero-field circle:nth-child(4) { animation-delay: 0.45s; }

/* As the page scrolls away, the mark recedes. */
@supports (animation-timeline: scroll()) {
  .motion .hero-mark {
    animation: drift linear both;
    animation-timeline: scroll(root);
    animation-range: 0 70vh;
  }
}

.motion .status-dot { animation: dot-breathe var(--breathe-ms) ease-in-out infinite alternate; }

/* Section overline rule draws in from the left. */
.motion .section-head:not(.is-visible) .overline::before { transform: scaleX(0); }
.motion .section-head.is-visible .overline::before { animation: line-in var(--slow-ms) var(--ease-out) 200ms backwards; }

/* Plan rows follow their card in, one by one. */
.motion .plan:not(.is-visible) li { opacity: 0; }
.motion .plan.is-visible li {
  animation: rise-soft var(--base-ms) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * var(--stagger-ms) + 250ms + var(--j, 0) * 70ms);
}

/* Premium's brass pill catches the light once. */
.motion .plan.premium.is-visible .premium-pill::after {
  animation: sheen var(--sheen-ms) ease-in-out 1;
  animation-delay: calc(var(--i, 0) * var(--stagger-ms) + var(--base-ms) + var(--sheen-delay));
}

/* Today card: quotes resurface in turn; the current dot fills as its time runs. */
.motion .slide { transition: visibility 0s linear 600ms; }
.motion .slide.is-current { transition: none; }
.motion .slide.is-current > * { animation: quote-in 900ms var(--ease-out) backwards; }
.motion .slide.is-current > :nth-child(2) { animation-delay: 120ms; }
.motion .slide.is-current > :nth-child(3) { animation-delay: 240ms; }
.motion .slide.is-leaving > * { animation: quote-out 600ms var(--ease-in-out) forwards; }
.motion [data-carousel].is-auto .dot[aria-current="true"]::after {
  animation: dot-progress var(--quote-interval) linear both;
}
.motion [data-carousel].is-paused .dot::after { animation-play-state: paused; }

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 32px 0 64px; }
  .hero-field { top: 88px; width: 720px; height: 720px; }
  .today-card, .plan { padding: 22px; }
  .section { padding: 64px 0; }
}
