/* ==========================================================================
   APICalculators — Design System v2
   Concept: "OVERCLOCKED LEDGER" — maximalist trading-floor energy meets a
   developer terminal. Huge, over-scaled serif numerals stamped onto a
   near-black void, torn between acid-lime and electric-magenta, with a
   restless gradient-mesh atmosphere, thick ink borders, and staggered
   reveal animation. Nothing here is polite.
   ========================================================================== */

@font-face { font-family: "Fraunces"; src: local("Fraunces"); }

:root {
  /* ---- Palette: Void / Lime / Magenta ---- */
  --void-950: #060608;
  --void-900: #0c0d12;
  --void-850: #121319;
  --void-800: #191b23;
  --void-700: #262834;
  --void-600: #3a3d4c;
  --void-400: #7b7f92;
  --void-200: #c7c9d6;
  --void-100: #e7e8ef;
  --paper-0:  #f7f5ee;
  --paper-50: #ece7d8;
  --paper-100:#ddd6c0;

  --lime-600: #7ea300;
  --lime-500: #a6d90a;
  --lime-400: #c4ff1f;
  --lime-300: #d9ff6b;
  --lime-100: #eaffb0;

  --magenta-600:#c81e6d;
  --magenta-500:#ef2b8a;
  --magenta-400:#ff5cab;
  --magenta-100:#ffe0f0;

  --cyan-400: #35e5d1;
  --amber-400:#ffb020;

  --success:#3fd17a; --success-soft:#0f2b1c;
  --danger:#ff5c5c;  --danger-soft:#2e1216;

  /* ---- Semantic tokens: DARK is the default identity of this brand ---- */
  --bg: var(--void-950);
  --bg-raised: var(--void-900);
  --bg-sunken: var(--void-850);
  --bg-inverse: var(--paper-0);
  --border: var(--void-700);
  --border-strong: var(--void-600);
  --text: var(--paper-0);
  --text-muted: var(--void-200);
  --text-faint: var(--void-400);
  --text-inverse: var(--void-950);
  --accent: var(--lime-400);
  --accent-strong: var(--lime-300);
  --accent-on: #0c1400;
  --accent-soft: #232d05;
  --accent2: var(--magenta-500);
  --accent2-on: #2c0016;
  --focus-ring: var(--cyan-400);
  --line-strong: var(--paper-0);

  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Public Sans", "Segoe UI", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.9rem;
  --fs-base: 1.05rem;
  --fs-md: 1.25rem;
  --fs-lg: 1.6rem;
  --fs-xl: 2.25rem;
  --fs-2xl: 3.25rem;
  --fs-3xl: clamp(3rem, 4vw + 1.5rem, 6.5rem);

  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-6: 1.5rem; --sp-8: 2rem; --sp-12: 3rem; --sp-16: 4rem; --sp-24: 7rem;

  --radius-sm: 3px; --radius-md: 6px; --radius-lg: 10px;
  --shadow-card: 6px 6px 0 0 var(--void-700);
  --shadow-raised: 10px 10px 0 0 var(--accent);
  --ease: cubic-bezier(.16,1,.3,1);
}

/* ---- Explicit LIGHT theme (opt-in via toggle) ---- */
:root[data-theme="light"] {
  --bg: var(--paper-0);
  --bg-raised: #ffffff;
  --bg-sunken: var(--paper-50);
  --bg-inverse: var(--void-950);
  --border: var(--paper-100);
  --border-strong: var(--void-200);
  --text: var(--void-950);
  --text-muted: var(--void-600);
  --text-faint: var(--void-400);
  --text-inverse: var(--paper-0);
  --accent: var(--lime-600);
  --accent-strong: #648900;
  --accent-on: #0c1400;
  --accent-soft: var(--lime-100);
  --accent2: var(--magenta-600);
  --line-strong: var(--void-950);
  --shadow-card: 6px 6px 0 0 var(--void-950);
  --shadow-raised: 10px 10px 0 0 var(--magenta-500);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
  position: relative;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; }
::selection { background: var(--accent); color: var(--accent-on); }

