/* ============================================================
   Clavesa — marketing site
   Light editorial / developer-tool. Self-contained, no CDN.
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("/fonts/plex-sans.woff2") format("woff2");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #fbfaf7;
  --bg-band:   #f3f1ea;
  --paper:     #ffffff;
  --ink:       #14151c;
  --ink-soft:  #46495a;
  --ink-dim:   #767a89;
  --line:      #e6e2d8;
  --line-2:    #efece3;
  --accent:    #2563eb;
  --accent-dk: #1d4ed8;
  --accent-sf: #eaf0ff;
  --btn:       #2563eb;
  --btn-h:     #1d4ed8;
  --code-bg:   #0e1320;
  --code-bg-2: #161d2e;
  --code-line: #26304a;
  --code-ink:  #d6def0;
  --code-dim:  #6b7690;
  --ok:        #34d399;

  /* "Inverted" feature panels (the dark card in the What grid, the highlighted
     Compare card). Dark-on-light here; a raised accent panel in dark mode. */
  --invert-bg: linear-gradient(180deg, #12151d, #0e1320);
  --invert-bd: #22283a;
  --invert-h:  #ffffff;
  --invert-p:  #aab3c9;
  --invert-ex: #7f8aa6;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono:  "Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wrap: 1120px;
  --r: 12px;
  color-scheme: light;
}

/* ---------- dark theme ----------
   Default follows the OS setting; the toggle sets data-theme to force one.
   The two selectors below carry identical values (the manual override and the
   system-default path). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0c0f17;
    --bg-band:   #10141f;
    --paper:     #151a27;
    --ink:       #eef1f8;
    --ink-soft:  #aab2c6;
    --ink-dim:   #7a8296;
    --line:      #262d3d;
    --line-2:    #1a2030;
    --accent:    #6ea8ff;
    --accent-dk: #5b90ff;
    --accent-sf: rgba(110,168,255,.13);
    --btn:       #3b82f6;
    --btn-h:     #2f74ea;
    --code-bg:   #0a0e18;
    --code-bg-2: #121826;
    --code-line: #242c40;
    --invert-bg: linear-gradient(180deg, #1c2436, #151b29);
    --invert-bd: var(--accent);
    --invert-h:  #ffffff;
    --invert-p:  #bcc4d8;
    --invert-ex: #8b95ad;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:        #0c0f17;
  --bg-band:   #10141f;
  --paper:     #151a27;
  --ink:       #eef1f8;
  --ink-soft:  #aab2c6;
  --ink-dim:   #7a8296;
  --line:      #262d3d;
  --line-2:    #1a2030;
  --accent:    #6ea8ff;
  --accent-dk: #5b90ff;
  --accent-sf: rgba(110,168,255,.13);
  --btn:       #3b82f6;
  --btn-h:     #2f74ea;
  --code-bg:   #0a0e18;
  --code-bg-2: #121826;
  --code-line: #242c40;
  --invert-bg: linear-gradient(180deg, #1c2436, #151b29);
  --invert-bd: var(--accent);
  --invert-h:  #ffffff;
  --invert-p:  #bcc4d8;
  --invert-ex: #8b95ad;
  color-scheme: dark;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  font-weight: 380;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 400; letter-spacing: -0.01em; }
p { margin: 0; }
code { font-family: var(--mono); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 28px; }

/* ---------- shared bits ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.eyebrow .idx {
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.arr { font-family: var(--mono); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  padding: 12px 20px; border-radius: 9px;
  border: 1px solid transparent;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  will-change: transform;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--btn); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 8px 22px -12px rgba(37,99,235,.7);
}
.btn--primary:hover { background: var(--btn-h); transform: translateY(-1px); }
.btn--ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink-dim); transform: translateY(-1px); }

/* ============================================================  NAV  */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, background .2s ease;
}
.nav.is-stuck { border-bottom-color: var(--line); }
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }

.wordmark {
  font-family: var(--mono); font-weight: 500; font-size: 19px;
  letter-spacing: -0.01em; color: var(--ink);
}
.wordmark .lam { color: var(--accent); }
.wordmark--lg { font-size: 26px; }

