/* =========================================================================
   Roko — design system
   One accent (red), one type family (Inter), mono only for file names.
   Colours in OKLCH so lightness steps are even and gradients stay clean.
   ========================================================================= */

:root{
  color-scheme: dark;

  /* surfaces: each step up is a little lighter, which is how depth reads in dark mode */
  --bg:        oklch(0.145 0.006 25);
  --surface-1: oklch(0.185 0.007 25);
  --surface-2: oklch(0.222 0.008 25);
  --surface-3: oklch(0.262 0.009 25);

  /* text, all at least 4.5:1 on --bg and --surface-2 */
  --text:   oklch(0.97 0.004 25);
  --text-2: oklch(0.82 0.008 25);
  --text-3: oklch(0.68 0.010 25);

  /* the one accent */
  --accent:       oklch(0.63 0.205 27);
  --accent-hover: oklch(0.68 0.205 27);
  --accent-press: oklch(0.57 0.19 27);
  --accent-soft:  oklch(0.63 0.205 27 / 0.14);
  --on-accent:    oklch(0.99 0 0);
  --ok:           oklch(0.78 0.17 150);

  /* borders are translucent so they pick up whatever surface they sit on */
  --border:        oklch(1 0 0 / 0.08);
  --border-strong: oklch(1 0 0 / 0.14);
  --highlight:     inset 0 1px 0 oklch(1 0 0 / 0.06);

  /* shadows for raised things */
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 8px 24px -8px oklch(0 0 0 / 0.6), 0 2px 6px oklch(0 0 0 / 0.3);
  --shadow-3: 0 30px 80px -20px oklch(0 0 0 / 0.75), 0 8px 20px oklch(0 0 0 / 0.35);

  /* spacing scale (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;

  /* radii: nested corners use outer minus padding */
  --r-xl: 20px; --r-lg: 16px; --r-md: 12px; --r-sm: 8px; --r-xs: 6px; --r-full: 999px;

  /* type */
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --t-xs: 0.8125rem;  /* 13 */
  --t-sm: 0.875rem;   /* 14 */
  --t-md: 1rem;       /* 16 */
  --t-lg: 1.125rem;   /* 18 */
  --t-xl: clamp(1.375rem, 1.1rem + 0.9vw, 1.75rem);
  --t-2xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.5rem);
  --t-3xl: clamp(2.25rem, 1.4rem + 3.6vw, 4rem);

  /* motion: fast for feedback, slower for things entering */
  --ease-out:    cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --d-1: 120ms; --d-2: 200ms; --d-3: 320ms; --d-4: 520ms;

  --header-h: 64px;
  --max: 1160px;
}

