/* ============================================================
   Certly — web design system
   Mirrors the app's "Certly Redesign" language: neutral paper,
   one indigo accent, hairline structure, mono for numerals and
   labels. No shadows, no gradients, no confetti.
   Token values are the ones in Utilities/DesignSystem.swift.
   ============================================================ */

:root {
  --bg:          #f6f6f4;
  --surface:     #ffffff;
  --alt:         #ebebe7;
  --ink:         #121213;
  --mut:         #78786f;
  --line:        rgba(18, 18, 19, 0.085);
  --line-faint:  rgba(18, 18, 19, 0.05);
  --line-strong: rgba(18, 18, 19, 0.12);
  --accent:      #3b4ee0;
  --accent-fg:   #ffffff;
  --accent-soft: rgba(59, 78, 224, 0.10);
  --ok:          #4b7a5e;
  --warn:        #a8853f;
  --bad:         #b8563f;
  --flame:       #cf6a34;
  --hero:        #121213;
  --hero-fg:     #f6f6f4;
  --hero-mut:    rgba(246, 246, 244, 0.58);
  --badge-invert: 0;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Helvetica, Arial, sans-serif;

  --maxw: 1120px;
  --pad: 28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0d0d0f;
    --surface:     #16161a;
    --alt:         #23232a;
    --ink:         #f1f1ee;
    --mut:         #8e8e88;
    --line:        rgba(255, 255, 255, 0.10);
    --line-faint:  rgba(255, 255, 255, 0.06);
    --line-strong: rgba(255, 255, 255, 0.16);
    --accent:      #7e8be8;
    --accent-fg:   #0d0d0f;
    --accent-soft: rgba(126, 139, 232, 0.14);
    --ok:          #79b28c;
    --warn:        #d0ab68;
    --bad:         #e08974;
    --flame:       #e8925c;
    --hero:        #f1f1ee;
    --hero-fg:     #0d0d0f;
    --hero-mut:    rgba(13, 13, 15, 0.62);
    --badge-invert: 1;
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
img { max-width: 100%; }
::selection { background: var(--accent-soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-sm); z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

/* ---------- layout ---------- */

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }
.section { padding: 76px 0; }
.section-tight { padding: 46px 0; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }
.stack-sm > * + * { margin-top: 10px; }
.stack   > * + * { margin-top: 18px; }
.stack-lg > * + * { margin-top: 30px; }

/* ---------- type ---------- */

.label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mut);
  display: block;
}
.label-accent { color: var(--accent); }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; margin: 0; }

.h-display { font-size: clamp(42px, 6.4vw, 66px); line-height: 1.04; }
.h-section { font-size: clamp(30px, 4.2vw, 42px); }
.h-card    { font-size: 21px; letter-spacing: -0.02em; line-height: 1.3; }

.lede  { font-size: 20px;   line-height: 1.6;  color: var(--mut); margin: 0; }
.body  { font-size: 17px;   line-height: 1.65; color: var(--mut); margin: 0; }
.small { font-size: 14.5px; line-height: 1.6;  color: var(--mut); margin: 0; }
.tiny  { font-size: 13px;   line-height: 1.55; color: var(--mut); margin: 0; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }
.ink-text { color: var(--ink); }
.measure { max-width: 60ch; }

/* ---------- header ---------- */

.hdr {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(1px)) {
  .hdr {
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: saturate(150%) blur(14px);
    -webkit-backdrop-filter: saturate(150%) blur(14px);
  }
}
.hdr-in {
  max-width: var(--maxw); margin: 0 auto;
  padding: 15px var(--pad);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: baseline; gap: 11px; text-decoration: none; color: inherit; }
.brand-mark { font-family: var(--mono); font-size: 14.5px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; }
.brand-sub  { font-family: var(--mono); font-size: 12px; letter-spacing: 0.05em; color: var(--mut); }

.nav { display: flex; align-items: center; gap: 2px; }
.nav-link {
  font-size: 15.5px; color: var(--mut); text-decoration: none;
  padding: 8px 13px; border-radius: var(--r-sm);
  transition: color .18s, background .18s;
}
.nav-link:hover { color: var(--ink); background: var(--alt); }
.nav-link[aria-current="page"] { color: var(--ink); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-size: 16px; font-weight: 500; text-decoration: none;
  padding: 14px 22px; border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer;
  transition: opacity .18s, border-color .18s, background .18s;
}
.btn-primary { background: var(--hero); color: var(--hero-fg); }
.btn-primary:hover { opacity: .86; }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 10px 16px; font-size: 15px; border-radius: var(--r-sm); }

.link-arrow { font-size: 16px; font-weight: 500; color: var(--accent); text-decoration: none; transition: opacity .18s; }
.link-arrow:hover { opacity: .72; }

.badge-link { display: inline-block; text-decoration: none; transition: opacity .2s; }
.badge-link:hover { opacity: .82; }
.badge-link img { height: 56px; width: auto; display: block; filter: invert(var(--badge-invert)); }
/* The ink block flips the page's polarity, so the badge has to flip with it. */
.ink .badge-link img { filter: invert(calc(1 - var(--badge-invert))); }

.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

/* ---------- chips & pills ---------- */

