/*
 * Chartlumo website – base, typography, layout primitives, components and page shell.
 * Requires /css/tokens.css first. Reference: docs/WEBSITE-DESIGNSYSTEM.md.
 * Breakpoints: phone ≤ 700px, tablet ≤ 1024px, header menu mode ≤ 960px.
 */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--header-h) + 24px);
  background: var(--bg);
}
/* No global smooth scrolling: anchor jumps must land exactly (short in-page hops are animated by shell.js). */
body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
img, svg, video, picture { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4 { font-weight: 500; text-wrap: balance; overflow-wrap: break-word; }
p, li, dd, figcaption { text-wrap: pretty; }
strong { font-weight: 600; }
::selection { background: var(--gold-fill); color: var(--on-gold); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }
a, button, [role="button"], summary { touch-action: manipulation; }
button, [role="button"], .btn, .seg, .icon-btn { -webkit-user-select: none; user-select: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Skip link */
.skip-link {
  position: fixed; left: 16px; top: 12px; z-index: var(--z-skip);
  padding: 10px 16px; border-radius: var(--r-sm);
  background: var(--gold-fill); color: var(--on-gold); font-size: var(--fs-small); font-weight: 600; text-decoration: none;
  transform: translateY(calc(-100% - 24px));
}
.skip-link:focus-visible { transform: none; outline-offset: 2px; }

/* ---------- Typography ---------- */
.t-display {
  font-size: var(--fs-display); line-height: var(--lh-display); letter-spacing: var(--ls-display);
  font-weight: 400; color: var(--text-1);
}
.t-h2 {
  font-size: var(--fs-h2); line-height: var(--lh-h2); letter-spacing: var(--ls-h2);
  font-weight: 400; color: var(--text-1);
}
.t-h3 {
  font-size: var(--fs-h3); line-height: var(--lh-h3); letter-spacing: var(--ls-h3);
  font-weight: 500; color: var(--text-1);
}
.t-serif {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: var(--fs-serif); line-height: 1.15; letter-spacing: -.015em; color: var(--gold);
}
.t-display .t-serif, .t-h2 .t-serif { font-size: 1em; line-height: inherit; }
.t-lead { font-size: var(--fs-lead); line-height: var(--lh-lead); color: var(--text-2); max-width: var(--measure); }
.t-body { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text-2); max-width: var(--measure); }
.t-small { font-size: var(--fs-small); line-height: 1.55; color: var(--text-2); }
.t-caption { font-size: var(--fs-caption); line-height: 1.5; color: var(--text-3); }
.t-label {
  font-size: var(--fs-label); line-height: 1.3; font-weight: 600;
  letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--text-2);
}
.t-num { font-variant-numeric: tabular-nums lining-nums; }
.t-strong { color: var(--text-1); }
.measure { max-width: var(--measure); }
.flow > * + * { margin-top: var(--flow, 1em); }
.prose a, .link { color: var(--gold); text-decoration: underline; text-decoration-color: var(--gold-line); }

/* ---------- Layout primitives ---------- */
.wrap { width: min(var(--w-std), 100% - 2 * var(--gutter)); margin-inline: auto; }
.wrap-text { width: min(var(--w-text), 100% - 2 * var(--gutter)); margin-inline: auto; }
.wrap-wide { width: min(var(--w-wide), 100% - 2 * var(--gutter)); margin-inline: auto; }
.section { padding-block: var(--section-y); }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--line); }
.section-head { display: grid; gap: var(--s-4); margin-bottom: clamp(32px, 2rem + 2vw, 64px); max-width: 760px; }
.stack { display: grid; gap: var(--stack, var(--s-5)); align-content: start; }