/* ---------- base ---------- */
*,*::before,*::after{ box-sizing: border-box; }
html{ overflow-x: clip; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); background: var(--bg); }
body{
  margin: 0; background: var(--bg); color: var(--text-2);
  font: 400 var(--t-md)/1.6 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, video, svg{ display: block; max-width: 100%; }
a{ color: inherit; text-decoration: none; }
button{ font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3{ color: var(--text); margin: 0; font-weight: 650; letter-spacing: -0.022em; line-height: 1.1; text-wrap: balance; }
p{ margin: 0; text-wrap: pretty; }
::selection{ background: var(--accent); color: var(--on-accent); }
:focus-visible{ outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-xs); }
.num{ font-variant-numeric: tabular-nums; }
.sr{ position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip{ position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: var(--r-sm); background: var(--text); color: var(--bg); font-weight: 600; }
.skip:focus{ top: 12px; }

.wrap{ width: min(var(--max), 100% - 40px); margin-inline: auto; }
@media (max-width: 560px){ .wrap{ width: calc(100% - 32px); } }

.icon{ width: 1.125em; height: 1.125em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons ---------- */
.btn{
  --h: 48px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--h); padding: 0 20px; border-radius: var(--r-md);
  font-weight: 600; font-size: var(--t-md); line-height: 1; white-space: nowrap;
  transition: transform var(--d-1) var(--ease-out), background-color var(--d-2) ease, box-shadow var(--d-2) ease, color var(--d-2) ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0) scale(0.97); transition-duration: 60ms; }
.btn-primary{ background: var(--accent); color: var(--on-accent); box-shadow: var(--highlight), 0 1px 0 oklch(0.45 0.16 27), 0 6px 18px -6px oklch(0.63 0.205 27 / 0.6); }
.btn-primary:hover{ background: var(--accent-hover); }
.btn-primary:active{ background: var(--accent-press); }
.btn-ghost{ background: var(--surface-2); color: var(--text); box-shadow: var(--highlight), inset 0 0 0 1px var(--border); }
.btn-ghost:hover{ background: var(--surface-3); }
.btn-lg{ --h: 56px; padding: 0 22px; font-size: var(--t-md); border-radius: var(--r-lg); }
.btn-sm{ --h: 40px; padding: 0 14px; font-size: var(--t-sm); border-radius: 10px; }
/* the arrow nudges forward on hover: a small secondary action */
.btn .icon-go{ transition: transform var(--d-2) var(--ease-out); }
.btn:hover .icon-go{ transform: translate(2px, -2px); }
.btn:hover .icon-right{ transform: translateX(3px); }

/* copy buttons: the copy icon blurs out and the check blurs in */
.swap{ position: relative; display: inline-grid; place-items: center; width: 1.125em; height: 1.125em; }
.swap .icon{ grid-area: 1 / 1; transition: opacity var(--d-2) ease, filter var(--d-2) ease, transform var(--d-3) var(--ease-spring); }
.swap .icon-b{ opacity: 0; filter: blur(4px); transform: scale(0.5); }
.is-copied .swap .icon-a{ opacity: 0; filter: blur(4px); transform: scale(0.5); }
.is-copied .swap .icon-b{ opacity: 1; filter: blur(0); transform: scale(1); }
.label-swap{ display: inline-grid; }
.label-swap > span{ grid-area: 1 / 1; transition: opacity var(--d-2) ease, transform var(--d-3) var(--ease-out), filter var(--d-2) ease; }
.label-swap > span:last-child{ opacity: 0; transform: translateY(6px); filter: blur(3px); }
.is-copied .label-swap > span:first-child{ opacity: 0; transform: translateY(-6px); filter: blur(3px); }
.is-copied .label-swap > span:last-child{ opacity: 1; transform: none; filter: none; }

/* ---------- header ---------- */
.header{
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: oklch(0.145 0.006 25 / 0.72); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color var(--d-3) ease;
}
.header.scrolled{ border-bottom-color: var(--border); }
.header .wrap{ height: 100%; display: flex; align-items: center; gap: var(--s-5); }
.brand{ display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); font-weight: 650; letter-spacing: -0.01em; }
.brand img{ width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 0 0 1px var(--border-strong); }
.nav{ display: flex; gap: 2px; margin-left: auto; }
.nav a{ display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: var(--t-sm); font-weight: 500; color: var(--text-2); transition: color var(--d-2) ease, background-color var(--d-2) ease; }
.nav a:hover{ color: var(--text); background: var(--surface-2); }
.nav a[aria-current="true"]{ color: var(--text); }
@media (max-width: 760px){ .nav{ display: none; } .header .btn{ margin-left: auto; } }

/* ---------- sections ---------- */
.section{ padding-block: var(--s-10) 0; }
.section-head{ display: grid; gap: var(--s-3); max-width: 640px; margin-bottom: var(--s-7); }
.section-head h2{ font-size: var(--t-2xl); }
.section-head p{ font-size: var(--t-lg); color: var(--text-2); }
@media (max-width: 760px){ .section{ padding-top: var(--s-9); } .section-head{ margin-bottom: var(--s-6); } }

/* ---------- reveal on scroll ---------- */
.js .reveal{ opacity: 0; transform: translateY(16px); transition: opacity var(--d-4) var(--ease-out), transform var(--d-4) var(--ease-out); transition-delay: calc(var(--i, 0) * 60ms); }
.js .reveal.in{ opacity: 1; transform: none; }

/* ---------- loading states ---------- */
.skeleton{ position: relative; background: var(--surface-2); overflow: hidden; }
.skeleton::after{
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg in oklch, transparent, oklch(1 0 0 / 0.06), transparent);
  animation: shimmer 1.4s var(--ease-in-out) infinite;
}
.skeleton.loaded::after{ display: none; }
.skeleton img{ opacity: 0; transition: opacity var(--d-3) ease; }
.skeleton.loaded img{ opacity: 1; }
@keyframes shimmer{ to{ transform: translateX(100%); } }

.spinner{
  position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
  border: 3px solid oklch(1 0 0 / 0.18); border-top-color: var(--text);
  animation: spin 0.8s linear infinite; opacity: 0; transition: opacity var(--d-2) ease; pointer-events: none;
}
.is-loading .spinner{ opacity: 1; }
@keyframes spin{ to{ transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toast{
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 90;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px 12px 12px; border-radius: var(--r-md);
  background: var(--surface-3); color: var(--text); font-weight: 500; font-size: var(--t-sm);
  box-shadow: var(--highlight), inset 0 0 0 1px var(--border), var(--shadow-3);
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform var(--d-3) var(--ease-out), opacity var(--d-2) ease;
}
.toast .tick{ display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: oklch(0.2 0.05 150); }
.toast .tick .icon{ width: 14px; height: 14px; stroke-width: 2.5; }
.toast.show{ transform: translate(-50%, 0); opacity: 1; animation: toastIn var(--d-4) var(--ease-spring); }
@keyframes toastIn{ 0%{ transform: translate(-50%, 140%) scale(.9); } 60%{ transform: translate(-50%, -6px) scale(1.02); } 100%{ transform: translate(-50%, 0) scale(1); } }

/* ---------- footer ---------- */
.footer{ margin-top: var(--s-10); border-top: 1px solid var(--border); }
.footer .wrap{ display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4) var(--s-6); padding-block: var(--s-6) var(--s-7); font-size: var(--t-sm); color: var(--text-3); }
.footer nav{ display: flex; flex-wrap: wrap; gap: 4px var(--s-2); }
.footer nav a{ display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text-2); transition: color var(--d-2) ease, background-color var(--d-2) ease; }
.footer nav a:hover{ color: var(--text); background: var(--surface-2); }