.nav__links { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.nav__links a {
  font-family: var(--mono); font-size: 13.5px; color: var(--ink-soft);
  transition: color .15s ease; position: relative;
}
.nav__links a:hover { color: var(--ink); }
.nav__links a:not(.nav__gh)::after {
  content: ""; position: absolute; left: 0; bottom: -6px; height: 1.5px; width: 0;
  background: var(--accent); transition: width .2s ease;
}
.nav__links a:not(.nav__gh):hover::after { width: 100%; }
.nav__gh {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
  background: var(--paper);
}
.nav__gh:hover { border-color: var(--ink-dim); }

/* theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: 18px; flex: none;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
  color: var(--ink-soft); cursor: pointer;
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-dim); transform: translateY(-1px); }
.theme-toggle .ic { width: 18px; height: 18px; }
.ic--sun { display: none; }
.ic--moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic--moon { display: none; }
  :root:not([data-theme="light"]) .ic--sun  { display: block; }
}
:root[data-theme="dark"] .ic--moon { display: none; }
:root[data-theme="dark"] .ic--sun  { display: block; }

.nav__toggle { display: none; }

/* ============================================================  HERO  */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 55% at 88% -5%, rgba(37,99,235,.10), transparent 60%),
    radial-gradient(50% 40% at 0% 0%, rgba(37,99,235,.05), transparent 60%);
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: .5;
  background-image:
    linear-gradient(var(--line-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% -10%, #000 25%, transparent 72%);
  mask-image: radial-gradient(120% 90% at 50% -10%, #000 25%, transparent 72%);
}
.hero__grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 56px; align-items: center;
  padding: clamp(56px, 9vw, 116px) 28px clamp(60px, 8vw, 104px);
}

.hero__title {
  font-family: var(--serif);
  font-size: clamp(44px, 6.4vw, 82px);
  line-height: 0.99;
  letter-spacing: -0.028em;
  font-weight: 460;
  margin-bottom: 26px;
}
.hero__sub {
  font-size: clamp(17px, 1.6vw, 20px);
  color: var(--ink-soft); max-width: 33ch; line-height: 1.55;
}
.hero__cta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 34px; }
.hero__foot {
  margin-top: 30px; font-size: 14px; color: var(--ink-dim);
  font-family: var(--mono);
}
.hero__foot em { color: var(--ink-soft); font-style: normal; }