/* atmosphere: layered radial gradient mesh + diagonal scanlines + grain */
body::before {
  content: "";
  position: fixed; inset: -10%;
  z-index: 0; pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 8% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(50rem 36rem at 110% 10%, color-mix(in srgb, var(--accent2) 24%, transparent), transparent 60%),
    radial-gradient(40rem 30rem at 50% 120%, color-mix(in srgb, var(--cyan-400) 12%, transparent), transparent 60%);
  filter: blur(2px);
  animation: drift 22s ease-in-out infinite alternate;
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .05; mix-blend-mode: overlay;
  background-image: repeating-linear-gradient(115deg, #fff 0 1px, transparent 1px 3px);
}
@keyframes drift { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(-2%,1%,0) scale(1.04); } }

/* ---- Layout ---- */
.wrap { max-width: 1200px; margin-inline: auto; padding-inline: var(--sp-6); position: relative; z-index: 1; }
.wrap--narrow { max-width: 780px; }

/* ---- Typography ---- */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: .98; margin: 0 0 var(--sp-4); letter-spacing: -.02em; }
h1 { font-size: var(--fs-3xl); font-weight: 700; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-4); color: var(--text-muted); }
.eyebrow {
  display: inline-flex; align-items: center; gap: .6em;
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent-on); background: var(--accent);
  padding: .35em .8em; border-radius: 999px; font-weight: 700;
  box-shadow: 3px 3px 0 0 var(--line-strong);
}
.eyebrow::before { content: "●"; font-size: .6em; }
.figure, .mono, code, kbd { font-family: var(--font-mono); }

/* ---- Reveal-on-load animation ---- */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
.hero > * { animation: rise .7s var(--ease) both; }
.hero > *:nth-child(2) { animation-delay: .06s; }
.hero > *:nth-child(3) { animation-delay: .12s; }
.hero > *:nth-child(4) { animation-delay: .18s; }
.grid > *, .calc { animation: rise .6s var(--ease) both; }
.grid > *:nth-child(3n+1) { animation-delay: .03s; }
.grid > *:nth-child(3n+2) { animation-delay: .09s; }
.grid > *:nth-child(3n+3) { animation-delay: .15s; }

/* ---- Nav ---- */
.site-nav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--line-strong);
}
.site-nav__inner { display: flex; align-items: center; justify-content: space-between; padding-block: var(--sp-4); gap: var(--sp-6); }
.brand { display: flex; align-items: center; gap: .6em; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); text-decoration: none; color: var(--text); }
.brand__mark {
  width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-on);
  display: grid; place-items: center; font-family: var(--font-mono); font-weight: 800; font-size: 14px;
  box-shadow: 3px 3px 0 0 var(--line-strong); transform: rotate(-6deg);
}
.nav-links { display: flex; gap: var(--sp-6); list-style: none; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; transition: color .15s var(--ease); }
.nav-links a:hover { color: var(--accent); }
.theme-toggle {
  border: 2px solid var(--line-strong); background: var(--bg-raised); color: var(--text); border-radius: var(--radius-md);
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  box-shadow: 3px 3px 0 0 var(--line-strong); transition: transform .12s var(--ease);
}
.theme-toggle:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 0 var(--accent); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .8em 1.5em; border-radius: var(--radius-md); font-weight: 800; font-size: var(--fs-sm);
  text-decoration: none; cursor: pointer; border: 2px solid var(--line-strong);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
  box-shadow: 4px 4px 0 0 var(--line-strong);
}
.btn:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 0 var(--line-strong); }
.btn:active { transform: translate(1px,1px); box-shadow: 2px 2px 0 0 var(--line-strong); }
.btn--primary { background: var(--accent); color: var(--accent-on); }
.btn--ghost { background: var(--bg-raised); color: var(--text); }
.btn--ghost:hover { background: var(--accent2); color: #fff; border-color: var(--line-strong); }

/* ---- Hero ---- */
.hero { padding-block: var(--sp-24) var(--sp-16); text-align: left; position: relative; }
.hero h1 { max-width: 15ch; }
.hero h1 em { font-style: normal; color: var(--accent); text-shadow: 3px 3px 0 var(--accent2); }
.hero p.lede { font-size: var(--fs-md); max-width: 46ch; color: var(--text-muted); }

/* ---- Cards / calculator grid ---- */
.grid { display: grid; gap: var(--sp-6); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--bg-raised); border: 2px solid var(--line-strong); border-radius: var(--radius-lg);
  padding: var(--sp-6); box-shadow: var(--shadow-card);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: var(--sp-3);
}
.card:hover { transform: translate(-4px,-4px); box-shadow: var(--shadow-raised); }
.card:nth-child(4n+2):hover { box-shadow: 10px 10px 0 0 var(--accent2); }
.card:nth-child(4n+3):hover { box-shadow: 10px 10px 0 0 var(--cyan-400); }
.card__icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-on);
  display: grid; place-items: center; font-family: var(--font-mono); font-weight: 800; font-size: 1.1em;
  box-shadow: 3px 3px 0 0 var(--line-strong);
}
.card__title { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; margin: 0; }
.card__desc { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.card__meta { margin-top: auto; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); padding-top: var(--sp-2); border-top: 1px dashed var(--border-strong); }

