/* Finance Hamster — calculators. Shares the warm amber/brown brand; scoped to .fh-calc. */

.fh-calc {
	--bg: #faf7f2; --card: #fff; --ink: #2b2118; --muted: #8a7d6f;
	--accent: #f59e0b; --accent-d: #b9770a; --soft: #fff5e1; --bd: #ece4d8;
	--pos: #15803d; --neg: #b91c1c; --contrib: #e3d8c3;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ink); max-width: 760px; margin: 0 auto; padding: 8px;
	background: var(--card); border: 1px solid var(--bd); border-radius: 18px; box-shadow: 0 1px 3px rgba(43,33,24,.05);
}
.fh-calc * { box-sizing: border-box; }
.fh-calc-head { padding: 14px 14px 4px; }
.fh-calc .fh-brand { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.fh-calc .fh-tag { display: inline-block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; background: var(--soft); color: var(--accent-d); border: 1px solid #f6d9a3; border-radius: 999px; padding: 3px 9px; vertical-align: middle; margin-left: 6px; }

.fh-calc-tabs { display: flex; gap: 6px; padding: 8px 14px 0; border-bottom: 1px solid var(--bd); }
.fh-calc-tab { appearance: none; background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 6px; font-size: 0.92rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.fh-calc-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

.fh-calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px 16px; }
@media (max-width: 600px) { .fh-calc-grid { grid-template-columns: 1fr; } }

.fh-calc-form { display: flex; flex-direction: column; gap: 12px; }
.fh-calc-field { display: flex; flex-direction: column; gap: 5px; }
.fh-calc-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.fh-calc-input { display: flex; align-items: center; border: 1px solid var(--bd); border-radius: 10px; overflow: hidden; background: #fff; }
.fh-calc-input:focus-within { border-color: var(--accent); }
.fh-calc-unit { padding: 0 6px 0 11px; color: var(--muted); font-weight: 700; }
.fh-calc-input input { flex: 1; border: none; padding: 10px 12px 10px 6px; font-size: 1rem; font-weight: 700; color: var(--ink); width: 100%; background: transparent; }
.fh-calc-input input:focus { outline: none; }
.fh-calc-range { width: 100%; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; height: 22px; }
.fh-calc-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.fh-calc-out { display: flex; flex-direction: column; gap: 12px; }
.fh-calc-big { display: flex; flex-direction: column; gap: 2px; }
.fh-calc-k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.fh-calc-v { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--accent-d); }
.fh-calc-v.fh-neg { color: var(--neg); }
.fh-calc-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fh-calc-split > div { display: flex; flex-direction: column; gap: 2px; }
.fh-calc-v2 { font-size: 1.1rem; font-weight: 800; }
.fh-pos { color: var(--pos); } .fh-neg { color: var(--neg); }

.fh-calc-chart { width: 100%; height: 120px; display: block; background: #fbf7ef; border: 1px solid var(--bd); border-radius: 10px; }
.fh-bar-c { fill: var(--contrib); }
.fh-bar-g { fill: var(--pos); }
.fh-bar-n { fill: var(--neg); }
.fh-calc-legend { font-size: 0.74rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fh-lg { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-left: 8px; }
.fh-lg-c { background: var(--contrib); } .fh-lg-g { background: var(--pos); } .fh-lg-n { background: var(--neg); }

.fh-calc-note { margin: 0 16px; padding: 10px 12px; background: var(--soft); border: 1px solid #f6d9a3; border-radius: 10px; color: #6b4e1f; font-size: 0.78rem; line-height: 1.45; }
.fh-calc .fh-disclaimer { margin: 12px 16px 16px; padding: 11px 13px; background: #fbf7ef; border: 1px dashed var(--bd); border-radius: 10px; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }

/* "Use a real ETF" picker */
.fh-calc-source { padding: 12px 16px 0; }
.fh-fund-pick { position: relative; }
.fh-fund-lbl { display: block; font-size: 0.82rem; font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.fh-fund-opt { color: var(--muted); font-weight: 600; }
.fh-fund-q { width: 100%; border: 1px solid var(--bd); border-radius: 10px; padding: 10px 12px; font-size: 0.95rem; background: #fff; color: var(--ink); }
.fh-fund-q:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.fh-fund-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--bd); border-radius: 12px; box-shadow: 0 8px 24px rgba(43,33,24,.12); overflow: hidden; max-height: 280px; overflow-y: auto; }
.fh-fund-opt-row { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; appearance: none; background: none; border: none; border-bottom: 1px solid var(--bd); padding: 9px 12px; cursor: pointer; }
.fh-fund-opt-row:last-child { border-bottom: none; }
.fh-fund-opt-row:hover, .fh-fund-opt-row:focus, .fh-fund-opt-row.is-active { background: var(--soft); outline: none; }
.fh-fund-name { font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.fh-fund-meta { font-size: 0.74rem; color: var(--muted); }
.fh-fund-chosen { margin: 8px 0 0; font-size: 0.78rem; color: #6b4e1f; background: var(--soft); border: 1px solid #f6d9a3; border-radius: 9px; padding: 8px 11px; line-height: 1.4; }

/* Embedded (inline on a profile) — drop the outer card chrome, sit flush */
.fh-calc.is-embed { max-width: none; border: none; border-radius: 0; box-shadow: none; background: transparent; padding: 0; }
.fh-calc.is-embed .fh-calc-source { padding-left: 0; padding-right: 0; }
.fh-calc.is-embed .fh-calc-tabs { padding-left: 0; padding-right: 0; }
.fh-calc.is-embed .fh-calc-grid { padding-left: 0; padding-right: 0; }
.fh-calc.is-embed .fh-calc-note { margin-left: 0; margin-right: 0; }

/* Compare funds tab */
.fh-calc .fh-cmp-calc { padding: 18px 16px; }
.fh-calc .fh-cmp-top { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 12px; align-items: end; }
@media (max-width: 600px) { .fh-calc .fh-cmp-top { grid-template-columns: 1fr 1fr; } .fh-calc .fh-cmp-pick { grid-column: 1 / -1; } }
.fh-calc .fh-cmp-pick { position: relative; }
.fh-calc .fh-cmp-empty { margin: 16px 0 0; padding: 12px 14px; background: var(--soft); border: 1px solid #f6d9a3; border-radius: 10px; color: #6b4e1f; font-size: 0.82rem; line-height: 1.45; }
.fh-calc .fh-cmp-out { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.fh-calc .fh-cmp-row { border: 1px solid var(--bd); border-radius: 12px; padding: 12px 14px; background: #fff; }
.fh-calc .fh-cmp-rowhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fh-calc .fh-cmp-fname { font-weight: 800; font-size: 0.95rem; }
.fh-calc .fh-cmp-remove { appearance: none; border: none; background: none; color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.fh-calc .fh-cmp-remove:hover { color: var(--neg); }
.fh-calc .fh-cmp-meta { color: var(--muted); font-size: 0.78rem; margin: 2px 0 8px; }
.fh-calc .fh-cmp-bar { background: #f1e9da; border-radius: 999px; height: 12px; overflow: hidden; }
.fh-calc .fh-cmp-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-d)); border-radius: 999px; transition: width 0.2s; }
.fh-calc .fh-cmp-val { font-size: 1.35rem; font-weight: 800; color: var(--accent-d); margin-top: 6px; }
@media (prefers-color-scheme: dark) { .fh-calc .fh-cmp-row { background: #1d1812; } .fh-calc .fh-cmp-bar { background: #322a20; } }

/* Focus-visible rings (WCAG 2.4.7) */
.fh-calc-tab:focus-visible, .fh-calc-input input:focus-visible,
.fh-fund-q:focus-visible, .fh-fund-opt-row:focus-visible { outline: 2px solid var(--accent-d); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .fh-calc * { transition: none !important; } }

/* Dark mode */
@media (prefers-color-scheme: dark) {
	.fh-calc {
		--bg: #181410; --card: #221c16; --ink: #f2ebe0; --muted: #b7ab9a;
		--accent: #f59e0b; --accent-d: #fbbf24; --soft: #2c2114; --bd: #3a3026;
		--pos: #4ade80; --neg: #f87171; --contrib: #4a3f30;
		background: var(--card);
	}
	.fh-calc .fh-calc-input { background: #1d1812; }
	.fh-calc .fh-calc-input input { color: var(--ink); }
	.fh-calc .fh-calc-chart { background: #1d1812; }
	.fh-calc .fh-fund-q { background: #1d1812; color: var(--ink); }
	.fh-calc .fh-fund-list { background: #241d15; }
	.fh-calc .fh-calc-note, .fh-calc .fh-fund-chosen { color: #f3d9a8; }
	.fh-calc .fh-disclaimer { background: #221c16; }
}
