/* ============================================================
   Calculator Network — Shared Base Stylesheet
   Design language: Clean/technical with warmth. Precision tools.
   Fonts: Cabinet Grotesk (display) + Satoshi (body) — Fontshare
   ============================================================ */

@import url('https://api.fontshare.com/v2/css?f[]=cabinet-grotesk@400,500,700,800&f[]=satoshi@400,500,700&display=swap');

/* === TOKENS === */
:root {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  /* Spacing (4px grid) */
  --s1:  0.25rem;
  --s2:  0.5rem;
  --s3:  0.75rem;
  --s4:  1rem;
  --s5:  1.25rem;
  --s6:  1.5rem;
  --s8:  2rem;
  --s10: 2.5rem;
  --s12: 3rem;
  --s16: 4rem;
  --s20: 5rem;
  --s24: 6rem;

  /* Radius */
  --r-sm:  0.375rem;
  --r-md:  0.5rem;
  --r-lg:  0.75rem;
  --r-xl:  1rem;
  --r-2xl: 1.5rem;
  --r-full: 9999px;

  /* Transitions */
  --ease: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Fonts */
  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body:    'Satoshi', 'Inter', sans-serif;

  /* Content widths */
  --narrow:  640px;
  --default: 900px;
  --wide:    1160px;
}

/* === LIGHT MODE === */
:root, [data-theme="light"] {
  --bg:              #f5f4f0;
  --surface:         #faf9f7;
  --surface-2:       #ffffff;
  --surface-offset:  #edeae5;
  --border:          #dedad4;
  --divider:         #e5e2dc;

  --text:            #1e1c18;
  --text-muted:      #6e6c67;
  --text-faint:      #b5b3ae;
  --text-inverse:    #f9f8f5;

  /* Accent: sharp indigo-slate — precise, trustworthy, slightly tech */
  --accent:          #3b5bdb;
  --accent-hover:    #2f4ac4;
  --accent-active:   #2340a8;
  --accent-hi:       #dce3ff;
  --accent-subtle:   #eef1ff;

  --success:         #2f7a3b;
  --success-hi:      #d4edda;
  --warning:         #b45309;
  --warning-hi:      #fef3c7;
  --error:           #c0392b;
  --error-hi:        #fde8e8;

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 80 / 0.06);
  --shadow-md: 0 4px 16px oklch(0.2 0.02 80 / 0.08);
  --shadow-lg: 0 12px 40px oklch(0.2 0.02 80 / 0.12);
}

/* === DARK MODE === */
[data-theme="dark"] {
  --bg:              #12110f;
  --surface:         #181715;
  --surface-2:       #1e1d1b;
  --surface-offset:  #1c1b19;
  --border:          #2e2d2b;
  --divider:         #242320;

  --text:            #d4d2ce;
  --text-muted:      #7a7876;
  --text-faint:      #504e4b;
  --text-inverse:    #1e1d1b;

  --accent:          #7c9ef4;
  --accent-hover:    #9db3f7;
  --accent-active:   #beccfa;
  --accent-hi:       #1e2a52;
  --accent-subtle:   #16213a;

  --success:         #5ebd6d;
  --success-hi:      #1a3b22;
  --warning:         #f59e0b;
  --warning-hi:      #3b2a0a;
  --error:           #e05c5c;
  --error-hi:        #3b1a1a;

  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.25);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.35);
  --shadow-lg: 0 12px 40px oklch(0 0 0 / 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #12110f; --surface: #181715; --surface-2: #1e1d1b;
    --surface-offset: #1c1b19; --border: #2e2d2b; --divider: #242320;
    --text: #d4d2ce; --text-muted: #7a7876; --text-faint: #504e4b;
    --text-inverse: #1e1d1b;
    --accent: #7c9ef4; --accent-hover: #9db3f7; --accent-active: #beccfa;
    --accent-hi: #1e2a52; --accent-subtle: #16213a;
    --success: #5ebd6d; --success-hi: #1a3b22;
    --warning: #f59e0b; --warning-hi: #3b2a0a;
    --error: #e05c5c; --error-hi: #3b1a1a;
    --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.25);
    --shadow-md: 0 4px 16px oklch(0 0 0 / 0.35);
    --shadow-lg: 0 12px 40px oklch(0 0 0 / 0.45);
  }
}

/* === BASE RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--s16);
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

img, svg { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
h1,h2,h3,h4,h5,h6 { text-wrap: balance; line-height: 1.2; font-family: var(--font-display); }
p, li { text-wrap: pretty; max-width: 72ch; }

::selection { background: var(--accent-hi); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-sm); }
button { cursor: pointer; background: none; border: none; }

a, button, [role="button"], input, textarea, select {
  transition: color var(--ease), background var(--ease),
              border-color var(--ease), box-shadow var(--ease), opacity var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border-width: 0;
}

/* === SHARED LAYOUT UTILITIES === */
.container { width: 100%; max-width: var(--default); margin-inline: auto; padding-inline: var(--s6); }
.container--narrow { max-width: var(--narrow); }
.container--wide   { max-width: var(--wide); }

/* === SHARED COMPONENTS === */