/* ---------- legal pages ---------- */
.doc-hero{ padding-block: var(--s-9) var(--s-7); max-width: 720px; }
.doc-hero .crumb{ display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: var(--s-4); font-size: var(--t-sm); color: var(--text-3); transition: color var(--d-2) ease; }
.doc-hero .crumb:hover{ color: var(--text); }
.doc-hero .crumb .icon{ transform: rotate(180deg); transition: transform var(--d-2) var(--ease-out); }
.doc-hero .crumb:hover .icon{ transform: rotate(180deg) translateX(3px); }
.doc-hero h1{ font-size: var(--t-3xl); margin-bottom: var(--s-4); }
.doc-hero p{ font-size: var(--t-lg); }
.doc{ display: grid; grid-template-columns: 220px minmax(0, 720px); gap: var(--s-8); align-items: start; }
.toc{ position: sticky; top: calc(var(--header-h) + 24px); }
.toc ol{ list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: c; }
.toc a{ counter-increment: c; display: flex; gap: 10px; min-height: 36px; align-items: center; padding: 0 10px; border-radius: var(--r-sm); font-size: var(--t-sm); color: var(--text-3); transition: color var(--d-2) ease, background-color var(--d-2) ease; }
.toc a::before{ content: counter(c, decimal-leading-zero); font-variant-numeric: tabular-nums; color: var(--text-3); opacity: .7; }
.toc a:hover, .toc a.on{ color: var(--text); background: var(--surface-1); }
.clause{ padding-block: var(--s-6); border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 24px); }
.clause:first-child{ border-top: 0; padding-top: 0; }
.clause h2{ font-size: var(--t-xl); margin-bottom: var(--s-4); display: flex; gap: 14px; align-items: baseline; }
.clause h2 .n{ font-size: var(--t-sm); font-weight: 500; color: var(--accent); font-variant-numeric: tabular-nums; }
.clause p{ margin-bottom: var(--s-3); }
.clause ul{ margin: 0 0 var(--s-3); padding-left: 1.1em; display: grid; gap: 6px; }
.clause li::marker{ color: var(--accent); }
.clause strong{ color: var(--text); font-weight: 600; }
.doc-end{ margin-top: var(--s-7); padding: var(--s-6); border-radius: var(--r-xl); background: var(--surface-1); box-shadow: var(--highlight), inset 0 0 0 1px var(--border); display: grid; gap: var(--s-3); }
.doc-end h2{ font-size: var(--t-xl); }
.doc-end .row{ display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-2); }
@media (max-width: 860px){ .doc{ grid-template-columns: 1fr; gap: var(--s-6); } .toc{ position: static; } }

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{ animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .js .reveal{ opacity: 1; transform: none; }
}

/* rates table on the terms page: numbers line up in columns */
.rates{ margin: var(--s-4) 0; border-radius: var(--r-md); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.rates .row{ display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 5.5rem; gap: var(--s-3); padding: 12px 16px; border-top: 1px solid var(--border); font-size: var(--t-sm); }
.rates .row:first-child{ border-top: 0; background: var(--surface-1); color: var(--text-3); }
.rates .row:first-child b{ color: var(--text-3); font-weight: 500; }
.rates .row b{ color: var(--text); font-weight: 500; }
.rates .row span{ text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.callout{ margin: var(--s-4) 0; padding: 14px 16px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text-2); font-size: var(--t-sm); }
.callout b{ color: var(--text); font-weight: 600; }
@media (max-width: 480px){ .rates .row{ grid-template-columns: minmax(0, 1fr) 4.6rem 3.6rem; padding: 10px 12px; } }

/* 404 */
.lost{ min-height: calc(100svh - var(--header-h) - 120px); display: grid; place-content: center; justify-items: center; text-align: center; gap: var(--s-4); padding-block: var(--s-8); }
.lost .code{ font-size: clamp(5rem, 14vw, 9rem); font-weight: 750; letter-spacing: -0.05em; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.lost h1{ font-size: var(--t-2xl); }
.lost p{ font-size: var(--t-lg); max-width: 40ch; }
.lost .row{ display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); margin-top: var(--s-3); }
