/* =========================================================
   Kalkylatory.com — Design System
   Fast, accessible, AdSense-friendly. No external CSS deps.
   ========================================================= */

:root {
  /* Brand palette — calm teal/emerald, warm neutrals */
  --brand-50:  #ecfdf5;
  --brand-100: #d1fae5;
  --brand-200: #a7f3d0;
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;
  --brand-800: #065f46;

  --accent-500: #6366f1;   /* indigo accent for scientific keys */
  --accent-600: #4f46e5;

  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --surface-2: #f1f3f6;
  --border:    #e3e7ee;
  --text:      #14181f;
  --text-2:    #4a5361;
  --text-3:    #7b8494;

  --danger:    #e5484d;
  --warn:      #d9820b;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);

  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --maxw: 1120px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0d1117;
    --surface:   #161b22;
    --surface-2: #1c2330;
    --border:    #2a3240;
    --text:      #e8edf4;
    --text-2:    #aab4c2;
    --text-3:    #7b8494;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 14px rgba(0,0,0,.45);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #1c2330;
  --border:    #2a3240;
  --text:      #e8edf4;
  --text-2:    #aab4c2;
  --text-3:    #7b8494;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 750; letter-spacing: -.02em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 1.05rem + 1.3vw, 1.9rem); margin-top: 2.2em; }
h3 { font-size: 1.2rem; margin-top: 1.6em; }
p { color: var(--text-2); }
ul, ol { color: var(--text-2); padding-left: 1.3em; }
li { margin: .35em 0; }

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
.narrow { max-width: 780px; }

/* ---------- Skip link ---------- */
.skip { position: absolute; left: -999px; top: 0; background: var(--brand-600); color:#fff;
  padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 200; }
.skip:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800;
  font-size: 1.22rem; color: var(--text); letter-spacing: -.03em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.brand b { color: var(--brand-600); }
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--text-2); font-weight: 600; font-size: .95rem;
  padding: 8px 12px; border-radius: 9px;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--brand-700); background: var(--brand-50); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav-links a.active { background: var(--surface-2); } }

.theme-toggle, .menu-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; display: grid;
  place-items: center; flex: none;
}
.theme-toggle:hover, .menu-btn:hover { color: var(--text); }
.menu-btn { display: none; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .sun { display:none; } :root:not([data-theme="light"]) .theme-toggle .moon { display:block; } }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

@media (max-width: 860px) {
  .menu-btn { display: grid; margin-left: auto; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 10px; gap: 2px; margin: 0; display: none; box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-links a { width: 100%; padding: 12px; }
  .nav .theme-toggle { order: 3; }
}

/* ---------- Hero ---------- */
.hero { padding: clamp(28px, 4vw, 56px) 0 8px; }
.hero p.lead { font-size: 1.15rem; max-width: 640px; color: var(--text-2); margin-top: 10px; }
.eyebrow { color: var(--brand-600); font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; font-size: .8rem; }

/* ---------- Main ---------- */
main { flex: 1 0 auto; }
section { margin: 40px 0; }

/* ---------- Cards / calculator grid ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

.tool-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md);
  border-color: var(--brand-200); text-decoration: none; }
.tool-card .ico {
  width: 46px; height: 46px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600);
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .tool-card .ico { background: var(--surface-2); } }
:root[data-theme="dark"] .tool-card .ico { background: var(--surface-2); }
.tool-card .ico svg { width: 24px; height: 24px; }
.tool-card h3 { margin: 0 0 2px; font-size: 1.05rem; color: var(--text); }
.tool-card p { margin: 0; font-size: .9rem; color: var(--text-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--brand-600); color: #fff; border: none; cursor: pointer;
  font-weight: 700; font-size: 1rem; padding: 12px 20px; border-radius: 11px;
  box-shadow: var(--shadow-sm); transition: background .15s ease, transform .1s ease;
}
.btn:hover { background: var(--brand-700); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 650; font-size: .92rem; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: .82rem; color: var(--text-3); margin-top: 4px; }
.input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent);
}
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .suffix {
  display: grid; place-items: center; padding: 0 14px; background: var(--surface-2);
  border: 1.5px solid var(--border); border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-3); font-weight: 600;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px){ .row { grid-template-columns: 1fr; } }

/* radio pills */
.pills { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 4px; gap: 4px; }
.pills label { padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 650;
  font-size: .9rem; color: var(--text-2); }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills input:checked + span,
.pills label:has(input:checked) { background: var(--surface); color: var(--brand-700);
  box-shadow: var(--shadow-sm); }

/* ---------- Result box ---------- */
.result {
  margin-top: 20px; padding: 22px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-50), color-mix(in srgb, var(--brand-100) 55%, var(--surface)));
  border: 1px solid var(--brand-200);
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .result {
  background: linear-gradient(135deg, var(--surface-2), var(--surface)); border-color: var(--border); } }