/* Two columns, text + media; stacks on phones. */
.split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(40px, 2rem + 4vw, 112px); align-items: center;
}
.split--text-wide { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
.split--reverse > :first-child { order: 2; }
.split-media { display: flex; justify-content: center; }

/* ---------- Device frame for app screenshots (690 × 1500) ---------- */
.device {
  /* Fixed width before the screenshot loads, so frames never grow (no layout shift). */
  position: relative; margin: 0; width: var(--device-w, 300px); max-width: 100%;
  padding: 2.6%;
  background: var(--device-bezel);
  border-radius: 15.5% / 7.2%;
  box-shadow: 0 0 0 1px var(--device-outline), var(--shadow-device);
  isolation: isolate;
}
.device::after {           /* fine inner highlight along the bezel edge */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px rgba(255, 255, 255, .03);
}
.device-screen {
  display: block; width: 100%; height: auto; aspect-ratio: 690 / 1500;
  border-radius: 13.6% / 6.3%;
  background: var(--surface-1);
  object-fit: cover;
}
/* Theme-dependent screenshots: two <img>, only the active one is rendered (and, being lazy, fetched). */
.shot-light { display: none; }
:root[data-theme="light"] .shot-dark { display: none; }
:root[data-theme="light"] .shot-light { display: block; }
.device-sm { --device-w: 220px; }
.device-lg { --device-w: 340px; }
.device-caption, .figure-caption {
  margin-top: var(--s-5); font-size: var(--fs-caption); line-height: 1.5; color: var(--text-3);
  text-align: center; max-width: 34ch; margin-inline: auto;
}
.figure { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; } /* the frame can never exceed its column */

/* ---------- Status badges (shape + word, never colour alone) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 7px; vertical-align: middle;
  min-height: 26px; padding: 3px 11px 3px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-label); font-weight: 600; letter-spacing: .02em; line-height: 1.2;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; }
.badge--available { background: var(--pos-tint); color: var(--pos); }
.badge--available::before { background: currentColor; }                       /* filled dot */
.badge--demo { background: var(--gold-tint); color: var(--gold); }
:root[data-theme="light"] .badge--demo { color: var(--gold-fill-hover); } /* 12px text on the tint: ≥ 4.5:1 */
.badge--demo::before {                                                         /* half-filled dot */
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.badge--planned { color: var(--text-2); border-color: var(--line-ui); border-style: dashed; }
.badge--planned::before { border: 1.5px dashed currentColor; }                 /* open dashed ring */

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 24px; border-radius: var(--r-pill);
  font-size: .9375rem; font-weight: 600; letter-spacing: .005em; line-height: 1.2;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: background-color var(--dur-1) ease-out, border-color var(--dur-1) ease-out, transform var(--dur-1) ease-out, color var(--dur-1) ease-out;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--gold-fill); color: var(--on-gold); }
.btn--primary:active { background: var(--gold-fill-pressed); }
.btn--secondary { background: transparent; color: var(--text-1); border-color: var(--line-ui); }
.btn--secondary:active { background: var(--pressed); }
.btn[aria-disabled="true"], .btn:disabled { opacity: var(--disabled-opacity); pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.link-arrow {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  color: var(--gold); font-weight: 600; font-size: .9375rem; text-decoration: none;
}
.link-arrow::after {          /* drawn chevron, no text arrow */
  content: ""; width: 7px; height: 7px; flex: none; margin-left: 2px;
  border-top: 1.6px solid currentColor; border-right: 1.6px solid currentColor;
  transform: rotate(45deg); transition: transform var(--dur-2) var(--ease-out);
}
.link-arrow:active { opacity: .75; }

@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--gold-fill-hover); }
  .btn--secondary:hover { border-color: var(--gold); background: var(--hover); }
  .link-arrow:hover { text-decoration: underline; text-decoration-color: var(--gold-line); }
  .link-arrow:hover::after { transform: translateX(3px) rotate(45deg); }
  .prose a:hover, .link:hover { text-decoration-color: currentColor; }
}

/* ---------- Note box for limitations ---------- */
.note {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px;
  padding: 16px 18px; border-radius: var(--r-md);
  background: var(--surface-1); border: 1px solid var(--line-strong);
  font-size: var(--fs-small); line-height: 1.6; color: var(--text-2); max-width: var(--measure);
}
.note::before {               /* drawn "i" mark */
  content: ""; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: linear-gradient(var(--gold), var(--gold)) center 7px / 1.6px 6px no-repeat,
              radial-gradient(circle, var(--gold) 0 1px, transparent 1.3px) center 3.5px / 4px 4px no-repeat;
}
.note strong { color: var(--text-1); }
.note > * { grid-column: 2; }
.note > :first-child { grid-row: 1; }

