/* ==========================================================================
   Daily compound interest calculator
   Loaded only on /calculator. Inherits the tokens, .glass, .btn and .section
   primitives from landing.css.
   ========================================================================== */

.calc-top { padding-top: 54px; }

/* The script toggles rows with the hidden attribute; our own display rules
   would otherwise out-specify the UA stylesheet and keep them on screen. */
.calc-top [hidden] { display: none !important; }

.calc-grid {
	display: grid;
	grid-template-columns: 400px minmax(0, 1fr);
	gap: 26px;
	align-items: start;
}

/* ================================= inputs ================================ */

.calc-form {
	padding: 24px;
	position: sticky;
	top: 92px;
	max-height: calc(100vh - 116px);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--stroke-2) transparent;
}
.calc-form::-webkit-scrollbar { width: 8px; }
.calc-form::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 8px; }

.calc-legend-head {
	display: flex;
	align-items: center;
	gap: 9px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .13em;
	text-transform: uppercase;
	color: var(--ink-faint);
	margin: 0 0 16px;
}
.calc-legend-head i { color: var(--blue); font-size: 14px; }

.calc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc-row-3 { grid-template-columns: repeat(3, 1fr); }

.calc-field { margin-bottom: 16px; min-width: 0; }
.calc-field > label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--ink-dim);
	margin-bottom: 7px;
}
.calc-field small {
	display: block;
	margin-top: 6px;
	font-size: 11.5px;
	line-height: 1.45;
	color: var(--ink-faint);
}

