/* Kami Calculator stylesheet. Mobile first, no frameworks, system fonts for speed. */
:root {
  --bg: #ffffff;
  --bg-soft: #f4f6f8;
  --ink: #1a2332;
  --muted: #5b6779;
  --line: #dde4ec;
  --brand: #0b5fff;
  --brand-dark: #0849c4;
  --good: #0e7a3d;
  --warn: #9a3412;
  --card: #ffffff;
  --radius: 12px;
  --max: 1060px;
  --focus: #ffbf47;
  /* Motion system (Emil Kowalski philosophy): custom curves beat built-in easings. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 160ms;
  --dur-pop: 180ms;
  --dur-card: 220ms;
}
* { box-sizing: border-box; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 0; background: #000; color: #fff; padding: 10px 14px; z-index: 99; }
.skip-link:focus { left: 8px; top: 8px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 18px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 14px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 20px; }
.brand-mark { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.brand-mark svg { display: block; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.2; }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 15px; }
.nav a:hover { background: var(--bg-soft); }
.header-search { position: relative; flex: 1; margin-left: 12px; }
.header-search input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.header-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15); outline: none; }
.search-pop {
  position: absolute; top: 46px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(16, 30, 54, 0.12); overflow: hidden; z-index: 30;
  /* Interruptible, origin-aware popover: transform + opacity only (GPU), never display-toggle. */
  transform-origin: top center;
  opacity: 0; transform: scale(0.97) translateY(-4px); visibility: hidden; pointer-events: none;
  transition: opacity 125ms var(--ease-out), transform var(--dur-pop) var(--ease-out), visibility 0s linear var(--dur-pop);
}
.search-pop.open { opacity: 1; transform: scale(1) translateY(0); visibility: visible; pointer-events: auto; transition: opacity 125ms var(--ease-out), transform var(--dur-pop) var(--ease-out), visibility 0s; }
/* Skip animation on subsequent results while typing: feels faster without losing first-open context. */
.search-pop.is-instant { transition-duration: 0ms; }
.search-pop a { display: block; padding: 10px 12px; text-decoration: none; color: var(--ink); border-bottom: 1px solid #eef2f6; }
.search-pop a span { display: block; font-size: 13px; color: var(--muted); }
.search-pop a:hover { background: var(--bg-soft); }

/* Header dropdown menu */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav .icon-link { display: none; }
.nav .icon-link svg { display: block; }
.nav-drop { position: relative; }
.nav-drop-btn { appearance: none; border: 1px solid var(--brand); background: #fff; color: var(--brand); font: inherit; font-size: 15px; font-weight: 700; padding: 8px 14px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: transform var(--dur-press) var(--ease-out), background-color 150ms ease, border-color 150ms ease; }
.nav-drop-btn:hover { background: #eef4ff; }
.nav-drop-btn:active { transform: scale(0.97); }
.nav-drop-btn .icon-bars { display: none; }
.nav-drop-list {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 240px; max-height: 70vh; overflow: auto; margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(16, 30, 54, 0.12); z-index: 30;
  /* Origin-aware: scales from trigger, not center. Interruptible via transition (not keyframes). */
  transform-origin: top left;
  opacity: 0; transform: scale(0.95) translateY(-4px); visibility: hidden; pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
.nav-drop.open .nav-drop-list, .nav-drop:focus-within .nav-drop-list { opacity: 1; transform: scale(1) translateY(0); visibility: visible; pointer-events: auto; transition: opacity 150ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s; }
.nav-drop-list a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 15px; white-space: nowrap; }
.nav-drop-list a:hover { background: var(--bg-soft); }

/* Hero */
.hero { background: linear-gradient(180deg, #eef4ff 0%, #fff 100%); border-bottom: 1px solid var(--line); padding: 34px 0 26px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; letter-spacing: -0.5px; }
.hero p.lead { margin: 0 0 18px; color: var(--muted); font-size: 18px; max-width: 62ch; }
.hero-search { display: flex; gap: 8px; max-width: 620px; }
.hero-search input { flex: 1; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 16px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.hero-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15); outline: none; }
.btn { appearance: none; border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: 12px; padding: 12px 18px; font-size: 16px; font-weight: 700; cursor: pointer; transition: transform var(--dur-press) var(--ease-out), background-color 150ms ease, border-color 150ms ease, box-shadow 200ms var(--ease-out); }
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(0.97); }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: #eef4ff; }
.btn.secondary:active { transform: scale(0.97); }
.hero-meta { margin-top: 14px; color: var(--muted); font-size: 14px; }
.hero-results { margin-top: 12px; display: grid; gap: 8px; max-width: 620px; }
.hero-results a { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; text-decoration: none; color: var(--ink); transition: transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out), border-color 150ms ease; }
.hero-results a span { color: var(--muted); font-size: 13px; display: block; }
@media (hover: hover) and (pointer: fine) {
  .hero-results a:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(16, 30, 54, 0.08); }
}

/* Sections and cards */
.section { padding: 26px 0; }
.section h2 { font-size: 24px; margin: 0 0 6px; }
.section .sub { color: var(--muted); margin: 0 0 16px; }
.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; transition: transform var(--dur-card) var(--ease-out), box-shadow var(--dur-card) var(--ease-out), border-color 150ms ease; }
@media (hover: hover) and (pointer: fine) {
  .card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 30, 54, 0.08); border-color: #c4d2e6; }
}
.card h3 { margin: 0 0 6px; font-size: 18px; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--brand); }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 700; background: #eef4ff; color: var(--brand-dark); border-radius: 999px; padding: 3px 10px; margin-bottom: 8px; }
.calc-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .calc-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .calc-list { grid-template-columns: repeat(3, 1fr); } }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13.5px; margin: 10px 0 0; }