/* ---- Calculator panel (input + result) ---- */
.calc {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  background: var(--bg-raised); border: 2px solid var(--line-strong); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: 8px 8px 0 0 var(--accent2);
}
.calc__inputs { padding: var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-4); }
.calc__result {
  padding: var(--sp-8); background: var(--bg-inverse); color: var(--text-inverse);
  display: flex; flex-direction: column; justify-content: center; gap: var(--sp-2);
  position: relative; overflow: hidden;
}
.calc__result::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(30rem 20rem at 100% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%);
  pointer-events: none;
}
.field { display: flex; flex-direction: column; gap: var(--sp-2); position: relative; z-index: 1; }
.field label { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.field .hint { font-size: var(--fs-xs); color: var(--text-faint); }
.field input, .field select {
  font: inherit; font-family: var(--font-mono); padding: .7em .85em; border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong); background: var(--bg-sunken); color: var(--text); width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 3px 3px 0 0 var(--accent); }
.result__label { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; position: relative; z-index: 1; }
.result__value { font-family: var(--font-mono); font-size: var(--fs-3xl); font-weight: 800; line-height: .95; position: relative; z-index: 1; }
.result__sub { font-size: var(--fs-sm); color: color-mix(in srgb, var(--text-inverse) 65%, transparent); position: relative; z-index: 1; }
.result__break { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: var(--fs-sm); padding-block: var(--sp-2); border-top: 1px dashed color-mix(in srgb, var(--text-inverse) 25%, transparent); position: relative; z-index: 1; }
@media (max-width: 760px) { .calc { grid-template-columns: 1fr; } }

/* ---- Table (comparisons) ---- */
.table-wrap { overflow-x: auto; border: 2px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); background: var(--bg-raised); }
th, td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--accent-on); background: var(--accent); font-weight: 800; }
td.num, th.num { font-family: var(--font-mono); text-align: right; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-sunken); }

/* ---- FAQ / accordion ---- */
.faq-item { border-bottom: 2px solid var(--border); padding-block: var(--sp-4); }
.faq-item summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-md); font-family: var(--font-display); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; font-family: var(--font-mono); color: var(--accent-on); background: var(--accent);
  width: 1.6em; height: 1.6em; border-radius: 50%; display: grid; place-items: center; font-size: .8em; flex: none;
}
.faq-item[open] summary::after { content: "−"; background: var(--accent2); color: #fff; }
.faq-item p { margin-top: var(--sp-3); }

/* ---- Section rhythm ---- */
.section { padding-block: var(--sp-16); border-top: 2px solid var(--border); }
.section-head { max-width: 60ch; margin-bottom: var(--sp-8); }

/* ---- Footer ---- */
.site-footer { border-top: 2px solid var(--line-strong); padding-block: var(--sp-12); margin-top: var(--sp-16); background: var(--bg-raised); }
.footer-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: var(--sp-8); }
.footer-grid h4 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .1em; font-family: var(--font-mono); color: var(--accent); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.footer-grid a { text-decoration: none; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom { margin-top: var(--sp-12); padding-top: var(--sp-6); border-top: 1px dashed var(--border-strong); display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--font-mono); }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ---- Utility ---- */
.badge { display: inline-flex; align-items: center; gap: .4em; padding: .35em .8em; border-radius: 999px; font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--accent); color: var(--accent-on); font-weight: 800; box-shadow: 2px 2px 0 0 var(--line-strong); }
.badge--success { background: var(--success); color: #05170c; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  body::before { animation: none; }
}
