/* ============================================================================
 * Calculators & Unit Converters — page + widget styles
 * Uses the shared design tokens (tokens.css) so light/dark themes just work.
 * ========================================================================== */

/* ---- Hero -------------------------------------------------------------- */
/* NOTE: base.css applies `.dx section { padding: var(--section-y) 0 }` (120px,
   specificity 0,1,1). These hero/group rules are `.dx`-prefixed so they win. */
.dx .calc-hero { padding: 46px 0 16px; }
.calc-hero .eyebrow { margin-bottom: 14px; }
.calc-hero h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.1; margin: 0 0 12px; letter-spacing: -0.02em; }
.calc-hero p.lede { color: var(--fg-muted); max-width: 60ch; font-size: 1.05rem; line-height: 1.6; margin: 0; }

.calc-breadcrumb { font-size: 0.82rem; color: var(--fg-dim); margin-bottom: 18px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.calc-breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.calc-breadcrumb a:hover { color: var(--orange); }
.calc-breadcrumb span { color: var(--fg-faint); }

/* ---- Layout: form | results ------------------------------------------- */
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
@media (max-width: 860px) { .calc-grid { grid-template-columns: 1fr; } }

.calc-form { background: var(--bg-elev-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.calc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 520px) { .calc-fields { grid-template-columns: 1fr; } }
.calc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.calc-field.full { grid-column: 1 / -1; }
.calc-label { font-size: 0.8rem; color: var(--fg-muted); font-weight: 500; }
.calc-input { width: 100%; }
textarea.calc-input { resize: vertical; min-height: 84px; font-family: var(--font-mono); }

/* number affixes */
.calc-affix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--bg-inset); }
.calc-affix:focus-within { border-color: var(--orange); }
.calc-affix .calc-input { border: 0; background: transparent; border-radius: 0; }
.calc-affix .calc-input:focus { outline: none; box-shadow: none; }
.calc-affix-pre, .calc-affix-suf { display: flex; align-items: center; padding: 0 11px; font-size: 0.85rem; color: var(--fg-dim); background: var(--bg-elev-2); white-space: nowrap; }
.calc-affix-suf { border-left: 1px solid var(--line); }
.calc-affix-pre { border-right: 1px solid var(--line); }