/* Breadcrumbs */
.crumbs { font-size: 14px; color: var(--muted); margin: 18px 0 10px; }
.crumbs a { color: var(--muted); }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: #9aa7bb; }

/* Article */
.article h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.18; margin: 6px 0 8px; letter-spacing: -0.4px; }
.article .short { color: var(--muted); font-size: 18px; margin: 0 0 12px; max-width: 68ch; }
.toc { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; }
.toc h2 { font-size: 15px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 4px 0; font-size: 15px; }
.article h2 { font-size: 23px; margin: 30px 0 8px; padding-top: 6px; }
.article h3 { font-size: 18px; margin: 20px 0 6px; }
.article p, .article li { max-width: 72ch; }
.keypoints { border: 1px solid var(--line); border-left: 4px solid var(--good); background: #f3faf5; border-radius: 0 12px 12px 0; padding: 12px 16px; margin: 16px 0; }
.keypoints b { display: block; margin-bottom: 6px; }
.keypoints ul { margin: 0; padding-left: 20px; }
dl.vars { display: grid; gap: 8px; margin: 12px 0; max-width: 72ch; }
dl.vars div { display: grid; grid-template-columns: 150px 1fr; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; }
dl.vars dt { font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14.5px; }
dl.vars dd { margin: 0; font-size: 15px; }
@media (max-width: 560px) { dl.vars div { grid-template-columns: 1fr; } }
.formula { background: #0f1f3d; color: #eaf0ff; border-radius: 12px; padding: 14px 16px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.facts { display: grid; gap: 10px; grid-template-columns: 1fr; margin: 14px 0; }
@media (min-width: 720px) { .facts { grid-template-columns: repeat(3, 1fr); } }
.fact { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.fact b { display: block; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.example { border-left: 4px solid var(--brand); background: #f6f9ff; padding: 12px 16px; border-radius: 0 12px 12px 0; margin: 14px 0; }
table.data { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15.5px; }
table.data th, table.data td { border: 1px solid var(--line); padding: 9px 10px; text-align: left; }
table.data th { background: var(--bg-soft); }
.table-scroll { overflow-x: auto; }
details.faq { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; background: #fff; transition: border-color 150ms ease, background-color 150ms ease; }
details.faq summary { cursor: pointer; font-weight: 700; }
.verify { border: 1px dashed #9db4d8; background: #fbfcff; border-radius: 12px; padding: 12px 16px; margin: 20px 0; font-size: 15px; color: #33415c; }
.related { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .related { grid-template-columns: repeat(3, 1fr); } }

/* Calculator tool */
.tool { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 16px 0 8px; background: #fff; }
.tool-head { background: #0f1f3d; color: #fff; padding: 12px 16px; }
.tool-head b { font-size: 16px; }
.tool-body { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 860px) { .tool-body { grid-template-columns: 1.1fr 0.9fr; } }
.tool-form { padding: 16px; }
.tool-results { padding: 16px; background: var(--bg-soft); border-top: 1px solid var(--line); }
@media (min-width: 860px) { .tool-results { border-top: 0; border-left: 1px solid var(--line); } }
.field { margin-bottom: 13px; }
.field label { display: block; font-weight: 700; font-size: 14.5px; margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 11px 12px; border: 1px solid #b9c4d4; border-radius: 10px; font-size: 16px; background: #fff; transition: border-color 150ms ease, box-shadow 150ms ease, transform var(--dur-press) var(--ease-out); }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15); outline: none; }
.field .help { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool-actions { display: flex; gap: 8px; margin-top: 6px; }
.result-main { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.result-main .k { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.result-main .v { font-size: 26px; font-weight: 800; transition: opacity 160ms ease-out, filter 200ms ease; }
.result-grid { display: grid; gap: 8px; }
.result-grid .r { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.result-grid .r b { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.result-grid .r span { display: inline-block; transition: opacity 160ms ease-out, filter 200ms ease; }
/* Blur masks the old/new value overlap during live recalc: one smooth morph, not two numbers swapping. */
.tool-results.is-updating .result-main .v,
.tool-results.is-updating .result-grid .r span { opacity: 0.55; filter: blur(2px); }
.calc-note { font-size: 14.5px; color: #33415c; margin-top: 10px; }
.calc-error { background: #fdecea; color: #7a1f14; border: 1px solid #f3b3ab; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14.5px; opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top center; visibility: hidden; pointer-events: none; height: 0; margin: 0; padding-top: 0; padding-bottom: 0; border-width: 0; overflow: hidden; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), visibility 0s linear 180ms; }
.calc-error.show { opacity: 1; transform: none; visibility: visible; pointer-events: auto; height: auto; margin-bottom: 12px; padding: 10px 12px; border-width: 1px; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), visibility 0s; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 30px; background: #fbfcfe; }
.site-footer .wrap { padding-top: 22px; padding-bottom: 26px; }
.foot-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.site-footer h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 6px 0; }
.site-footer a { color: var(--ink); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.foot-base { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

/* Search page */
.search-big { display: flex; gap: 8px; margin: 14px 0; }
.search-big input { flex: 1; padding: 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 16px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.search-big input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15); outline: none; }

/* Stagger: cascading entrance for grids. Decorative only, never blocks interaction. 40ms steps, capped. */
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: no-preference) {
  .calc-list .card, .cat-grid .card, .related .card { animation: card-in 280ms var(--ease-out) backwards; }
  .calc-list .card:nth-child(2), .cat-grid .card:nth-child(2), .related .card:nth-child(2) { animation-delay: 40ms; }
  .calc-list .card:nth-child(3), .cat-grid .card:nth-child(3), .related .card:nth-child(3) { animation-delay: 80ms; }
  .calc-list .card:nth-child(4), .cat-grid .card:nth-child(4) { animation-delay: 120ms; }
  .calc-list .card:nth-child(5), .cat-grid .card:nth-child(5) { animation-delay: 160ms; }
  .calc-list .card:nth-child(6), .cat-grid .card:nth-child(6) { animation-delay: 200ms; }
  .calc-list .card:nth-child(n+7), .cat-grid .card:nth-child(n+7) { animation-delay: 200ms; }
  .hero-results a { animation: card-in 250ms var(--ease-out) backwards; }
  .hero-results a:nth-child(2) { animation-delay: 40ms; }
  .hero-results a:nth-child(3) { animation-delay: 80ms; }
  .hero-results a:nth-child(n+4) { animation-delay: 120ms; }
  /* Typing fast: skip stagger after first paint so the list feels instant. */
  .hero-results.is-instant a { animation: none; }
}
@media (max-width: 640px) {
  .header-search { visibility: hidden; opacity: 0; transform: translateY(-6px); position: absolute; top: 100%; left: 0; right: 0; max-width: none; margin: 0; padding: 10px 18px 14px; background: #fff; border-bottom: 1px solid var(--line); z-index: 25; pointer-events: none; transition: opacity 200ms var(--ease-out), transform 220ms var(--ease-drawer), visibility 0s linear 220ms; }
  .site-header.search-open .header-search { visibility: visible; opacity: 1; transform: translateY(0); pointer-events: auto; transition: opacity 180ms var(--ease-out), transform 240ms var(--ease-drawer), visibility 0s; }
  .nav a.hide-m { display: none; }
  .nav a.icon-link { display: inline-flex; align-items: center; }
  .nav-drop-btn .drop-label, .nav-drop-btn .icon-chev { display: none; }
  .nav-drop-btn .icon-bars { display: block; }
  .nav-drop-list { left: auto; right: 0; transform-origin: top right; }
  .site-header .wrap { flex-wrap: wrap; }
  .nav { margin-left: auto; }
  body { font-size: 16px; }
}
/* Reduced motion: keep opacity/color (comprehension), drop movement/position. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .btn:active, .nav-drop-btn:active, .btn.secondary:active { transform: none; }
  .card, .card:hover { transform: none; box-shadow: none; }
  .search-pop, .nav-drop-list, .header-search, .calc-error { transform: none !important; transition: opacity 0.01ms linear !important; }
  .tool-results.is-updating .result-main .v,
  .tool-results.is-updating .result-grid .r span { filter: none; opacity: 0.8; }
}
@media print {
  .site-header, .site-footer, .toc, .tool-actions, .hero-search { display: none; }
  .tool { border: 1px solid #000; }
}
