/* The rules: STANDARDS.md, checked by tools/check.mjs */
@layer tokens, base, layout, part, exception;

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

@layer tokens {
  :root {
    /* grounds */
    --ground: #000000;
    --card: #0d1116;
    --screen: #05070a;
    --raised: #1c222b;
    --line: #1f2630;
    --edge: #2b323d;
    /* inks */
    --ink: #f2f4f7;
    --soft: #c3cad5;
    --muted: #8a94a6;
    --dim: #4a5260;
    --paper: #dfe4ea;
    /* what a colour means */
    --buy: #00d68f;
    --trim: #ff4d5e;
    --mesh: #4886fe;
    --mesh-ink: #7fb0ff;
    --on-buy: #001b12;
    --mesh-risk: #f75c66;
    --mesh-sell: #0da484;
    --mesh-sell-ink: #3fd3ae;
    /* a chart's inks: charts.js reads these */
    --chart-dip: #2be3a6;
    --chart-rip: #ff6b78;
    --chart-wick: #aab3c0;
    --chart-up: #dfe4ea;
    --chart-down: #6b7686;
    --chart-halo: #000000;
    /* type: six sizes, and three weights with the body's */
    --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --t-small: 0.875rem;
    --t-body: 1rem;
    --t-lead: 1.125rem;
    --t-head: 1.375rem;
    --t-title: clamp(1.875rem, 1.2rem + 2vw, 2.625rem);
    --t-hero: clamp(2.375rem, 1.2rem + 3.6vw, 3.75rem);
    --w-strong: 600;
    --w-title: 800;
    /* space: nine steps */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-7: 3rem;
    --s-8: 4.5rem;
    --s-9: 6rem;
    /* corners: three */
    --r-small: 0.5rem;
    --r-card: 1rem;
    --r-pill: 62rem;
    --hair: 0.0625rem;
    /* widths */
    --page: 76.25rem;
    --gutter: var(--s-5);
    --words: 46rem;
    --hero-words: 32rem;
    --plan: 34rem;
    --mini: 14.25rem;
    --logo: 2.5rem;
    --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  }
}

@layer base {
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body { margin: 0; background: var(--ground); color: var(--soft); font-family: var(--font); font-size: var(--t-body); line-height: 1.5; overflow-x: clip; }
  main { overflow-x: clip; }
  a { color: inherit; text-decoration: none; }
  img, svg { display: block; max-width: 100%; height: auto; }
  h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
  ul, ol { list-style: none; }
  h1, h2, h3, b { color: var(--ink); }
  b { font-weight: var(--w-strong); }
  h1 { font-size: var(--t-hero); line-height: 1.02; letter-spacing: -0.035em; font-weight: var(--w-title); margin-bottom: var(--s-4); }
  h2 { font-size: var(--t-title); line-height: 1.08; letter-spacing: -0.03em; font-weight: var(--w-title); margin-bottom: var(--s-3); }
  h3 { font-size: var(--t-head); line-height: 1.2; letter-spacing: -0.01em; }
  :focus-visible { outline: var(--s-1) solid var(--buy); outline-offset: var(--s-1); border-radius: var(--r-small); }
}

@layer layout {
  .in { width: min(var(--page), 100% - 2 * var(--gutter)); margin-inline: auto; }
  .block { padding-top: var(--s-8); scroll-margin-top: var(--s-2); }
  .grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* cards whose parts line up across */
  .level { row-gap: 0; }
  .level > .card { display: grid; grid-row: span 4; grid-template-rows: subgrid; justify-items: start; }
  .level > .card > .chart, .level > .card > .inset { width: 100%; }
  h2 + .grid { margin-top: var(--s-5); }
  .split { display: grid; gap: var(--s-7); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

  .top { display: flex; align-items: center; gap: var(--s-6); padding-block: var(--s-5); }
  .top nav { display: flex; gap: var(--s-6); margin-left: auto; }
  .to-x { padding: var(--s-3); margin: calc(-1 * var(--s-3)); color: var(--ink); }
  .to-x svg { width: 1.25em; height: 1.25em; fill: currentColor; }
  .top nav a { color: var(--soft); }
  .top nav a:hover { color: var(--ink); }

  .hero { display: grid; grid-template-columns: minmax(0, var(--hero-words)) minmax(0, 1fr); align-items: center; }
  .hero h1 { white-space: nowrap; }
  .hero > :first-child { position: relative; z-index: 1; }
  .hero + section { position: relative; z-index: 1; }
  .actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }
  .trust { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); margin-top: var(--s-5); font-size: var(--t-small); color: var(--soft); }

  .final { position: relative; isolation: isolate; margin-top: var(--s-9); padding-block: var(--s-8); text-align: center; }
  .final::before { content: ""; position: absolute; z-index: -1; inset: 0 calc(50% - 50vw); background: var(--buy); }
  .final .actions { justify-content: center; }
  .final .lead { margin-inline: auto; margin-bottom: var(--s-5); }
  .final :focus-visible { outline-color: var(--on-buy); }
  .foot { display: grid; gap: var(--s-3); border-top: var(--hair) solid var(--line); padding-block: var(--s-5) var(--s-6); font-size: var(--t-small); color: var(--muted); }
}

