/* =============================================================================
   Subtitler — design system (light · flat color)
   Warm paper surfaces that match the logo's own near-white card. The logo is
   built from flat navy / violet / coral, so the site is too — no gradients.
   Editorial grotesque type, generous space, restrained accents.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces — warm paper */
  --bg: #f6f3ec;
  --bg-2: #f1ece2;
  --surface: #fffdf8;
  --surface-2: #faf6ee;

  /* Lines */
  --border: #e7e0d2;
  --border-strong: #d8cfbd;

  /* Ink — dark navy-slate text */
  --ink: #1b2533;
  --text-dim: #4f5a66;
  --text-mute: #7e8893;
  --text-faint: #a8afb7;

  /* Brand — flat colors lifted from the mark */
  --coral: #ff6f5a;       /* fills: buttons, icon tiles */
  --coral-ink: #d8472f;   /* coral for text/links on light (contrast) */
  --navy: #1f3a6d;
  --violet: #6f4f93;

  /* Semantic */
  --ok: #1f7a52;
  --warn: #b07414;

  /* Tints */
  --coral-tint: #ffeae4;
  --coral-tint-line: #f6d3c9;
  --ok-tint: #e6f3ec;
  --ok-tint-line: #cce7d9;
  --warn-tint: #faf0db;
  --warn-tint-line: #ecd9ab;

  /* Dark code panel (intentional contrast against the paper) */
  --code-bg: #16212c;
  --code-text: #e7eef1;
  --code-mute: #8b97a3;
  --code-border: #283744;

  /* Type */
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Consolas, monospace;

  /* Radii */
  --r-xs: 7px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Shadows — soft, navy-tinted */
  --shadow-sm: 0 1px 2px rgba(27, 37, 51, 0.05);
  --shadow-md: 0 8px 24px rgba(27, 37, 51, 0.08);
  --shadow-lg: 0 24px 56px rgba(27, 37, 51, 0.12);

  /* Layout */
  --maxw: 1120px;
  --maxw-prose: 740px;
  --topbar-h: 66px;
  --gutter: clamp(20px, 5vw, 56px);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* -----------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a {
  color: var(--coral-ink);
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--coral-tint);
  color: var(--ink);
}

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

/* -----------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}

.display {
  font-size: clamp(2.7rem, 6vw, 4.8rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.98;
}

h2 {
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
}

h3 {
  font-size: 1.18rem;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1.1em;
}

.lead {
  font-size: clamp(1.08rem, 1.6vw, 1.28rem);
  color: var(--text-dim);
  line-height: 1.6;
}

.accent {
  color: var(--coral-ink);
}

code,
pre,
.mono {
  font-family: var(--font-mono);
}

/* -----------------------------------------------------------------------------
   4. Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: clamp(56px, 8vw, 104px);
  position: relative;
}

.section--alt {
  background: var(--bg-2);
  border-block: 1px solid var(--border);
}

.section-head {
  max-width: 660px;
  margin-bottom: clamp(32px, 4vw, 52px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--coral-ink);
  margin-bottom: 15px;
}

.eyebrow::before {
  content: "";
  width: 20px;
  height: 2px;
  background: var(--coral);
}

.section-head p {
  margin-top: 13px;
  color: var(--text-dim);
  font-size: 1.06rem;
}

/* -----------------------------------------------------------------------------
   5. Topbar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding-inline: var(--gutter);
  background: rgba(246, 243, 236, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.16rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand .logo {
  height: 32px;
  width: auto;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a:not(.btn) {
  padding: 8px 13px;
  border-radius: var(--r-xs);
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}

.nav a:not(.btn):hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav a.active {
  color: var(--ink);
}

.nav a.active::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--coral);
}

.nav .nav-cta {
  margin-left: 6px;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

/* -----------------------------------------------------------------------------
   6. Buttons, pills, chips
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s var(--ease), border-color 0.16s var(--ease),
    background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* coral fill, dark ink label — flat and high-contrast */
.btn--primary {
  border-color: transparent;
  background: var(--coral);
  color: var(--ink);
}

.btn--primary:hover {
  background: #ff5e46;
  box-shadow: 0 10px 26px rgba(255, 111, 90, 0.34);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  background: var(--surface);
}

.btn--sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.9rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--text-dim);
}

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.pill .dot--beta {
  background: #f0852b;
  box-shadow: 0 0 0 3px rgba(240, 133, 43, 0.16);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.chip--ok {
  color: var(--ok);
  border-color: var(--ok-tint-line);
  background: var(--ok-tint);
}

.chip--run {
  color: var(--coral-ink);
  border-color: var(--coral-tint-line);
  background: var(--coral-tint);
}

/* -----------------------------------------------------------------------------
   7. Hero
   -------------------------------------------------------------------------- */
.hero {
  padding-block: clamp(52px, 8vw, 96px) clamp(56px, 9vw, 104px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  gap: clamp(36px, 6vw, 76px);
  align-items: center;
}

.hero-inner {
  max-width: 760px;
}

.hero h1 {
  margin: 18px 0 22px;
}

.hero .lead {
  max-width: 620px;
  margin-bottom: 30px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.hero-meta svg {
  width: 15px;
  height: 15px;
  color: var(--coral-ink);
}

/* -----------------------------------------------------------------------------
   8. Steps (how it works)
   -------------------------------------------------------------------------- */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.step {
  position: relative;
  padding: 26px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.step:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.step .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--coral-tint);
  border: 1px solid var(--coral-tint-line);
  color: var(--coral-ink);
  font-family: var(--font-mono);
  font-weight: 500;
  margin-bottom: 18px;
}

.step h3 {
  margin-bottom: 8px;
}

.step p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 44px;
  right: -13px;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
  transform: rotate(45deg);
  z-index: 1;
}

/* -----------------------------------------------------------------------------
   9. Feature cards
   -------------------------------------------------------------------------- */
.features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.feature {
  position: relative;
  padding: 26px 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.feature:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.feature .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--coral-tint);
  color: var(--coral-ink);
  margin-bottom: 16px;
}