.calc-field input[type="number"],
.calc-field input[type="date"],
.calc-field select {
	width: 100%;
	padding: 11px 13px;
	border: 1px solid var(--stroke);
	border-radius: 10px;
	background: rgba(5, 8, 15, .55);
	color: var(--ink);
	font-family: var(--f-mono);
	font-size: 14.5px;
	line-height: 1.3;
	transition: border-color .16s, box-shadow .16s, background .16s;
	-webkit-appearance: none;
	appearance: none;
}
.calc-field select {
	font-family: var(--f-body);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%2397a3bd' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 13px center;
	background-size: 11px;
	padding-right: 34px;
	cursor: pointer;
}
.calc-field select option { background: #0b1020; color: var(--ink); }

.calc-field input:focus,
.calc-field select:focus {
	outline: none;
	border-color: var(--blue);
	background: rgba(5, 8, 15, .8);
	box-shadow: 0 0 0 3px rgba(46, 168, 255, .16);
}

/* date pickers ship a near-black indicator on a dark field - lift it */
.calc-field input[type="date"]::-webkit-calendar-picker-indicator {
	filter: invert(68%) sepia(12%) saturate(500%) hue-rotate(190deg);
	cursor: pointer;
}

/* --- input with a trailing unit ----------------------------------------- */
.calc-suffix { position: relative; }
.calc-suffix > span {
	position: absolute;
	top: 50%;
	right: 13px;
	transform: translateY(-50%);
	font-size: 13.5px;
	font-weight: 600;
	color: var(--ink-faint);
	pointer-events: none;
}
.calc-suffix input { padding-right: 32px; }

/* --- chip radio groups --------------------------------------------------- */
.calc-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.calc-chips input { position: absolute; opacity: 0; width: 0; height: 0; }
.calc-chips span {
	display: inline-block;
	padding: 7px 13px;
	border: 1px solid var(--stroke);
	border-radius: 999px;
	background: var(--panel);
	font-size: 12.5px;
	font-weight: 600;
	color: var(--ink-dim);
	cursor: pointer;
	transition: background .16s, border-color .16s, color .16s;
	white-space: nowrap;
}
.calc-chips span:hover { border-color: var(--stroke-2); color: var(--ink); }
.calc-chips input:checked + span {
	background: rgba(46, 168, 255, .14);
	border-color: var(--blue);
	color: #cbe8ff;
}
.calc-chips input:focus-visible + span { box-shadow: 0 0 0 3px rgba(46, 168, 255, .22); }

/* --- day-of-week toggles ------------------------------------------------- */
.calc-days { display: flex; gap: 6px; }
.calc-days input { position: absolute; opacity: 0; width: 0; height: 0; }
.calc-days span {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border: 1px solid var(--stroke);
	border-radius: 10px;
	background: var(--panel);
	font-size: 13px;
	font-weight: 600;
	color: var(--ink-faint);
	cursor: pointer;
	transition: background .16s, border-color .16s, color .16s;
}
.calc-days input:checked + span {
	background: rgba(46, 168, 255, .16);
	border-color: var(--blue);
	color: #cbe8ff;
}
.calc-days input:focus-visible + span { box-shadow: 0 0 0 3px rgba(46, 168, 255, .22); }

/* --- plain checkbox ------------------------------------------------------ */
.calc-check {
	display: flex !important;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	margin-bottom: 0 !important;
	color: var(--ink-dim) !important;
}
.calc-check input {
	width: 17px;
	height: 17px;
	accent-color: var(--blue);
	cursor: pointer;
	flex: 0 0 auto;
}

.calc-sep { border: 0; border-top: 1px solid var(--stroke); margin: 22px 0; }

.calc-actions { display: flex; gap: 10px; margin-top: 22px; }
.calc-actions .btn { flex: 1; }

/* ================================ results ================================ */

/* Both of these are grids whose single implicit column would otherwise be
   auto-floored, i.e. sized to the widest unbreakable thing inside them - the
   nowrap breakdown table. That dragged the column out to ~785px and blew the
   whole page past the viewport on phones. minmax(0,1fr) pins the column to the
   container and lets .calc-table-scroll do the scrolling it was built for. */
.calc-results { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
.calc-results > *, #ciResults > * { min-width: 0; }

.calc-warn {
	margin: 0;
	padding: 13px 16px;
	border: 1px solid rgba(247, 177, 60, .34);
	border-radius: var(--r);
	background: rgba(247, 177, 60, .09);
	color: #f3cf94;
	font-size: 13.5px;
	line-height: 1.5;
}

#ciResults { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }

/* --- headline ------------------------------------------------------------ */
.calc-headline { padding: 30px 28px; text-align: center; }
.calc-headline-label {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--ink-faint);
}
.calc-headline-value {
	font-family: var(--f-head);
	font-size: clamp(38px, 6vw, 62px);
	font-weight: 700;
	letter-spacing: -.03em;
	line-height: 1.05;
	margin: 10px 0 8px;
	word-break: break-word;
}
.calc-headline-sub { color: var(--ink-dim); font-size: 15px; }
.calc-headline-sub strong { color: var(--gold); font-weight: 600; }
.calc-headline-term {
	margin-top: 12px;
	font-family: var(--f-mono);
	font-size: 12.5px;
	color: var(--ink-faint);
}

/* --- stat tiles ---------------------------------------------------------- */
.calc-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 10px;
}
.calc-stat {
	display: flex;
	flex-direction: column;
	gap: 5px;
	padding: 14px 16px;
	border: 1px solid var(--stroke);
	border-radius: var(--r);
	background: var(--panel);
}
.calc-stat span { font-size: 12px; color: var(--ink-faint); }
.calc-stat b {
	font-family: var(--f-mono);
	font-size: 16px;
	font-weight: 500;
	color: #fff;
	word-break: break-word;
}

/* --- panels -------------------------------------------------------------- */
.calc-panel { padding: 20px 22px; }
.calc-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 16px;
}
.calc-panel-head h3 { font-size: 18px; margin: 0; }