@layer part {
  .skip { position: absolute; left: -100vw; top: var(--s-2); z-index: 5; padding: var(--s-2) var(--s-4); border-radius: var(--r-small); background: var(--ink); color: var(--ground); font-weight: var(--w-strong); }
  .skip:focus { left: var(--s-2); }

  /* The logo: one drawing, logo.svg. The page never builds it from text. */
  .logo img { height: var(--logo); width: auto; }

  /* THE GROUND: the cells, behind the top of the home page only; drawn by tools/make_logo.mjs */
  body:has(.hero)::before { content: ""; position: absolute; z-index: -1; inset: 0 0 auto; aspect-ratio: 1440 / 820; background: linear-gradient(transparent 62%, var(--ground)), url("ground-top.svg") top / 100% auto no-repeat; }
  /* THE LIT CELL: the full stop of the headline */
  .stop { display: inline-block; margin-left: 0.07em; filter: drop-shadow(0 0 0.2em var(--buy)); }
  .stop::before { content: ""; display: block; width: 0.27em; height: 0.31em; background: var(--buy); clip-path: var(--hex); }

  .btn { display: inline-block; padding: var(--s-3) var(--s-5); border: var(--hair) solid var(--buy); border-radius: var(--r-pill); background: var(--buy); color: var(--on-buy); font-weight: var(--w-strong); white-space: nowrap; transition: filter 0.15s ease; }
  .btn:hover { filter: brightness(1.1); }
  .btn.quiet { background: transparent; border-color: var(--edge); color: var(--ink); }
  .btn.quiet:hover { border-color: var(--muted); filter: none; }
  .btn.dark { background: var(--on-buy); border-color: var(--on-buy); color: var(--ink); }
  .btn.wide { display: block; text-align: center; }

  .eyebrow { margin-bottom: var(--s-2); color: var(--buy); font-size: var(--t-small); font-weight: var(--w-strong); letter-spacing: 0.14em; text-transform: uppercase; }
  .lead { max-width: var(--words); margin-bottom: var(--s-6); font-size: var(--t-lead); }
  .sub { margin-bottom: var(--s-5); font-size: var(--t-lead); }
  .note { margin-top: var(--s-3); font-size: var(--t-small); color: var(--muted); }
  .follow { align-items: center; margin-top: var(--s-6); }
  .link { color: var(--ink); text-decoration: underline; text-underline-offset: 0.15em; }

  /* ONE CARD: the tiles, the steps, the price, the questions */
  .card { padding: var(--s-5); border: var(--hair) solid var(--line); border-radius: var(--r-card); background: var(--card); }
  .card h3 { margin-block: var(--s-3) var(--s-2); }
  .card > h3:first-child { margin-top: 0; }
  /* THE GREEN: the price and the close */
  .band { margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-5)) var(--s-4); padding: var(--s-5); border-radius: var(--r-card) var(--r-card) 0 0; background: var(--buy); }
  .card .band h3 { margin-top: 0; }
  .inset { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-small); background: var(--screen); }

  /* ONE FRAME: every chart, and every picture of one */
  .frame { overflow: hidden; border: var(--hair) solid var(--line); border-radius: var(--r-card); background: var(--screen); }
  .frame-bar { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); border-bottom: var(--hair) solid var(--line); font-size: var(--t-small); }
  .frame-bar button { margin-left: auto; }

  /* a chart holds its shape before it is drawn */
  .chart { aspect-ratio: 1000 / 500; background: var(--screen); }
  .chart svg, .chart img { width: 100%; height: 100%; }
  .chart img { object-fit: cover; }
  .chart text { font-family: var(--font); }
  .chart.short { aspect-ratio: 1000 / 430; margin-top: var(--s-3); border-radius: var(--r-small); overflow: hidden; }
  .sig { opacity: 0; transform: scale(0.2); transform-box: fill-box; transform-origin: center; transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
  .sig.on { opacity: 1; transform: scale(1); }

  /* THE MESH, drawn by mesh.js */
  .plan { height: var(--plan); background: var(--ground); }
  .plan canvas, .plan img { display: block; width: 100%; height: 100%; object-fit: cover; }
  /* its words and calculator, where the chart is empty */
  .mesh-panel { position: relative; }
  .says { position: absolute; left: 57%; right: var(--s-5); top: var(--s-5); }
  .says h3 { margin-bottom: var(--s-2); }
  .mini { position: absolute; left: var(--s-5); bottom: var(--s-6); width: var(--mini); overflow: hidden; border: var(--hair) solid var(--muted); border-radius: var(--r-small); background: var(--card); font-size: var(--t-small); }
  .mini p { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-3); }
  .mini b { color: var(--ink); }
  .mini-top { border-bottom: var(--hair) solid var(--line); }
  .mini .mini-foot { border-top: var(--hair) solid var(--line); background: var(--screen); color: var(--muted); }
  .mini dl { padding: var(--s-1) var(--s-3); }
  .mini dl div { display: flex; align-items: center; justify-content: space-between; padding-block: calc(var(--s-1) / 2); line-height: 1.5; }
  .mini dt::before { display: inline-block; box-sizing: border-box; width: 0.65em; height: 0.65em; margin-right: 0.5em; }
  .mini dd { min-width: 5em; padding-inline: var(--s-2); border: var(--hair) solid var(--edge); border-radius: calc(var(--r-small) / 2); background: var(--screen); color: var(--ink); text-align: right; }
  .at-entry::before { content: ""; background: var(--mesh); }
  .at-risk::before { content: ""; background: var(--mesh-risk); }
  .at-exit::before { content: ""; border: 0.15em solid var(--mesh-sell); border-radius: 50%; }
  .tabs { display: flex; overflow: hidden; border: var(--hair) solid var(--edge); border-radius: calc(var(--r-small) / 2); line-height: 1.4; }
  .tabs > * { padding-inline: var(--s-2); }
  .mini .tabs b { background: var(--paper); color: var(--ground); }
  .exits .says { top: auto; bottom: var(--s-6); }
  .exits .mini { bottom: auto; top: var(--s-4); }

  .keys { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-bottom: var(--s-5); }
  .keys svg, h3 svg { display: inline; width: 0.9em; height: 0.9em; margin-right: 0.45em; vertical-align: -0.05em; }
  h3 svg { width: 0.75em; height: 0.75em; margin-right: 0.35em; vertical-align: 0; }
  h3 svg + svg { margin-left: -0.05em; }

  .replay { padding: var(--s-1) var(--s-3); border: var(--hair) solid var(--edge); border-radius: var(--r-pill); background: transparent; color: var(--ink); font: var(--w-strong) var(--t-small) var(--font); cursor: pointer; }
  .replay::before { content: ""; display: inline-block; width: 0.6em; height: 0.7em; margin-right: 0.5em; background: var(--buy); clip-path: polygon(0 0, 100% 50%, 0 100%); }
  .replay:hover { border-color: var(--muted); }

  .stats { display: grid; grid-template-columns: repeat(4, 1fr); border-block: var(--hair) solid var(--line); margin-top: var(--s-5); text-align: center; }
  .stats div { display: flex; flex-direction: column-reverse; justify-content: flex-end; padding: var(--s-5) var(--s-2); }
  .stats dt { font-size: var(--t-small); color: var(--muted); }
  .stats dd { font-size: var(--t-title); line-height: 1.2; font-weight: var(--w-title); letter-spacing: -0.02em; color: var(--ink); }

  .words { max-width: calc(var(--words) + 2 * var(--gutter)); margin-inline: auto; padding-bottom: var(--s-8); }
  .words h1 { font-size: var(--t-title); }
  .words h2 { font-size: var(--t-head); letter-spacing: -0.01em; line-height: 1.2; margin-block: var(--s-6) var(--s-2); }
  .links { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }

  .ticks { margin-block: var(--s-3) var(--s-5); }
  .ticks li { position: relative; padding: var(--s-1) 0 var(--s-1) var(--s-5); }
  .ticks li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 0.65em; height: 0.75em; background: var(--buy); clip-path: var(--hex); }

  .steps { counter-reset: step; }
  .steps li { counter-increment: step; }
  .steps li::before { content: counter(step); display: grid; place-items: center; width: var(--s-6); height: var(--s-6); margin-bottom: var(--s-3); border-radius: 50%; background: var(--raised); color: var(--ink); font-weight: var(--w-strong); }

  .faq dt { color: var(--ink); font-weight: var(--w-strong); margin-bottom: var(--s-1); }
  .amount { font-size: var(--t-hero); line-height: 1.15; font-weight: var(--w-title); letter-spacing: -0.03em; color: var(--ink); }
  .amount small { font-size: var(--t-lead); font-weight: 400; letter-spacing: 0; color: var(--muted); }

  /* The laptop (tools/make_hero.py); the page on its screen is sized by the screen (cqw) */
  .laptop { position: relative; width: 106%; margin: 0 -6% -18% 0; }
  .laptop > img { width: 100%; }
  .screen { position: absolute; left: 8.6%; top: 7.6%; width: 82.6%; height: 52.75%; container-type: inline-size; background: var(--ground); overflow: hidden; }
  .screen .chart { position: absolute; inset: 5.8cqw 0 0 4.6cqw; aspect-ratio: auto; background: var(--ground); }
  .app { font-size: 1.42cqw; color: var(--chart-wick); white-space: nowrap; }
  .app span { line-height: 1; }
  .app-bar { display: flex; align-items: center; gap: 1.1em; height: 4em; padding: 0 1em; }
  .app-bar img { width: 2.6em; height: 2.6em; }
  .app .search { border: 0.07em solid var(--edge); background: var(--card); border-radius: 1.2em; padding: 0.55em 2.6em 0.55em 1em; color: var(--ink); }
  .times { display: flex; gap: 0.85em; color: var(--dim); }
  .times .lit { color: var(--ink); }
  .times .on { color: var(--ground); background: var(--ink); border-radius: 0.3em; padding: 0.4em; margin-block: -0.4em; font-weight: var(--w-strong); }
  .markets { display: flex; gap: 0.5em; margin-left: auto; }
  .markets span { border: 0.1em solid var(--edge); border-radius: 0.7em; padding: 0.5em 0.8em; }
  .markets .on { border-color: var(--buy); color: var(--ink); }
  .views { display: flex; border: 0.07em solid var(--edge); border-radius: 0.4em; overflow: hidden; }
  .views span { padding: 0.55em 0.9em; color: var(--ink); background: var(--card); }
  .views .on { background: var(--paper); color: var(--ground); }
  .app .dim { color: var(--muted); }
  .rail { position: absolute; z-index: 1; left: 0; top: 4.4em; bottom: 0.6em; width: 3.2em; display: flex; flex-direction: column; align-items: center; justify-content: space-between; color: var(--paper); }
  .rail svg { width: 1.5em; height: 1.5em; fill: none; stroke: currentColor; stroke-width: 1.6; }
  .rail [fill^="#"] { stroke: none; }
  .app-name { position: absolute; z-index: 1; left: 3.6em; top: 4.6em; display: flex; align-items: center; gap: 0.5em; color: var(--ink); font-weight: var(--w-strong); }
  .app-name i { width: 0.8em; height: 0.9em; background: var(--mesh); clip-path: polygon(0 0, 100% 0, 70% 50%, 100% 100%, 0 100%); }
}