/* Site header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--divider);
  padding: var(--s4) 0;
}
.site-header .inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--wide); margin-inline: auto; padding-inline: var(--s6);
}
.site-logo {
  display: flex; align-items: center; gap: var(--s3);
  text-decoration: none; color: var(--text);
  font-family: var(--font-display); font-weight: 800;
  font-size: var(--text-lg); letter-spacing: -0.02em;
}
.site-logo svg { color: var(--accent); flex-shrink: 0; }
.site-logo span em { font-style: normal; color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: var(--s3); }

.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); border: 1px solid var(--border);
}
.theme-toggle:hover { background: var(--surface-offset); color: var(--text); }

/* Back breadcrumb */
.breadcrumb {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--text-sm); color: var(--text-muted);
  padding: var(--s4) 0;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-faint); }

/* Page hero (calculator pages) */
.calc-hero {
  padding: var(--s12) 0 var(--s10);
  border-bottom: 1px solid var(--divider);
}
.calc-tag {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-subtle); border: 1px solid var(--accent-hi);
  padding: var(--s1) var(--s3); border-radius: var(--r-full);
  margin-bottom: var(--s4);
}
.calc-title {
  font-size: var(--text-2xl); font-weight: 800;
  letter-spacing: -0.03em; color: var(--text);
  margin-bottom: var(--s3);
}
.calc-subtitle {
  font-size: var(--text-base); color: var(--text-muted); max-width: 52ch;
}

/* Main calculator card */
.calc-body { padding: var(--s12) 0; }
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.calc-card-inner { padding: var(--s8); }
@media (min-width: 640px) { .calc-card-inner { padding: var(--s10); } }

/* Two-column calculator layout */
.calc-grid {
  display: grid;
  gap: var(--s8);
}
@media (min-width: 760px) {
  .calc-grid { grid-template-columns: 1fr 1fr; }
}

/* Input group */
.input-group { display: flex; flex-direction: column; gap: var(--s2); }
.input-group label {
  font-size: var(--text-sm); font-weight: 600; color: var(--text);
}
.input-group .hint { font-size: var(--text-xs); color: var(--text-muted); }
.input-wrap {
  position: relative; display: flex; align-items: center;
}
.input-wrap .prefix, .input-wrap .suffix {
  position: absolute; font-size: var(--text-sm); color: var(--text-muted);
  pointer-events: none; user-select: none;
}
.input-wrap .prefix { left: var(--s4); }
.input-wrap .suffix { right: var(--s4); }
.calc-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: var(--text-base);
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.calc-input::-webkit-inner-spin-button,
.calc-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.calc-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
.input-wrap .prefix ~ .calc-input { padding-left: var(--s8); }
.input-wrap .suffix ~ .calc-input,
.input-wrap .calc-input:has(~ .suffix) { padding-right: var(--s8); }
.input-wrap .calc-input.has-prefix { padding-left: var(--s8); }
.input-wrap .calc-input.has-suffix { padding-right: var(--s8); }

/* Range slider */
.range-wrap { display: flex; flex-direction: column; gap: var(--s2); }
.range-header { display: flex; justify-content: space-between; align-items: baseline; }
.range-header label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.range-value { font-size: var(--text-sm); font-weight: 700; color: var(--accent); font-family: var(--font-display); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 5px;
  background: var(--divider); border-radius: var(--r-full); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm); cursor: pointer;
}

/* Result panel */
.result-panel {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-hi);
  border-radius: var(--r-xl);
  padding: var(--s6);
  display: flex; flex-direction: column; gap: var(--s4);
}
.result-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.result-value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.result-sub { font-size: var(--text-sm); color: var(--text-muted); }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.result-item { display: flex; flex-direction: column; gap: var(--s1); }
.result-item .r-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; }
.result-item .r-value { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; color: var(--text); letter-spacing: -0.02em; }

/* CTA button */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2); padding: var(--s3) var(--s6);
  font-size: var(--text-sm); font-weight: 600; font-family: var(--font-display);
  border-radius: var(--r-md); text-decoration: none;
  border: 1.5px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-offset); border-color: var(--text-muted); }

/* Related tools card */
.related-section { padding: var(--s12) 0; border-top: 1px solid var(--divider); }
.related-section h2 { font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--s6); }
.tool-cards { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: var(--s6); text-decoration: none;
  color: var(--text); display: flex; flex-direction: column; gap: var(--s3);
}
.tool-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.tool-card-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--accent-subtle); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.tool-card h3 { font-size: var(--text-base); font-weight: 700; }
.tool-card p { font-size: var(--text-sm); color: var(--text-muted); }

/* Info sections below calculator */
.info-section { padding: var(--s12) 0; }
.info-section h2 { font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.02em; margin-bottom: var(--s4); }
.info-section p { color: var(--text-muted); margin-bottom: var(--s4); }
.info-section p:last-child { margin-bottom: 0; }
.formula-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s6); margin: var(--s6) 0;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: var(--text-sm); color: var(--text);
  overflow-x: auto; white-space: pre;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--divider);
  padding: var(--s10) 0;
  font-size: var(--text-sm); color: var(--text-muted);
}
.site-footer .inner {
  max-width: var(--wide); margin-inline: auto; padding-inline: var(--s6);
  display: flex; flex-wrap: wrap; gap: var(--s4);
  align-items: center; justify-content: space-between;
}
.footer-links { display: flex; gap: var(--s6); flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* Affiliate disclosure */
.disclosure {
  font-size: var(--text-xs); color: var(--text-faint);
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--divider); background: var(--surface);
  max-width: var(--narrow);
}

/* Utility classes */
.divider { border: none; border-top: 1px solid var(--divider); margin: var(--s6) 0; }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.mt-8 { margin-top: var(--s8); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.font-display { font-family: var(--font-display); }
.font-mono { font-family: 'JetBrains Mono', monospace; }
