/* Tokens lifted from flywheel-redesign/client/src/styles/tokens (www.flywheelos.com). */
:root {
  --bg: #ffffff;
  --surface: #faf9f6;
  --surface-hover: #f5f5f5;
  --surface-active: #eeeeee;
  --fg: #000000;
  --text-primary: #111111;
  --text-secondary: #333333;
  --text-subtle: #555555;
  --text-muted: #666666;
  --text-faint: #888888;
  --border: #e5e5e5;
  --border-subtle: #cccccc;
  --accent: #e6ff00;
  --accent-subtle: rgba(230, 255, 0, 0.1);
  --nav-link: #6b7a7c;
  --nav-dark: #0c0d0e;
  --nav-button-bg: #f1f3f3;
  --nav-scrolled-bg: rgba(12, 13, 14, 0.75);
  --sand: rgba(215, 200, 175, 1);
  --max: 1300px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "DM Mono", Monaco, Consolas, monospace;
}

* { box-sizing: border-box; border-color: var(--border); }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: #000; color: #fff; }
a { color: inherit; }
.numeric { font-family: var(--mono); }

/* Ruled "blueprint" frame: full-width rows, a bordered 1300px column inside. */
.row { width: 100%; display: flex; justify-content: center; border-bottom: 1px solid var(--border); background: var(--bg); }
.row.surface { background: var(--surface); }
.col { width: 100%; max-width: var(--max); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }

.eyebrow {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 600; color: var(--text-muted); margin: 0 0 16px;
}
.lead { font-size: 18px; line-height: 1.6; color: var(--text-muted); margin: 0; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 50; display: flex; justify-content: center;
  background: #fff; border-bottom: 1px solid var(--border); transition: all 0.3s;
}
.nav-inner {
  width: 100%; max-width: var(--max); height: 48px; padding: 0 40px;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: relative;
  transition: all 0.3s;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand span:first-of-type {
  font-family: "Plus Jakarta Sans", var(--sans); font-weight: 600; font-size: 15px; letter-spacing: -0.02em;
}
.brand-tag {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); border: 1px solid var(--border); padding: 2px 6px;
}
.logo-mark { width: 20px; height: 20px; display: block; }
.nav-links { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; }
.nav-links a, .nav-right a, .menu-btn {
  padding: 8px 16px; font-size: 15px; font-weight: 500; color: var(--nav-link);
  text-decoration: none; border-radius: 6px; transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.on { color: var(--text-primary); background: #f9fafb; }
.nav-right { display: flex; align-items: center; }
.nav-cta { color: var(--text-primary) !important; }
.nav-cta:hover { opacity: 0.7; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); font-family: inherit; cursor: pointer; }

@media (min-width: 900px) {
  .nav.scrolled { background: transparent; border-bottom-color: transparent; padding-top: 10px; }
  .nav.scrolled .nav-inner {
    max-width: fit-content; height: 56px; padding: 0 12px; gap: 24px;
    background: var(--nav-scrolled-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: none; border-radius: 20px;
  }
  .nav.scrolled .nav-links { position: static; transform: none; }
  .nav.scrolled .brand { color: #fff; }
  .nav.scrolled .logo-mark { filter: invert(1) brightness(2); }
  .nav.scrolled .brand-tag { color: rgba(255, 255, 255, 0.6); border-color: rgba(255, 255, 255, 0.2); }
  .nav.scrolled .nav-links a { color: rgba(255, 255, 255, 0.7); }
  .nav.scrolled .nav-links a:hover, .nav.scrolled .nav-links a.on { color: #fff; background: rgba(255, 255, 255, 0.08); }
  .nav.scrolled .nav-cta { background: var(--nav-button-bg); color: var(--nav-dark) !important; padding: 6px 12px; border-radius: 12px; }
}

/* Frame markers: corner brackets that slide out on hover. */
.btn-sand, .btn-black { position: relative; display: inline-flex; align-items: center; text-decoration: none; overflow: visible; transition: all 0.3s; }
.fm { position: absolute; width: 14px; height: 14px; border-color: currentColor; opacity: 0.3; transition: all 0.3s; }
.fm-tl { top: -7px; left: -7px; border-top: 1.5px solid; border-left: 1.5px solid; }
.fm-tr { top: -7px; right: -7px; border-top: 1.5px solid; border-right: 1.5px solid; }
.fm-bl { bottom: -7px; left: -7px; border-bottom: 1.5px solid; border-left: 1.5px solid; }
.fm-br { bottom: -7px; right: -7px; border-bottom: 1.5px solid; border-right: 1.5px solid; }
.btn-sand:hover .fm, .btn-black:hover .fm { opacity: 1; }
.btn-sand:hover .fm-tl, .btn-black:hover .fm-tl { transform: translate(-4px, -4px); }
.btn-sand:hover .fm-tr, .btn-black:hover .fm-tr { transform: translate(4px, -4px); }
.btn-sand:hover .fm-bl, .btn-black:hover .fm-bl { transform: translate(-4px, 4px); }
.btn-sand:hover .fm-br, .btn-black:hover .fm-br { transform: translate(4px, 4px); }

.btn-sand {
  padding: 16px 32px; font-size: 14px; font-weight: 600; color: #111;
  background: linear-gradient(135deg, rgba(215, 200, 175, 0.45) 0%, rgba(196, 184, 154, 0.35) 50%, rgba(215, 200, 175, 0.45) 100%);
  border: 1px solid rgba(215, 200, 175, 0.5);
  box-shadow: 0 4px 20px rgba(215, 200, 175, 0.25), 0 1px 4px rgba(0, 0, 0, 0.06), inset 0 1px 1px rgba(255, 252, 248, 0.5), inset 0 -1px 1px rgba(215, 200, 175, 0.15);
  backdrop-filter: blur(12px);
}
.btn-black { background: #000; color: #fff; padding: 0 40px; height: 56px; font-size: 16px; font-weight: 500; }
.btn-black .fm { border-color: #000; }
.btn-black:hover { background: rgba(0, 0, 0, 0.9); }
.btn-pill {
  display: inline-flex; gap: 8px; align-items: center; padding: 12px 28px; border-radius: 999px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06); backdrop-filter: blur(8px); transition: transform 0.2s;
}
.btn-pill span { transition: transform 0.2s; }
.btn-pill:hover { transform: scale(1.02); }
.btn-pill:hover span { transform: translateX(3px); }

/* Hero */
.hero { position: relative; min-height: 560px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mesh {
  position: absolute; inset: 0; opacity: 0.9;
  background:
    radial-gradient(ellipse at 15% 20%, hsl(30, 35%, 85%) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, hsl(40, 30%, 94%) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 80%, hsl(45, 25%, 92%) 0%, transparent 55%),
    radial-gradient(ellipse at 90% 90%, hsl(35, 40%, 88%) 0%, transparent 45%),
    linear-gradient(135deg, hsl(40, 28%, 93%) 0%, hsl(38, 32%, 91%) 100%);
}
.hero-inner { position: relative; z-index: 1; text-align: center; max-width: 900px; padding: 80px 32px; }
.hero h1 { font-size: 84px; font-weight: 600; line-height: 0.92; letter-spacing: -0.04em; margin: 0 0 28px; }
.hero .lead { max-width: 640px; margin: 0 auto; }
.hero-ctas { margin-top: 40px; display: flex; gap: 20px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* The loop strip */
.loop { padding: 40px 64px; }
.loop-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); border: 1px solid var(--border); background: #fff; }
.loop-step { padding: 20px 16px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.loop-step:last-child { border-right: 0; }
.loop-step span { font-size: 12px; font-weight: 400; color: var(--text-faint); }

.prose-wide { padding: 64px; max-width: var(--max); }
.prose-wide h2 { font-size: 48px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; margin: 0 0 24px; max-width: 900px; }
.prose-wide p { font-size: 17px; line-height: 1.75; color: var(--text-subtle); max-width: 820px; }

/* Cards: border-separated grid, invert to black on hover. */
.section-head { padding: 32px 32px 0; }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); margin-top: 8px; }
.card {
  padding: 32px; background: #fff; display: flex; flex-direction: column; text-decoration: none;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transition: background 0.3s, color 0.3s;
  min-height: 240px;
}
.card:nth-child(3n) { border-right: 0; }
.card-icon {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-hover); font-size: 14px; margin-bottom: 32px; transition: all 0.3s;
}
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 12px; }
.card-body { font-size: 15px; line-height: 1.6; color: var(--text-subtle); flex: 1; transition: color 0.3s; }
.card-arrow { margin-top: 20px; font-size: 13px; font-weight: 600; opacity: 0; transition: opacity 0.3s; }
.card:hover { background: #000; color: #fff; }
.card:hover .card-icon { background: #fff; color: #000; }
.card:hover .card-body { color: #d1d1d1; }
.card:hover .card-arrow { opacity: 1; }

/* Doc layout: sidebar, content, on-this-page. */
.doc-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; }
.sidebar, .toc { position: sticky; top: 48px; align-self: start; max-height: calc(100vh - 48px); overflow-y: auto; padding: 32px 24px; }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); min-height: calc(100vh - 48px); }
.toc { border-left: 1px solid var(--border); min-height: calc(100vh - 48px); }
.side-group { margin-bottom: 28px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; color: var(--text-faint); margin: 0 0 10px; }
.sidebar a, .toc a {
  display: block; padding: 6px 10px; margin: 0 -10px; font-size: 14px; color: var(--text-subtle);
  text-decoration: none; transition: all 0.2s; border-left: 2px solid transparent;
}
.sidebar a:hover, .toc a:hover { color: var(--text-primary); background: var(--surface-hover); }
.sidebar a.on { color: #000; font-weight: 600; background: #fff; border-left-color: #000; }
.toc a { font-size: 13px; }
.toc a.on { color: #000; border-left-color: #000; }

.doc { padding: 56px 64px 40px; min-width: 0; }
.doc-title { font-size: 56px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; margin: 0 0 20px; }
.route-chip { display: inline-flex; align-items: stretch; margin: 28px 0 0; border: 1px solid var(--border); font-size: 13px; }
.route-chip span { padding: 6px 10px; background: var(--surface); border-right: 1px solid var(--border); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; display: flex; align-items: center; color: var(--text-muted); }
.route-chip code { padding: 6px 10px; font-family: var(--mono); font-size: 13px; }

/* Prose, matching the blog's portable-text styles. */
.prose { margin-top: 40px; border-top: 1px solid var(--border); padding-top: 8px; }
.prose h2 { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin: 48px 0 14px; }
.prose h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; margin: 32px 0 10px; }
.prose h4 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
.prose .anchor { text-decoration: none; }
.prose .anchor:hover::after { content: " #"; color: var(--text-faint); }
.prose p, .prose ul, .prose ol { font-size: 16px; line-height: 1.75; color: var(--text-subtle); margin: 0 0 20px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--text-faint); }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose a { text-decoration: underline; text-underline-offset: 4px; }
.prose code { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; color: var(--text-primary); }
.prose pre { background: #0c0d0e; color: #e5e5e5; padding: 20px 24px; overflow-x: auto; margin: 0 0 24px; }
.prose pre code { background: none; border: 0; color: inherit; padding: 0; }
.prose blockquote { border-left: 4px solid var(--accent); background: var(--accent-subtle); margin: 28px 0; padding: 14px 24px; }
.prose blockquote p { margin: 0; font-size: 16px; color: var(--text-secondary); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 28px; border: 1px solid var(--border); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th { text-align: left; background: var(--surface); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.prose td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text-subtle); vertical-align: top; line-height: 1.55; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: #fcfcfa; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 64px; border: 1px solid var(--border); }
.pager a { padding: 20px 24px; text-decoration: none; font-weight: 600; font-size: 16px; transition: all 0.3s; }
.pager a span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); font-weight: 600; margin-bottom: 6px; }
.pager a:hover { background: #000; color: #fff; }
.pager-next { text-align: right; border-left: 1px solid var(--border); }

/* Footer */
.footer { background: var(--surface); position: relative; overflow: hidden; }
.footer::before {
  content: ""; position: absolute; inset: 20% -10% -40%;
  background: radial-gradient(ellipse at 50% 60%, rgba(215, 200, 175, 0.55) 0%, transparent 60%);
  filter: blur(40px); pointer-events: none;
}
.footer-cta { position: relative; text-align: center; padding: 96px 24px 128px; }
.footer-cta h2 { font-size: 56px; font-weight: 600; line-height: 1.05; letter-spacing: -0.03em; margin: 0 auto 40px; max-width: 820px; }
.footer-bar {
  position: relative; max-width: var(--max); margin: 0 auto; padding: 24px 40px;
  display: grid; grid-template-columns: repeat(3, 1fr); font-size: 13px; color: var(--text-muted);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.footer-bar span:nth-child(2) { text-align: center; }
.footer-bar span:last-child { text-align: right; }

/* Responsive */
@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .card:nth-child(3n) { border-right: 1px solid var(--border); }
  .card:nth-child(2n) { border-right: 0; }
  .loop-steps { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .nav-inner { padding: 0 16px; }
  .nav-links { display: none; }
  .menu-btn { display: inline-block; }
  .nav-cta { display: none; }
  .doc-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; position: static; min-height: 0; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .menu-open .sidebar { display: block; }
  .doc { padding: 36px 20px; }
  .doc-title { font-size: 40px; }
  .hero h1 { font-size: 48px; }
  .prose-wide { padding: 40px 20px; }
  .prose-wide h2 { font-size: 34px; }
  .card-grid { grid-template-columns: 1fr; }
  .card { border-right: 0 !important; min-height: 0; }
  .loop { padding: 24px 20px; }
  .loop-steps { grid-template-columns: repeat(2, 1fr); }
  .footer-cta h2 { font-size: 36px; }
  .footer-bar { grid-template-columns: 1fr; gap: 8px; text-align: center; }
  .footer-bar span { text-align: center !important; }
}
@media (max-width: 760px) {
  .menu-open .nav-links { display: flex; position: fixed; top: 48px; left: 0; right: 0; transform: none; background: #fff; border-bottom: 1px solid var(--border); padding: 8px; flex-direction: column; }
}
.prose-wide blockquote { border-left: 4px solid var(--accent); background: var(--accent-subtle); margin: 28px 0 0; padding: 14px 24px; max-width: 820px; }
.prose-wide blockquote p { margin: 0; font-size: 15px; }
.prose-wide code { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; }
.prose-wide a { text-underline-offset: 4px; }

/* Search (Pagefind, built into dist/pagefind at build time). */
.search-btn {
  display: inline-flex; align-items: center; gap: 10px; margin-right: 8px; padding: 6px 8px 6px 12px;
  font: 500 14px var(--sans); color: var(--nav-link); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.search-btn:hover { color: var(--text-primary); border-color: var(--border-subtle); }
.search-btn kbd { font: 11px var(--mono); padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.search-dialog {
  width: min(680px, calc(100vw - 32px)); max-height: 80vh; margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}
.search-dialog::backdrop { background: rgba(12, 13, 14, 0.35); }
.search-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px 0; }
.search-head .side-label { margin: 0; }
.search-head button { font: 11px var(--mono); padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; }
#search { padding: 12px 20px 20px; --pagefind-ui-font: var(--sans); --pagefind-ui-border-radius: 6px; --pagefind-ui-scale: 0.85; }
@media (max-width: 760px) { .search-btn kbd { display: none; } }

/* Felix theme: Lapis blue on paper (brand kit, Design/felix/BRAND.md). */
.theme-felix {
  --accent: #0a28c8;
  --accent-subtle: rgba(10, 40, 200, 0.06);
}
.theme-felix ::selection { background: #0a28c8; color: #fff; }
.theme-felix .brand span:first-of-type { font-family: var(--sans); font-weight: 600; font-size: 16px; letter-spacing: -0.045em; }
.theme-felix .mesh {
  background:
    radial-gradient(ellipse at 15% 20%, hsl(229, 70%, 90%) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, hsl(229, 60%, 96%) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 80%, hsl(45, 25%, 96%) 0%, transparent 55%),
    radial-gradient(ellipse at 90% 90%, hsl(229, 65%, 92%) 0%, transparent 45%),
    linear-gradient(135deg, hsl(45, 22%, 97%) 0%, hsl(229, 40%, 96%) 100%);
}
.theme-felix .btn-sand {
  color: #fff; background: #0a28c8; border: 1px solid #0a28c8;
  box-shadow: 0 6px 24px rgba(10, 40, 200, 0.25); backdrop-filter: none;
}
.theme-felix .btn-sand .fm { border-color: #0a28c8; }
.theme-felix .btn-sand:hover { background: #0820a6; }
.theme-felix .toc a.on { color: #0a28c8; border-left-color: #0a28c8; }
.theme-felix .prose a:not(.anchor) { color: #0a28c8; }