.chip {
  display: inline-block; font-family: var(--mono); font-size: 13px;
  color: var(--ink); background: var(--alt); padding: 7px 11px; border-radius: var(--r-sm);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.pill {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 15px 7px 12px;
}
.pill .dot { width: 7px; height: 7px; background: var(--flame); transform: rotate(45deg); flex: none; }
.pill .dot-accent { background: var(--accent); }
.pill .dot-ok { background: var(--ok); }

/* ---------- stat strip ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 26px 0 26px 22px; border-left: 1px solid var(--line-faint); }
.stat:first-child { border-left: 0; padding-left: 0; }
.stat-val { font-family: var(--mono); font-size: clamp(32px, 4vw, 40px); font-weight: 500; letter-spacing: -0.03em; line-height: 1; display: block; }
.stat-lab { margin-top: 10px; }

/* ---------- rows (the workhorse) ---------- */

.rows { border-top: 1px solid var(--line); }
.row { display: block; text-decoration: none; color: inherit; padding: 22px 0; border-bottom: 1px solid var(--line); }
a.row { transition: opacity .18s; }
a.row:hover { opacity: .68; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.row-title { font-size: 19px; font-weight: 500; letter-spacing: -0.015em; }
.row-meta { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 4px 18px; }

.track { height: 2px; background: var(--alt); border-radius: 2px; margin: 13px 0 11px; overflow: hidden; }
.track > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ---------- cards ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px; }
a.card { display: block; text-decoration: none; color: inherit; transition: border-color .2s; }
a.card:hover { border-color: var(--line-strong); }

.ink { background: var(--hero); color: var(--hero-fg); border-radius: var(--r-xl); padding: 36px; }
.ink .body, .ink .small, .ink .tiny, .ink .label { color: var(--hero-mut); }
.ink .link-arrow { color: var(--hero-fg); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.split  { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; }
.split-hero { grid-template-columns: 1.08fr .92fr; }

/* ---------- phone frames ---------- */

.phone {
  border: 1px solid var(--line); border-radius: 32px; overflow: hidden;
  background: var(--bg); display: block; line-height: 0;
}
.phone img { width: 100%; height: auto; display: block; }
.phone-sm { max-width: 300px; }

.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 42px 26px; }
.shot-cap { margin-top: 15px; }

/* ---------- numbered steps ---------- */

.steps { counter-reset: step; border-top: 1px solid var(--line); }
.step { display: grid; grid-template-columns: 78px 1fr; gap: 26px; padding: 34px 0; border-bottom: 1px solid var(--line); }
.step-n { font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; color: var(--mut); padding-top: 5px; }

/* ---------- legal pages ---------- */

.legal { max-width: 780px; }
.legal h2 { font-size: 23px; margin: 0 0 14px; }
.legal p, .legal li { font-size: 17px; line-height: 1.72; color: var(--mut); }
.legal p { margin: 0 0 14px; }
.legal ul { padding-left: 18px; margin: 12px 0 16px; }
.legal li { margin-bottom: 8px; }
.legal section { padding: 34px 0; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.legal a { color: var(--accent); }
.legal strong { color: var(--ink); font-weight: 560; }
.legal-toc { display: flex; flex-wrap: wrap; gap: 7px; }
.legal-toc a { text-decoration: none; }

/* ---------- footer ---------- */

.ftr { border-top: 1px solid var(--line); margin-top: 30px; }
.ftr-in { max-width: var(--maxw); margin: 0 auto; padding: 56px var(--pad) 34px; }
.ftr-grid { display: grid; grid-template-columns: 1.8fr 1fr 1fr 1fr; gap: 36px; }
.ftr-col { display: flex; flex-direction: column; gap: 11px; }
.ftr-col a { font-size: 15.5px; color: var(--mut); text-decoration: none; transition: color .18s; }
.ftr-col a:hover { color: var(--ink); }
.ftr-bottom {
  margin-top: 46px; padding-top: 20px; border-top: 1px solid var(--line-faint);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px;
}

/* ---------- reveal ---------- */

/* Only hide it if JavaScript is actually running, so a failed or blocked
   script never leaves the page blank. The `js` class is set inline in head. */
.js [data-reveal] { opacity: 0; transform: translateY(14px); }
.revealed {
  opacity: 1 !important; transform: none !important;
  transition: opacity .6s cubic-bezier(.2,.7,.2,1), transform .6s cubic-bezier(.2,.7,.2,1);
}

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

/* ---------- responsive ---------- */

@media (max-width: 940px) {
  .split, .split-hero { grid-template-columns: 1fr; gap: 40px; }
  .split-hero .phone-wrap { order: -1; max-width: 300px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .shots { grid-template-columns: repeat(2, 1fr); }
  .ftr-grid { grid-template-columns: 1fr 1fr; gap: 30px; }
}

@media (max-width: 720px) {
  :root { --pad: 20px; }
  .section { padding: 54px 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 20px 0 20px 18px; }
  .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line-faint); }
  .nav-link { display: none; }
  .ink { padding: 26px; border-radius: var(--r-lg); }
  .ftr-grid { grid-template-columns: 1fr; }
  .row-head { flex-direction: column; gap: 6px; }
  .step { grid-template-columns: 1fr; gap: 12px; padding: 28px 0; }
  .step-n { padding-top: 0; }
}

@media (max-width: 520px) {
  .shots { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