/* segmented toggle */
.calc-seg { display: inline-flex; background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 3px; flex-wrap: wrap; }
.calc-seg-btn { flex: 1 1 auto; border: 0; background: transparent; color: var(--fg-muted); font: inherit; font-size: 0.82rem; padding: 7px 12px; border-radius: calc(var(--r-md) - 3px); cursor: pointer; white-space: nowrap; }
.calc-seg-btn:hover { color: var(--fg); }
.calc-seg-btn.active { background: var(--orange); color: #1a1206; font-weight: 600; }

.calc-go { margin-top: 16px; width: 100%; }

/* ---- Results ----------------------------------------------------------- */
.calc-result { background: var(--bg-elev-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; min-height: 120px; }
.calc-headline { padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.calc-headline-label { font-size: 0.82rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.calc-headline-value { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 700; letter-spacing: -0.02em; color: var(--orange); line-height: 1.1; word-break: break-word; }

.calc-rows { display: flex; flex-direction: column; gap: 0; margin: 0; }
.calc-rows > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.calc-rows > div:last-child { border-bottom: 0; }
.calc-rows dt { color: var(--fg-muted); font-size: 0.88rem; margin: 0; }
.calc-rows dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

.calc-note { margin: 16px 0 0; font-size: 0.8rem; color: var(--fg-dim); line-height: 1.5; }
.calc-error { color: var(--danger, #e5534b); font-size: 0.9rem; padding: 8px 0; }

/* stacked breakdown bar */
.calc-bars { margin: 0 0 16px; }
.calc-bar-track { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--bg-inset); }
.calc-bar-seg { display: block; height: 100%; }
.calc-bar-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 11px; }
.calc-bar-key { font-size: 0.78rem; color: var(--fg-muted); display: inline-flex; align-items: center; gap: 6px; }
.calc-bar-key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* amortization / schedule tables */
.calc-table-wrap { margin-top: 16px; max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.calc-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.calc-table th { position: sticky; top: 0; background: var(--bg-elev-2); text-align: right; padding: 9px 12px; color: var(--fg-muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.calc-table tbody tr:last-child td { border-bottom: 0; }

/* ---- Converter --------------------------------------------------------- */
.conv-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: end; }
@media (max-width: 640px) { .conv-row { grid-template-columns: 1fr; } }
.conv-cell { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.conv-cell .conv-val, .conv-cell .conv-res { font-size: 1.3rem; font-weight: 600; }
.conv-cell .conv-res { color: var(--orange); }
.conv-swap { align-self: center; background: var(--bg-inset); border: 1px solid var(--line); color: var(--fg-muted); width: 40px; height: 40px; border-radius: 999px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-bottom: 4px; }
.conv-swap:hover { color: var(--orange); border-color: var(--orange); }
@media (max-width: 640px) { .conv-swap { transform: rotate(90deg); margin: 2px auto; } }
.conv-eq { margin: 18px 0; padding: 14px 16px; background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-md); text-align: center; color: var(--fg-muted); font-size: 1rem; }
.conv-eq strong { color: var(--fg); }
.conv-table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.conv-table td { text-align: right; }
.conv-table td:first-child { text-align: left; color: var(--fg-muted); }
.conv-hl td { background: var(--orange-tint, rgba(255,140,40,.10)); color: var(--fg); font-weight: 600; }

/* ---- Scientific calculator -------------------------------------------- */
.sci { max-width: 420px; margin: 0 auto; }
.sci-disp { background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; }
.sci-expr { width: 100%; border: 0; background: transparent; color: var(--fg); font-family: var(--font-mono); font-size: 1.05rem; text-align: right; }
.sci-expr:focus { outline: none; }
.sci-out { text-align: right; font-size: 1.7rem; font-weight: 700; color: var(--orange); margin-top: 6px; min-height: 1.7rem; word-break: break-all; font-variant-numeric: tabular-nums; }
.sci-modes { display: flex; gap: 6px; margin-bottom: 10px; }
.sci-mode { flex: 1; padding: 6px; background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--fg-dim); font: inherit; font-size: 0.78rem; cursor: pointer; }
.sci-mode.active { background: var(--orange); color: #1a1206; border-color: var(--orange); font-weight: 600; }
.sci-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.sci-key { padding: 13px 0; background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--fg); font: inherit; font-size: 0.95rem; cursor: pointer; transition: background .12s; }
.sci-key:hover { background: var(--bg-inset); border-color: var(--line-strong); }
.sci-key:active { transform: translateY(1px); }
.sci-key.sci-op { color: var(--orange); }
.sci-key.sci-fn { color: var(--violet); }
.sci-key.sci-eq { background: var(--orange); color: #1a1206; border-color: var(--orange); font-weight: 700; }

/* ---- "How it works" / FAQ / related ----------------------------------- */
.calc-prose { max-width: 760px; margin: 40px auto 0; }
.calc-prose h2 { font-size: 1.35rem; margin: 34px 0 12px; letter-spacing: -0.01em; }
.calc-prose p, .calc-prose li { color: var(--fg-muted); line-height: 1.7; }
.calc-prose ul { padding-left: 20px; }
.calc-faq details { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 10px; background: var(--bg-elev-1); }
.calc-faq summary { cursor: pointer; font-weight: 600; }
.calc-faq details[open] summary { margin-bottom: 8px; }
.calc-faq p { margin: 0; }

.calc-related { margin: 44px 0 0; }
.calc-related h2 { font-size: 1.15rem; margin: 0 0 14px; }
.calc-related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.calc-related-grid a { display: block; padding: 13px 15px; background: var(--bg-elev-1); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--fg); font-size: 0.9rem; font-weight: 500; transition: border-color .12s; }
.calc-related-grid a:hover { border-color: var(--orange); }

/* ---- Property promo hook (left intentionally empty for now) ------------ */
.calc-promo:empty { display: none; }

/* ---- Hub --------------------------------------------------------------- */
.calc-hub-search { position: relative; max-width: 520px; margin: 8px 0 0; }
.dx .calc-hub-search input { width: 100%; padding-left: 44px; }
.calc-hub-search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--fg-dim); pointer-events: none; }

/* trust strip under the hero */
.calc-trust { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 18px 0 0; }
.calc-trust span { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--fg-muted); }
.calc-trust svg { width: 14px; height: 14px; color: var(--success, #34b27b); flex-shrink: 0; }

.calc-cat-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 8px; }
.calc-cat-nav a { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--fg-muted); text-decoration: none; }
.calc-cat-nav a svg { width: 15px; height: 15px; }
.calc-cat-nav a:hover { border-color: var(--orange); color: var(--fg); }

.dx .calc-group { padding: 12px 0 30px; scroll-margin-top: 80px; }
.calc-group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.calc-group-ic { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.calc-group-ic svg { width: 19px; height: 19px; }
.calc-group-head h2 { font-size: 1.3rem; margin: 0; letter-spacing: -0.01em; }
.calc-group-head p { margin: 0; color: var(--fg-dim); font-size: 0.85rem; }
@media (max-width: 520px) { .calc-group-head p { display: none; } }

.calc-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.calc-card { display: flex; flex-direction: row; align-items: flex-start; gap: 12px; padding: 15px 16px; background: var(--bg-elev-1); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--fg); transition: border-color .12s, transform .12s, box-shadow .12s; }
.calc-card:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: 0 8px 24px -14px rgba(0,0,0,.5); }
.calc-card-ic { width: 36px; height: 36px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.calc-card-ic svg { width: 19px; height: 19px; }
.calc-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.calc-card-title { font-weight: 600; font-size: 0.93rem; }
.calc-card-desc { font-size: 0.79rem; color: var(--fg-dim); line-height: 1.45; }

/* per-category accent for the group + card icon badges */
.cic-finance    { color: #f08a3c; background: rgba(240,138,60,.13); }
.cic-health     { color: #34b27b; background: rgba(52,178,123,.13); }
.cic-math       { color: #a78bfa; background: rgba(167,139,250,.14); }
.cic-datetime   { color: #d9a527; background: rgba(217,165,39,.14); }
.cic-converters { color: #4a90d9; background: rgba(74,144,217,.14); }

/* hub intro + FAQ blocks (also reused on calc pages) */
.calc-intro { max-width: 760px; color: var(--fg-muted); line-height: 1.7; margin: 14px 0 0; }
.calc-hub-faq { padding: 18px 0 40px; }

/* "free / private" badge row on single calculator pages */
.calc-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.calc-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; font-weight: 500; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-muted); background: var(--bg-elev-1); }
.calc-badge svg { width: 13px; height: 13px; color: var(--success, #34b27b); }

/* key-takeaways card (AEO/GEO) */
.calc-tldr { background: var(--bg-elev-1); border: 1px solid var(--line); border-left: 3px solid var(--orange); border-radius: var(--r-md); padding: 16px 20px; margin: 22px 0 0; max-width: 880px; }
.calc-tldr .eyebrow { margin-bottom: 8px; }
.calc-tldr ul { margin: 0; padding-left: 18px; }
.calc-tldr li { color: var(--fg-muted); line-height: 1.65; font-size: 0.9rem; }
.calc-updated { font-family: var(--font-mono); color: var(--fg-dim); font-size: 0.78rem; margin: 12px 0 0; }