.calc-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-dim); }
.calc-legend span { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw-cap { background: var(--grad-brand); }
.sw-int { background: var(--grad-gold); }

.calc-chart { width: 100%; }
/* height comes from the viewBox the script sizes to this container, so the
   drawing is never stretched out of proportion */
.calc-chart svg { width: 100%; height: auto; display: block; }

/* --- table view switch --------------------------------------------------- */
.calc-toggle {
	display: inline-flex;
	padding: 3px;
	border: 1px solid var(--stroke);
	border-radius: 10px;
	background: rgba(5, 8, 15, .5);
}
.calc-toggle button {
	padding: 6px 14px;
	border: 0;
	border-radius: 7px;
	background: transparent;
	color: var(--ink-dim);
	font-family: var(--f-body);
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background .16s, color .16s;
}
.calc-toggle button:hover { color: var(--ink); }
.calc-toggle button.is-active { background: var(--panel-2); color: #fff; }

/* --- breakdown table ----------------------------------------------------- */
.calc-table-scroll {
	max-height: 460px;
	overflow: auto;
	border: 1px solid var(--stroke);
	border-radius: var(--r);
	scrollbar-width: thin;
	scrollbar-color: var(--stroke-2) transparent;
}
.calc-table-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.calc-table-scroll::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 8px; }

.calc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.calc-table th,
.calc-table td { padding: 9px 13px; text-align: left; white-space: nowrap; }
.calc-table th {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #0a1020;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--ink-faint);
	border-bottom: 1px solid var(--stroke);
}
.calc-table td {
	border-bottom: 1px solid rgba(255, 255, 255, .045);
	font-family: var(--f-mono);
	color: var(--ink-dim);
}
.calc-table tbody tr:last-child td { border-bottom: 0; }
.calc-table tbody tr:hover td { background: rgba(255, 255, 255, .028); }
.calc-table .num { text-align: right; }
.calc-table .up { color: var(--up); }
.calc-table .strong { color: #fff; font-weight: 500; }

.calc-table-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-faint); }

/* ================================ explain ================================ */

.calc-explain {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 18px;
	margin-top: 30px;
}
.calc-explain-card { padding: 24px 26px; }
.calc-explain-card h3 { font-size: 19px; }
.calc-explain-card p,
.calc-explain-card li { color: var(--ink-dim); font-size: 14.5px; }
.calc-explain-card ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.calc-explain-card em { color: var(--ink); font-style: italic; }

.calc-formula {
	padding: 12px 16px;
	border: 1px solid var(--stroke);
	border-radius: 10px;
	background: rgba(5, 8, 15, .5);
	font-family: var(--f-mono);
	font-size: 16px;
	color: #cbe8ff;
	text-align: center;
}
.calc-formula sup { font-size: 11px; }

.calc-disclaimer {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	max-width: 900px;
	margin: 30px auto 0;
	font-size: 13px;
	line-height: 1.6;
	color: var(--ink-faint);
	text-align: left;
}
.calc-disclaimer i { color: var(--blue); font-size: 15px; margin-top: 2px; flex: 0 0 auto; }

/* =============================== responsive ============================== */

@media (max-width: 1080px) {
	.calc-grid { grid-template-columns: minmax(0, 1fr); }
	.calc-form { position: static; max-height: none; overflow: visible; }
}

@media (max-width: 720px) {
	.calc-top { padding-top: 30px; }
	.calc-explain { grid-template-columns: minmax(0, 1fr); }
	.calc-explain-card { padding: 20px 18px; }
	.calc-stats { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
	.calc-panel { padding: 18px 16px; }
	.calc-form { padding: 20px 18px; }
	.calc-days span { width: 34px; height: 34px; }
	.calc-headline { padding: 24px 18px; }
	.calc-panel-head h3 { font-size: 16.5px; }
	.calc-formula { font-size: 14px; padding: 10px 12px; }
	.calc-grid { gap: 18px; }
}

@media (max-width: 460px) {
	.calc-row, .calc-row-3 { grid-template-columns: minmax(0, 1fr); }
	.calc-actions { flex-direction: column; }
	.calc-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
	.calc-stat { padding: 11px 12px; }
	.calc-stat b { font-size: 14.5px; }
	.calc-stat span { font-size: 11px; }

	/* the switch sits under its heading rather than squeezing beside it */
	.calc-panel-head { flex-direction: column; align-items: stretch; gap: 10px; }
	.calc-toggle { align-self: flex-start; }
	.calc-toggle button { padding: 6px 11px; font-size: 12px; }

	.calc-days { gap: 4px; justify-content: space-between; }
	.calc-days span { width: 100%; min-width: 30px; height: 34px; }
	.calc-days label { flex: 1; }

	.calc-table th, .calc-table td { padding: 8px 10px; }
	.calc-disclaimer { font-size: 12.5px; }
}