@layer exception {
  .band, .band *, .final h2, .final .lead, .final .quiet { color: var(--on-buy); border-color: var(--on-buy); }
  .buy { color: var(--buy); }
  .trim { color: var(--trim); }
  .eyebrow.mesh { color: var(--mesh-ink); }
  .meshes .frame { border: calc(2 * var(--hair)) solid var(--muted); background: var(--ground); }
  .meshes .frame-bar { border-bottom: 0; padding-bottom: 0; color: var(--muted); }
  .mesh-buy { color: var(--mesh); }
  .mesh-sell { color: var(--mesh-sell); }
  .mesh-red { color: var(--mesh-risk); }
  .foot .logo img { height: var(--s-5); }

  @media (min-width: 110rem) { body:has(.hero)::before { aspect-ratio: 2200 / 940; background-image: linear-gradient(transparent 62%, var(--ground)), url("ground-top-wide.svg"); } }
  @media (max-width: 75rem) { .meshes { grid-template-columns: minmax(0, 1fr); } }
  @media (max-width: 62rem) {
    .level { row-gap: var(--s-4); }
    .level > .card { grid-row: auto; grid-template-rows: none; }
    body:has(.hero)::before { aspect-ratio: 780 / 1700; background-image: linear-gradient(transparent 62%, var(--ground)), url("ground-top-tall.svg"); }
    .hero, .split, .grid.three { grid-template-columns: minmax(0, 1fr); }
    .split { gap: var(--s-5); }
    .laptop { width: 100%; margin: var(--s-5) 0 -16%; }
    .top nav { display: none; }
    .to-x { margin-left: auto; }
  }
  /* THE PHONE */
  @media (max-width: 40rem) {
    :root { --logo: var(--s-6); }
    .top { padding-block: var(--s-5) var(--s-7); }
    .top .btn { display: none; }
    h1 { line-height: 1.14; margin-bottom: var(--s-5); }
    .sub { margin-bottom: var(--s-6); line-height: 1.6; }
    .actions { gap: var(--s-4); }
    .actions .btn { flex: 1 1 100%; padding-block: var(--s-4); text-align: center; }
    .trust { flex-direction: column; gap: var(--s-3); margin-top: var(--s-6); font-size: var(--t-body); }
    .laptop { margin-top: var(--s-7); }
    .stats { grid-template-columns: repeat(2, 1fr); margin-top: var(--s-7); padding-block: var(--s-4); }
    .block { padding-top: var(--s-9); }
    .eyebrow { margin-bottom: var(--s-4); }
    h2 { line-height: 1.16; margin-bottom: var(--s-4); text-wrap: balance; }
    body:has(.hero)::before { background-image: linear-gradient(transparent 62%, var(--ground)), linear-gradient(transparent 4%, color-mix(in srgb, var(--ground) 62%, transparent) 16%), url("ground-top-tall.svg"); background-size: 100% auto; }
    h2 + .grid, h2 + .keys { margin-top: var(--s-6); }
    .lead { margin-bottom: var(--s-7); line-height: 1.6; }
    .grid { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
    .level { row-gap: var(--s-5); }
    .card p { line-height: 1.6; }
    .chart.short { margin-top: var(--s-5); }
    .inset { margin-top: var(--s-4); padding: var(--s-4); }
    .keys { flex-direction: column; gap: var(--s-3); margin-bottom: var(--s-6); }
    .keys li { padding-left: 1.35em; text-indent: -1.35em; }
    .frame-bar { padding-block: var(--s-3); }
    .note, .follow { margin-top: var(--s-6); }
    .follow span { flex: 1 1 100%; }
    .ticks li { padding-block: var(--s-2); }
    .split { gap: var(--s-5); }
    .split .lead { margin-bottom: 0; }
    .list { gap: 0; border: var(--hair) solid var(--line); border-radius: var(--r-card); background: var(--card); overflow: hidden; }
    .list > .card { border-width: 0 0 var(--hair); border-radius: 0; }
    .list > .card:last-child { border-bottom: 0; }
    .list h3 { font-size: var(--t-lead); }
    .plan { height: auto; aspect-ratio: 4 / 5; }
    .mesh-panel { display: flex; flex-direction: column; }
    .mesh-panel .says, .mesh-panel .mini { position: static; width: auto; max-width: none; margin: var(--s-5); }
    .mesh-panel .says { order: -1; }
    .meshes .frame-bar { padding: var(--s-4) var(--s-5) 0; }
    .mini dl div { padding-block: var(--s-1); }
    .final { padding-block: var(--s-9); }
    .foot { gap: var(--s-5); padding-block: var(--s-7); }
    .links { gap: var(--s-4) var(--s-5); }
  }
  @media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
  @media (prefers-reduced-motion: reduce) { .sig, .btn { transition: none; } }
}
