/* ═══════════════════════════════════════════════════════════════════════
   CALCIVUS — GLOBAL STYLESHEET
   Enhanced & production-ready
═══════════════════════════════════════════════════════════════════════ */

/* ── CSS VARIABLES ──────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:       #0A0F16;
  --bg2:      #111820;
  --bg3:      #171F29;
  --bg4:      #1C2533;

  /* Borders */
  --border:   #2A3444;
  --border2:  #1E2A38;

  /* Brand */
  --accent:        #2563EB;
  --accent-light:  #3B82F6;
  --accent-dark:   #1D4ED8;
  --accent-glow:   rgba(37, 99, 235, 0.18);
  --accent-glow2:  rgba(37, 99, 235, 0.08);

  /* Gradient */
  --grad-brand: linear-gradient(135deg, #3B82F6, #06B6D4);
  --grad-green: linear-gradient(135deg, #10B981, #3B82F6);
  --grad-warm:  linear-gradient(135deg, #F59E0B, #EF4444);

  /* Text */
  --text:   #E8EFF8;
  --text2:  #8B96A8;
  --text3:  #5A6478;

  /* Semantic colours */
  --green:   #3FB950;
  --orange:  #F0883E;
  --pink:    #FF7B72;
  --cyan:    #39C5CF;
  --yellow:  #E3B341;
  --purple:  #A78BFA;

  /* Shape */
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);

  /* Transitions */
  --transition: 0.2s ease;
}

/* ── RESET & BASE ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

/* ── SCROLLBAR ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
::selection { background: var(--accent-glow); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════
   NAVIGATION
═══════════════════════════════════════════════════════════════════════ */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 15, 22, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border2);
  padding: 0 28px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition);
}

/* Logo */
.nav-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -1px;
  font-family: 'Outfit', sans-serif;
  display: flex;
  align-items: center;
  gap: 0;
  transition: opacity var(--transition);
}
.nav-logo:hover { opacity: 0.85; }
.nav-logo .logo-calc { color: var(--text); }
.nav-logo .logo-ivus {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Nav links */
.nav-links { display: flex; gap: 2px; align-items: center; }
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  text-decoration: none;
  padding: 6px 13px;
  border-radius: 7px;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.nav-link:hover { color: var(--text); background: var(--bg3); }
.nav-link.active { color: var(--accent-light); }

.nav-cta {
  font-size: 13px;
  font-weight: 600;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 7px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.nav-cta:hover {
  background: var(--accent-light);
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
  transform: translateY(-1px);
}

/* Hamburger */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 7px;
  transition: all var(--transition);
}
.nav-hamburger:hover { background: var(--bg3); color: var(--text); }

/* Mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  top: 62px;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border2);
  padding: 12px 16px;
  z-index: 99;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-md);
}
.mobile-nav.open { display: flex; animation: slideDown .2s ease; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mobile-nav a {
  color: var(--text2);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}
.mobile-nav a:hover { background: var(--bg3); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════
   LAYOUT UTILITIES
═══════════════════════════════════════════════════════════════════════ */
.container    { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 780px;  margin: 0 auto; padding: 0 24px; }
.section { padding: 52px 0; }

/* ── BREADCRUMB ─────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text3);
  padding: 18px 0 0;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--text3);
  text-decoration: none;
  transition: color var(--transition);
}
.breadcrumb a:hover { color: var(--text2); }
.breadcrumb-sep { color: var(--border); }

/* ── PAGE HERO ──────────────────────────────────────────────────────── */
.page-hero { padding: 52px 0 36px; }
.page-hero h1 {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 14px;
}
.page-hero h1 em {
  font-style: normal;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-hero p {
  font-size: 16px;
  color: var(--text2);
  max-width: 580px;
  line-height: 1.75;
}

/* ── BADGE ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 100px;
  padding: 4px 14px;
}
.badge-blue {
  background: var(--accent-glow2);
  color: var(--accent-light);
  border: 1px solid rgba(37, 99, 235, .25);
}
.badge-green {
  background: rgba(63, 185, 80, .1);
  color: var(--green);
  border: 1px solid rgba(63,185,80,.2);
}

/* ── CARDS ──────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  text-decoration: none;
  display: block;
}
.card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--bg3);
}

/* ═══════════════════════════════════════════════════════════════════════
   CALCULATOR WIDGET
═══════════════════════════════════════════════════════════════════════ */
.calc-wrap {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.calc-wrap:hover { box-shadow: var(--shadow-md); }

.calc-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg2) 100%);
}
.calc-head-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.calc-head-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.calc-head-cat {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.calc-head-cat::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.calc-body { padding: 28px; }

/* ── FORM INPUTS ────────────────────────────────────────────────────── */
.calc-inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 22px;
}
.input-group { display: flex; flex-direction: column; gap: 7px; }
.input-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.calc-input {
  width: 100%;
  height: 48px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 15px;
  padding: 0 16px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.calc-input:hover { border-color: var(--text3); }
.calc-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg4);
}
.calc-input::placeholder { color: var(--text3); }