/* staggered reveal */
.hero__copy > * { opacity: 0; transform: translateY(14px); animation: rise .7s cubic-bezier(.2,.7,.2,1) forwards; }
.hero__copy > .eyebrow    { animation-delay: .02s; }
.hero__copy > .hero__title{ animation-delay: .09s; }
.hero__copy > .hero__sub  { animation-delay: .17s; }
.hero__copy > .hero__cta  { animation-delay: .25s; }
.hero__copy > .hero__foot { animation-delay: .33s; }
.hero__term { opacity: 0; transform: translateY(18px) scale(.99); animation: rise .8s .34s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- terminal ---------- */
.term {
  margin: 0; border-radius: 14px; overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  box-shadow: 0 40px 80px -40px rgba(15,20,32,.55), 0 2px 0 rgba(255,255,255,.4) inset;
}
.term__bar {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 14px; background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-line);
}
.term__dot { width: 11px; height: 11px; border-radius: 50%; background: #38415a; }
.term__dot:nth-child(1){ background:#ec6a5e; } .term__dot:nth-child(2){ background:#f4bf4f; } .term__dot:nth-child(3){ background:#61c554; }
.term__name { margin-left: 8px; font-family: var(--mono); font-size: 12px; color: var(--code-dim); }
.term__body, .code__body {
  margin: 0; padding: 18px 20px; overflow-x: auto;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.85; color: var(--code-ink);
}
.term__body .pr { color: var(--accent); }
.term__body .pr { color: #6ea8ff; }
.term .dim, .code .dim { color: var(--code-dim); }
.term .ok { color: var(--ok); }
.term .lnk { color: #7cc5ff; text-decoration: underline; text-underline-offset: 2px; }
.term .env { color: #f4bf4f; }
.cur { display: inline-block; width: 8px; height: 1.05em; background: #6ea8ff; vertical-align: -2px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.term__cap { margin-top: 14px; font-size: 13.5px; color: var(--ink-dim); font-family: var(--mono); text-align: center; }
.term--inline { box-shadow: 0 24px 48px -34px rgba(15,20,32,.5); }

/* copy button */
.copy {
  margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--code-dim);
  background: transparent; border: 1px solid var(--code-line); border-radius: 6px;
  padding: 3px 9px; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.copy:hover { color: var(--code-ink); border-color: #3a465f; }
.copy.is-done { color: var(--ok); border-color: rgba(52,211,153,.5); }

/* ============================================================  SECTIONS  */
.section { padding: clamp(64px, 9vw, 108px) 0; border-top: 1px solid var(--line); }
.section--band { background: var(--bg-band); }
.section__title {
  font-family: var(--serif); font-weight: 450;
  font-size: clamp(28px, 3.6vw, 42px); line-height: 1.08; letter-spacing: -0.02em;
  max-width: 20ch;
}
.section__lead {
  margin-top: 20px; max-width: 62ch; font-size: clamp(16px, 1.4vw, 18.5px);
  color: var(--ink-soft);
}

/* ---------- what: cards ---------- */
.cards {
  margin-top: 48px; display: grid; gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 26px 24px 24px; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 22px 40px -30px rgba(20,21,28,.4); border-color: #d8d3c6; }
.card__ico {
  display: inline-flex; width: 40px; height: 40px; border-radius: 10px;
  align-items: center; justify-content: center; color: var(--accent);
  background: var(--accent-sf); margin-bottom: 16px;
}
.card__ico svg { width: 21px; height: 21px; }
.card h3 { font-family: var(--sans); font-weight: 560; font-size: 17.5px; letter-spacing: -0.01em; margin-bottom: 7px; }
.card p { font-size: 15px; color: var(--ink-soft); line-height: 1.55; }
.card p code { font-size: 13px; background: var(--bg-band); padding: 1px 5px; border-radius: 4px; }
.card--muted { background: var(--invert-bg); border-color: var(--invert-bd); }
.card--muted h3 { color: var(--invert-h); }
.card--muted p { color: var(--invert-p); }

/* ---------- how: ladder ---------- */
.ladder {
  margin-top: 46px; display: flex; align-items: stretch; flex-wrap: wrap; gap: 10px;
}
.ladder__step {
  flex: 1 1 0; min-width: 130px; display: flex; flex-direction: column; gap: 3px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px;
}
.ladder__step--hi { border-color: var(--accent); background: var(--accent-sf); }
.ladder__k { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--ink); }
.ladder__step--hi .ladder__k { color: var(--accent-dk); }
.ladder__v { font-size: 13px; color: var(--ink-dim); }
.ladder__arr { align-self: center; color: var(--ink-dim); font-family: var(--mono); }
.ladder__note { margin-top: 18px; font-size: 15px; color: var(--ink-soft); }
.ladder__note strong { color: var(--ink); font-weight: 600; }

.how__grid { margin-top: 44px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 32px; align-items: start; }
.how__aside h3 { font-family: var(--serif); font-size: 24px; font-weight: 450; letter-spacing: -0.015em; margin-bottom: 12px; }
.how__aside > p { color: var(--ink-soft); font-size: 15.5px; }
.how__aside .term--inline { margin-top: 20px; }
.how__fine { margin-top: 14px; font-size: 13.5px; color: var(--ink-dim); font-family: var(--mono); }

/* ---------- code blocks (light-captioned, dark body) ---------- */
.code {
  margin: 0; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--code-line); background: var(--code-bg);
  box-shadow: 0 30px 60px -44px rgba(15,20,32,.6);
}
.code__cap {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; background: var(--code-bg-2); border-bottom: 1px solid var(--code-line);
  font-family: var(--mono); font-size: 12px;
}
.code__lang { color: var(--accent); font-weight: 500; }
.code__file { color: var(--code-dim); }
.code__body .kw  { color: #c792ea; }
.code__body .fn  { color: #82aaff; }
.code__body .num { color: #f78c6c; }
.code__body .str { color: #c3e88d; }

/* ---------- why: compare ---------- */
.compare { margin-top: 48px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.comp {
  border: 1px solid var(--line); border-radius: var(--r); padding: 24px 22px;
  background: var(--paper); display: flex; flex-direction: column;
}
.comp__k { font-family: var(--mono); font-weight: 500; font-size: 15px; }
.comp__ex { font-size: 12.5px; color: var(--ink-dim); margin-top: 4px; margin-bottom: 16px; min-height: 2.6em; }
.comp__t { font-size: 14.5px; color: var(--ink-soft); line-height: 1.5; }
.comp--hi {
  background: var(--invert-bg);
  border-color: var(--invert-bd); position: relative;
}
.comp--hi::before {
  content: ""; position: absolute; inset: -1px; border-radius: var(--r);
  padding: 1px; background: linear-gradient(150deg, var(--accent), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.comp--hi .comp__k { color: var(--invert-h); } .comp--hi .comp__k .lam { color: #6ea8ff; }
.comp--hi .comp__ex { color: var(--invert-ex); }
.comp--hi .comp__t { color: var(--invert-p); }

/* ---------- pillars ---------- */
.pillars { margin-top: 46px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.pillar {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 30px 30px 28px;
}
.pillar h3 { font-family: var(--serif); font-weight: 460; font-size: 22px; letter-spacing: -0.015em; margin-bottom: 12px; }
.pillar p { color: var(--ink-soft); font-size: 15.5px; }
.pillar__code {
  margin: 18px 0 0; padding: 15px 17px; border-radius: 10px;
  background: var(--code-bg); border: 1px solid var(--code-line);
  font-family: var(--mono); font-size: 13px; line-height: 1.7; color: var(--code-ink); overflow-x: auto;
}
.pillar__code .kw { color: #c792ea; } .pillar__code .str { color: #c3e88d; }

/* ---------- get started ---------- */
.start__grid { margin-top: 46px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.code--start .code__body { font-size: 13px; }
.start__cta { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 14px; }

/* ============================================================  FOOTER  */
.foot { border-top: 1px solid var(--line); padding: 60px 0 40px; background: var(--bg-band); }
.foot__inner { display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; align-items: start; }
.foot__tag { margin-top: 12px; max-width: 34ch; color: var(--ink-soft); font-size: 14.5px; }
.foot__links { display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, auto); gap: 10px 40px; }
.foot__links a { font-family: var(--mono); font-size: 13.5px; color: var(--ink-soft); transition: color .15s; }
.foot__links a:hover { color: var(--accent); }
.foot__legal {
  margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim);
}

/* Let grid items shrink below their content's min-content, so the code and
   terminal blocks scroll inside their own overflow-x box instead of stretching
   the whole page on narrow screens. */
.hero__grid > *, .how__grid > *, .start__grid > *,
.cards > *, .compare > *, .pillars > * { min-width: 0; }
.term, .code, .pillar__code { max-width: 100%; }

/* ============================================================  RESPONSIVE  */
@media (max-width: 900px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .hero__sub { max-width: 46ch; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .how__grid { grid-template-columns: minmax(0, 1fr); }
  .compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comp__ex { min-height: 0; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .nav__links { display: none; }
  .nav__links.is-open {
    display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
    position: absolute; top: 64px; left: 0; right: 0; padding: 22px 28px 26px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .theme-toggle { margin-left: auto; margin-right: 10px; }
  .nav__toggle {
    display: inline-flex; flex-direction: column; gap: 5px; justify-content: center;
    width: 40px; height: 40px; background: transparent; border: 1px solid var(--line);
    border-radius: 8px; cursor: pointer;
  }
  .nav__toggle span { display: block; width: 18px; height: 1.8px; background: var(--ink); margin-inline: auto; transition: transform .2s, opacity .2s; }
  .nav__toggle[aria-expanded="true"] span:first-child { transform: translateY(3.4px) rotate(45deg); }
  .nav__toggle[aria-expanded="true"] span:last-child { transform: translateY(-3.4px) rotate(-45deg); }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .pillars { grid-template-columns: minmax(0, 1fr); }
  .start__grid { grid-template-columns: minmax(0, 1fr); }
  .ladder { flex-direction: column; align-items: stretch; }
  .ladder__arr { transform: rotate(90deg); }
  .ladder__step { min-width: 0; width: 100%; }
  .foot__inner { flex-direction: column; }
}