/* ---------- Liquid glass material ---------- */
.glass {
  background-color: var(--glass-bg);
  background-image: var(--glass-sheen);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-edge-top), inset 0 -1px 0 var(--glass-edge-bottom), var(--glass-shadow);
}
.glass-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-caption); font-weight: 600; line-height: 1.25; color: var(--text-1);
  background-color: var(--glass-chip-bg);
  background-image: var(--glass-sheen);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-edge-top), inset 0 -1px 0 var(--glass-edge-bottom), 0 6px 18px -10px rgba(0, 0, 0, .5);
}
.glass-chip .t-num, .glass-chip b { color: var(--text-1); font-weight: 600; }
.glass-chip small { font-size: inherit; font-weight: 500; color: var(--glass-text-2); }
.overlay { position: relative; }
.overlay > .glass-chip { position: absolute; z-index: 1; }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .glass-chip { background-color: var(--glass-bg-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .glass-chip { background-color: var(--glass-bg-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .glass, .glass-chip { background-color: var(--glass-bg-solid); border-color: var(--line-ui); }
}

/* Compact controls on glass */
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--glass-text-2); cursor: pointer;
  transition: background-color var(--dur-1) ease-out, color var(--dur-1) ease-out;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--pressed); }

.seg {
  position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; border-radius: var(--r-pill);
  background: var(--hover); box-shadow: inset 0 0 0 1px var(--line);
}
.seg::before {                /* sliding thumb – transform only */
  content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--seg-count, 2));
  border-radius: var(--r-pill); background: var(--gold-fill);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2), inset 0 1px 0 rgba(255, 255, 255, .25);
  transform: translateX(calc(100% * var(--seg-index, 0)));
  transition: transform var(--dur-3) var(--ease-out);
}
.seg > button {
  position: relative; z-index: 1; min-width: 36px; height: 30px; padding: 0 10px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-pill); background: none; cursor: pointer;
  font-size: var(--fs-label); font-weight: 600; letter-spacing: .06em; color: var(--glass-text-2);
  transition: color var(--dur-2) ease-out;
}
.seg > button[aria-pressed="true"] { color: var(--on-gold); }
.seg > button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.seg[data-index="1"] { --seg-index: 1; }
.seg[data-index="2"] { --seg-index: 2; }
.seg--icons > button { padding: 0 9px; }

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--hover); color: var(--text-1); }
  .seg > button[aria-pressed="false"]:hover { color: var(--text-1); }
}

/* Motion toggle: pause icon while motion runs, play icon while paused */
.motion-btn .i-play { display: none; }
:root[data-motion="off"] .motion-btn .i-play { display: block; }
:root[data-motion="off"] .motion-btn .i-pause { display: none; }

/* ---------- Site header (floating glass bar) ---------- */
.site-header {
  position: sticky; top: 0; z-index: var(--z-header);
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
}
.site-bar {
  pointer-events: auto; position: relative;
  width: min(var(--w-std), 100%); margin-inline: auto;
  height: var(--header-h); padding: 0 10px 0 18px;
  display: flex; align-items: center; gap: 16px;
  border-radius: 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  font-size: 1.25rem; font-weight: 400; letter-spacing: .02em; line-height: 1;
  color: var(--text-1); text-decoration: none; min-height: 44px;
}
.brand-mark { width: 28px; height: 26px; fill: var(--gold); flex: none; }
.site-menu { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.site-nav { display: flex; align-items: center; gap: 2px; margin-inline: auto; }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--r-pill);
  font-size: .9375rem; font-weight: 500; color: var(--glass-text-2); text-decoration: none; white-space: nowrap;
  transition: color var(--dur-1) ease-out, background-color var(--dur-1) ease-out;
}
.site-nav a[aria-current="page"], .site-nav a[aria-current="true"] { color: var(--text-1); background: var(--hover); }
.site-nav a:active { background: var(--pressed); }
.site-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.nav-toggle { display: none; }
@media (hover: hover) and (pointer: fine) { .site-nav a:hover { color: var(--text-1); background: var(--hover); } }

/* Controls only make sense with JS (they stay hidden without it). */
:root:not(.has-js) .site-controls, :root:not(.has-js) .nav-toggle { display: none !important; }

/* Reading progress inside the bar – transform: scaleX only */
.bar-progress {
  position: absolute; left: 20px; right: 20px; bottom: 0; height: 1.5px;
  background: var(--gold); opacity: .7; border-radius: 1px;
  transform-origin: 0 50%; transform: scaleX(var(--progress, 0));
  pointer-events: none;
}