.calc-select {
  width: 100%;
  height: 48px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  padding: 0 16px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A6478' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color var(--transition);
}
.calc-select:hover { border-color: var(--text3); }
.calc-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); outline: none; }
.calc-select option { background: var(--bg2); color: var(--text); }

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── CALCULATE BUTTON ───────────────────────────────────────────────── */
.calc-btn {
  width: 100%;
  height: 52px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.03em;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
  position: relative;
  overflow: hidden;
}
.calc-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.12) 0%, transparent 60%);
  pointer-events: none;
}
.calc-btn:hover {
  background: var(--accent-light);
  box-shadow: 0 6px 20px rgba(37, 99, 235, .45);
  transform: translateY(-1px);
}
.calc-btn:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(37,99,235,.3); }

/* ── RESULT BOX ─────────────────────────────────────────────────────── */
.result-box {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-top: 22px;
  display: none;
  position: relative;
  overflow: hidden;
}
.result-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-brand);
}
.result-box.show {
  display: block;
  animation: resultReveal .35s cubic-bezier(.16,1,.3,1);
}
@keyframes resultReveal {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.result-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.result-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 30px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: -0.5px;
  word-break: break-all;
  line-height: 1.2;
}
.result-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 8px;
  line-height: 1.6;
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.result-item {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color var(--transition);
}
.result-item:hover { border-color: var(--border); }
.result-item-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-bottom: 5px;
}
.result-item-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.copy-btn {
  margin-top: 16px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text2);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.copy-btn:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg3);
}

/* ── FORMULA BOX ────────────────────────────────────────────────────── */
.formula-box {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 20px;
}
.formula-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.formula-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--accent-light);
  letter-spacing: 0.03em;
  line-height: 1.7;
}
.formula-desc {
  font-size: 13px;
  color: var(--text2);
  margin-top: 10px;
  line-height: 1.7;
}

/* ── CONTENT SECTIONS ───────────────────────────────────────────────── */
.content-section {
  margin-top: 44px;
  padding-top: 36px;
  border-top: 1px solid var(--border2);
}
.content-section h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.4px;
}
.content-section p {
  font-size: 15px;
  color: var(--text2);
  line-height: 1.85;
  margin-bottom: 14px;
}
.content-section ol,
.content-section ul {
  margin: 10px 0 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.content-section li {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.75;
}

/* ── FAQ ────────────────────────────────────────────────────────────── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.faq-item {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--border); }
.faq-item.open { border-color: var(--accent); }
.faq-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 15px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background var(--transition);
  gap: 12px;
}
.faq-q:hover { background: var(--bg2); }
.faq-toggle {
  color: var(--text3);
  font-size: 20px;
  transition: transform .25s ease, color .2s;
  flex-shrink: 0;
  font-weight: 300;
}
.faq-item.open .faq-toggle { transform: rotate(45deg); color: var(--accent-light); }
.faq-a {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.75;
  padding: 0 18px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .3s ease;
}
.faq-item.open .faq-a { max-height: 400px; padding: 0 18px 16px; }

/* ── RELATED CALCULATORS ────────────────────────────────────────────── */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.related-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--transition);
}
.related-card:hover {
  border-color: var(--accent);
  background: var(--bg3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,.12);
}
.related-icon { font-size: 22px; flex-shrink: 0; }
.related-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.related-cat {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════════════════ */
footer {
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  padding: 52px 24px 36px;
  margin-top: 80px;
}
.footer-inner { max-width: 1180px; margin: 0 auto; }
.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 36px;
  margin-bottom: 44px;
}
.footer-brand .brand-name {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  color: var(--text);
}
.footer-brand .brand-name span {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.footer-brand p { font-size: 13px; color: var(--text3); line-height: 1.7; max-width: 260px; }

.footer-col h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.footer-col a {
  font-size: 13px;
  color: var(--text3);
  text-decoration: none;
  transition: color var(--transition);
  display: inline-block;
}
.footer-col a:hover { color: var(--text2); }

.footer-bottom {
  border-top: 1px solid var(--border2);
  padding-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-bottom p { font-size: 12px; color: var(--text3); }

/* ═══════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 500;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow-md);
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  nav { padding: 0 16px; height: 58px; }
  .nav-links { display: none; }
  .nav-hamburger { display: block; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-brand { grid-column: 1 / -1; }

  .input-row { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr 1fr; }

  .page-hero { padding: 36px 0 24px; }
  .section { padding: 36px 0; }
  .calc-body { padding: 20px; }

  .container { padding: 0 16px; }
  .container-sm { padding: 0 16px; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .page-hero h1 { letter-spacing: -0.8px; }
  .calc-head { padding: 16px 18px; }
  .calc-body { padding: 16px; }
}

/* ── PRINT ──────────────────────────────────────────────────────────── */
@media print {
  nav, footer, .mobile-nav, .toast { display: none !important; }
  body { background: white; color: black; }
}