.feature .icon svg {
  width: 21px;
  height: 21px;
}

.feature h3 {
  margin-bottom: 8px;
}

.feature p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.93rem;
}

/* -----------------------------------------------------------------------------
   10. Code blocks (dark panel) + copy
   -------------------------------------------------------------------------- */
.code {
  position: relative;
  border: 1px solid var(--code-border);
  border-radius: var(--r-md);
  background: var(--code-bg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--code-border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--code-mute);
}

.code-head .fname {
  color: #b9c4cd;
}

.code-copy {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--code-border);
  border-radius: var(--r-xs);
  background: #1d2a36;
  color: #aeb9c3;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.code-copy:hover {
  color: #fff;
  background: #25333f;
}

.code-copy svg {
  width: 13px;
  height: 13px;
}

.code-copy.copied {
  color: #6bd3a3;
  border-color: #2f5a48;
}

pre {
  margin: 0;
  overflow: auto;
  padding: 18px;
  font-size: 0.87rem;
  line-height: 1.7;
  color: var(--code-text);
}

pre code {
  font-family: var(--font-mono);
}

/* inline code */
p code,
li code,
.article code {
  padding: 2px 7px;
  border: 1px solid var(--coral-tint-line);
  border-radius: 6px;
  background: var(--coral-tint);
  color: var(--coral-ink);
  font-size: 0.85em;
}

/* ...but never style code inside a code block (beats .article code) */
pre code,
.article pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

/* -----------------------------------------------------------------------------
   11. Footer
   -------------------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  padding-block: 18px;
}

.footer-thin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}

.footer-thin .brand {
  font-size: 1.02rem;
}

.footer-thin .brand .logo {
  height: 26px;
}

.footer-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.footer-meta a {
  color: var(--text-mute);
  transition: color 0.16s var(--ease);
}

.footer-meta a:hover {
  color: var(--ink);
}

.footer-meta .sep {
  color: var(--text-faint);
}

.footer-meta .heart {
  display: inline-block;
  width: 13px;
  height: 13px;
  color: var(--coral-ink);
  vertical-align: -2px;
}

/* -----------------------------------------------------------------------------
   12. Docs / article layout
   -------------------------------------------------------------------------- */
.docs {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: clamp(28px, 5vw, 56px);
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 32px);
  padding: 6px 0;
  counter-reset: toc-item;
}

.toc .toc-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 12px 10px;
}

.toc a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-mute);
  font-size: 0.92rem;
  padding: 8px 12px;
  border-left: 2px solid transparent;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}

.toc a::before {
  content: counter(toc-item, decimal-leading-zero);
  counter-increment: toc-item;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
}

.toc a:hover {
  color: var(--text-dim);
}

.toc a.active {
  color: var(--ink);
  border-left-color: var(--coral);
}

.toc a.active::before {
  color: var(--coral-ink);
}

.article {
  max-width: var(--maxw-prose);
  padding-block: clamp(40px, 6vw, 68px) clamp(56px, 9vw, 100px);
}

.article-head {
  margin-bottom: 38px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--border);
}

.article-head h1 {
  font-size: clamp(2.3rem, 4.6vw, 3.4rem);
  margin: 14px 0 14px;
}

.article-head p {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin: 0;
}

.article h2 {
  font-size: 1.6rem;
  margin: 50px 0 16px;
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}

.article h2 .step-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--coral-ink);
  margin-right: 10px;
}

.article p,
.article li {
  color: var(--text-dim);
}

.article ul {
  padding-left: 20px;
}

.article li {
  margin-bottom: 8px;
}

.article .code {
  margin: 20px 0;
}

/* callouts */
.callout {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  margin: 24px 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--navy);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.96rem;
}

.callout svg {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  color: var(--navy);
}

.callout--warn {
  border-left-color: var(--warn);
  background: var(--warn-tint);
}

.callout--warn svg {
  color: var(--warn);
}

.callout p {
  margin: 0;
}

/* -----------------------------------------------------------------------------
   13. Reveal-on-scroll
   -------------------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

[data-reveal].in {
  opacity: 1;
  transform: none;
}

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

/* -----------------------------------------------------------------------------
   14. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .features {
    grid-template-columns: repeat(2, 1fr);
  }
  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
  .step:not(:last-child)::after {
    display: none;
  }
}

@media (max-width: 820px) {
  .nav {
    position: fixed;
    inset: var(--topbar-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 14px var(--gutter) 22px;
    background: rgba(246, 243, 236, 0.96);
    backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  }
  .nav.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  .nav a:not(.btn) {
    padding: 12px 13px;
  }
  .nav a.active::after {
    display: none;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .docs {
    grid-template-columns: 1fr;
  }
  .toc {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 18px;
    border-bottom: 1px solid var(--border);
  }
  .toc .toc-label {
    width: 100%;
  }
  .toc a {
    border-left: 0;
    border-bottom: 2px solid transparent;
  }
  .toc a.active {
    border-left: 0;
    border-bottom-color: var(--coral);
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }
  .features,
  .steps {
    grid-template-columns: 1fr;
  }
  .hero-actions .btn {
    flex: 1;
  }
}