/* Menu mode (tablet narrow + phone) */
@media (max-width: 960px) {
  :root { --header-h: 56px; }
  .site-bar { padding: 0 6px 0 16px; border-radius: 18px; }
  .brand { font-size: 1.125rem; gap: 8px; }
  .brand-mark { width: 25px; height: 23px; }
  .has-js .nav-toggle { display: inline-grid; margin-left: auto; width: 44px; height: 44px; }
  .nav-toggle .i-close { display: none; }
  .nav-toggle[aria-expanded="true"] .i-close { display: block; }
  .nav-toggle[aria-expanded="true"] .i-menu { display: none; }

  .has-js .site-menu {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; gap: 4px; padding: 8px;
    border-radius: 20px;
    background-color: var(--sheet-bg);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-edge-top), var(--shadow-2);
    max-height: calc(100dvh - var(--header-h) - 40px); overflow-y: auto; overscroll-behavior: contain;
    transform-origin: calc(100% - 28px) 0;
    opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.97);
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  .has-js .site-header[data-open] .site-menu {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s;
  }
  .site-nav { display: grid; margin: 0; gap: 0; }
  .site-nav a { min-height: 52px; padding: 0 14px; border-radius: 12px; font-size: 1.0625rem; color: var(--text-1); }
  .site-controls { justify-content: space-between; padding: 10px 6px 4px 14px; margin-top: 4px; border-top: 1px solid var(--line); }
  .site-controls .seg > button { height: 36px; min-width: 44px; }
  .site-controls .icon-btn { width: 44px; height: 44px; }

  /* No JS: links sit in a scrollable row under the brand. */
  :root:not(.has-js) .site-bar { height: auto; flex-wrap: wrap; padding-block: 6px; }
  :root:not(.has-js) .site-menu { flex-basis: 100%; overflow-x: auto; }
  :root:not(.has-js) .site-nav { display: flex; margin: 0; }
  :root:not(.has-js) .site-nav a { min-height: 44px; font-size: .9375rem; }
}
html.menu-open { overflow: hidden; }

/* ---------- Notice line (legal pages) ---------- */
.notice-line { padding: 10px 0 0; font-size: var(--fs-caption); line-height: 1.5; color: var(--text-2); }
.notice-line .wrap { display: flex; gap: 10px; justify-content: center; text-align: center; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 40px 0 calc(44px + env(safe-area-inset-bottom)); margin-top: var(--section-y); }
.site-footer.no-gap { margin-top: 0; }
.footer-grid { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 24px 48px; align-items: start; }
.footer-grid .brand { font-size: 1.125rem; }
.footer-note { font-size: var(--fs-caption); line-height: 1.6; color: var(--text-3); max-width: 60ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; margin: 0; padding: 0; font-size: var(--fs-small); }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-2); text-decoration: none; }
.footer-links a[aria-current="page"] { color: var(--text-1); }
.footer-copy { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid var(--line); font-size: var(--fs-caption); color: var(--text-3); }
@media (hover: hover) and (pointer: fine) { .footer-links a:hover { color: var(--gold); } }

/* ---------- Legal pages ---------- */
.legal { padding-block: clamp(48px, 2rem + 4vw, 104px) 0; }
.legal-title { font-size: clamp(2rem, 1.6rem + 2vw, 3.5rem); line-height: 1.08; letter-spacing: var(--ls-h2); font-weight: 400; margin-bottom: 16px; }
.legal-kicker { font-size: var(--fs-small); color: var(--text-3); margin-bottom: 12px; }
.legal .t-lead { margin-bottom: 40px; }
.legal h2 { font-size: var(--fs-h3); line-height: var(--lh-h3); letter-spacing: var(--ls-h3); margin: 48px 0 12px; }
.legal p, .legal li { color: var(--text-2); max-width: var(--measure); }
.legal p + p { margin-top: 12px; }
.legal ul { padding-left: 20px; margin: 10px 0 0; }
.legal li + li { margin-top: 4px; }
.legal a:not(.btn) { color: var(--gold); text-decoration: underline; text-decoration-color: var(--gold-line); }
.legal .note { margin-top: 8px; }
.legal-stand { margin-top: 56px; font-size: var(--fs-caption); color: var(--text-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: auto minmax(0, 1fr); }
  .footer-links { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  h1, h2, .t-display, .t-h2, .legal-title { hyphens: auto; -webkit-hyphens: auto; }
  .split, .split--text-wide { grid-template-columns: minmax(0, 1fr); }
  .split--reverse > :first-child { order: 0; }
  .btn { width: 100%; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .device { --device-w: 260px; }
  .device-sm { --device-w: 200px; }
}
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
/* Phone on its side: a slimmer header leaves more of the 390px height for content. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --header-h: 48px; }
  .site-header { padding-top: max(6px, env(safe-area-inset-top)); }
  .site-bar { border-radius: 14px; }
}

/* ---------- Motion off: static reading view (explicit user choice) ---------- */
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}