:root[data-theme="dark"] .result { background: linear-gradient(135deg, var(--surface-2), var(--surface)); border-color: var(--border); }
.result .big { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.6rem); font-weight: 800;
  color: var(--brand-700); letter-spacing: -.02em; line-height: 1.1; }
:root[data-theme="dark"] .result .big { color: var(--brand-400); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .result .big { color: var(--brand-400); } }
.result .label { font-size: .85rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.result .sub { color: var(--text-2); margin-top: 8px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; margin-top: 14px; }
.result-grid .cell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.result-grid .cell b { display: block; font-size: 1.25rem; color: var(--text); }
.result-grid .cell span { font-size: .8rem; color: var(--text-3); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--surface); }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--surface-2); font-weight: 700; color: var(--text); }
table.data tr:last-child td { border-bottom: none; }

/* ---------- Prose / content ---------- */
.prose { max-width: 760px; }
.prose p, .prose li { font-size: 1.03rem; }
.prose h2 { border-top: 1px solid var(--border); padding-top: 1.4em; }
.prose strong { color: var(--text); }
.formula {
  font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 14px 0; overflow-x: auto;
  color: var(--text); font-size: .95rem;
}

/* ---------- FAQ ---------- */
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 18px; margin: 10px 0; background: var(--surface);
}
.faq details[open] { box-shadow: var(--shadow-sm); }
.faq summary { font-weight: 700; cursor: pointer; padding: 12px 0; list-style: none; color: var(--text); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--brand-600); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding-bottom: 14px; }

/* ---------- Breadcrumb ---------- */
.crumb { font-size: .85rem; color: var(--text-3); padding: 16px 0 0; }
.crumb a { color: var(--text-3); }
.crumb a:hover { color: var(--brand-600); }

/* ---------- Ad slots ---------- */
.ad-slot {
  margin: 26px auto; text-align: center; min-height: 90px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.ad-slot::before { content: "Annons"; position: absolute; font-size: .65rem; color: var(--text-3);
  transform: translateY(-34px); letter-spacing: .1em; text-transform: uppercase; }
.ad-slot.placeholder {
  border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-3);
  background: var(--surface-2); font-size: .85rem; min-height: 100px; position: relative;
}

/* ---------- Related links ---------- */
.related { display: flex; flex-wrap: wrap; gap: 10px; }
.related a { background: var(--surface-2); border: 1px solid var(--border); padding: 8px 14px;
  border-radius: 999px; font-size: .9rem; font-weight: 600; color: var(--text-2); }
.related a:hover { border-color: var(--brand-300); color: var(--brand-700); text-decoration: none; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 56px; padding: 40px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 30px; }
@media (max-width: 780px){ .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; } }
@media (max-width: 460px){ .footer-grid { grid-template-columns: 1fr; } }
.site-footer h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 12px; }
.site-footer ul { list-style: none; padding: 0; }
.site-footer li { margin: 7px 0; }
.site-footer a { color: var(--text-2); font-size: .92rem; }
.site-footer a:hover { color: var(--brand-600); }
.footer-brand p { font-size: .9rem; margin-top: 10px; max-width: 30ch; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 28px; padding-top: 18px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-size: .85rem; color: var(--text-3); }

/* ---------- Cookie banner ---------- */
.cookie {
  position: fixed; bottom: 16px; left: 16px; right: 16px; max-width: 520px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 18px 20px; z-index: 300; display: none;
}
.cookie.show { display: block; }
.cookie p { font-size: .9rem; margin-bottom: 12px; }
.cookie .actions { display: flex; gap: 10px; }
.cookie .btn { padding: 9px 16px; font-size: .9rem; }

/* ---------- Utility ---------- */
.muted { color: var(--text-3); }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.tag { display:inline-block; font-size:.72rem; font-weight:700; text-transform:uppercase;
  letter-spacing:.05em; color: var(--brand-700); background: var(--brand-50); padding: 3px 9px;
  border-radius: 999px; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .tag { background: var(--surface-2); color: var(--brand-400);} }
:root[data-theme="dark"] .tag { background: var(--surface-2); color: var(--brand-400); }

.section-head { display:flex; align-items:baseline; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom: 18px; }
.section-head p { margin-top: 4px; }
