/* ==========================================================================
   Budgettool design system
   Loaded after Bootstrap and style.css (see layout.pug) and overrides both.
   The written spec lives in design/DESIGN.md; the live specimen at /design.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
	/* Palette - design/colors.jpg. 100 = lightest, 500 = base, 900 = darkest */
	--violet-100: #CEACFF;
	--violet-300: #B37CFF;
	--violet-500: #7716FF;
	--violet-700: #3D0093;
	--violet-900: #2F0071;

	--magenta-100: #FCA4FF;
	--magenta-300: #FA71FF;
	--magenta-500: #F601FF;
	--magenta-700: #89008D;
	--magenta-900: #69006D;

	--blue-100: #B1B3FF;
	--blue-300: #8588FF;
	--blue-500: #252BFF;
	--blue-700: #000497;
	--blue-900: #000374;

	/* Neutrals, tinted towards violet so greys don't look dead next to it */
	--ink: #1E1433;
	--ink-muted: #6B6384;
	--surface: #FFFFFF;
	--surface-page: #F6F4FB;
	--surface-tint: #F4EEFF;
	--line: #ECE6F7;

	/* Gradients. Each runs between exactly the two colours specified; the
	   angle/stop keeps the dark end under any text (white text on the light
	   ends would fail contrast). */
	--grad-dusk:  linear-gradient(120deg, #2F0071 30%, #FCA4FF 130%);  /* #FCA4FF <-> #2F0071 */
	--grad-bloom: linear-gradient(120deg, #69006D 30%, #CEACFF 130%);  /* #CEACFF <-> #69006D */
	/* Full-range versions, for borders and decorative use without text */
	--grad-dusk-full:  linear-gradient(120deg, #2F0071, #FCA4FF);
	--grad-bloom-full: linear-gradient(120deg, #69006D, #CEACFF);

	--radius: 0.75rem;
	--radius-lg: 1.25rem;
	--shadow-sm: 0 1px 2px rgba(47, 0, 113, 0.06), 0 1px 3px rgba(47, 0, 113, 0.05);
	--shadow-md: 0 8px 24px -8px rgba(47, 0, 113, 0.25);
	--glow: 0 0 0 4px rgba(252, 164, 255, 0.25), 0 8px 28px -6px rgba(105, 0, 109, 0.55);

	/* Bootstrap hooks */
	--bs-primary: #7716FF;
	--bs-primary-rgb: 119, 22, 255;
	--bs-link-color: #7716FF;
	--bs-link-color-rgb: 119, 22, 255;
	--bs-link-hover-color: #3D0093;
	--bs-link-hover-color-rgb: 61, 0, 147;
	--bs-body-color: var(--ink);
	--bs-body-bg: var(--surface-page);
	--bs-secondary-color: var(--ink-muted);
	--bs-border-color: var(--line);
	--bs-body-font-family: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
	--bs-body-font-weight: 300;
	--bs-primary-bg-subtle: var(--surface-tint);
	--bs-primary-border-subtle: var(--violet-100);
	--bs-primary-text-emphasis: var(--violet-700);
}

/* ---------- Typography ----------
   Text 300 · numbers 400 · headings 600 · big titles 800/900 */

html, body {
	font-family: var(--bs-body-font-family);
	font-weight: 300;
	background-color: var(--surface-page);
	color: var(--ink);
}

h2, h3, h4, h5, h6,
.h2, .h3, .h4, .h5, .h6,
.card-title, strong, b, th {
	font-weight: 600;
}

/* High-order headings: every page title is an h1 (often sized .h3) */
h1, .h1, .display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
	font-weight: 800;
	letter-spacing: -0.02em;
}
.title-black { font-weight: 900; letter-spacing: -0.03em; }

.text-muted, .text-body-secondary { color: var(--ink-muted) !important; }

/* Numbers: regular weight, tabular figures so columns line up */
.num,
.table td.text-end,
.table th.text-end,
input[type="number"],
input[type="date"] {
	font-weight: 400;
	font-variant-numeric: tabular-nums;
}
.table .fw-bold td.text-end { font-weight: 600; }

/* Form controls hold data, so they read at regular weight. They need a
   stronger edge than --line (card borders) or they vanish on white. */
.form-control, .form-select, .budget-table input, .budget-table select {
	font-weight: 400;
}
.form-control, .form-select {
	border-color: #D6CCE8;
}

.form-control:focus, .form-select:focus {
	border-color: var(--violet-300);
	box-shadow: 0 0 0 0.25rem rgba(119, 22, 255, 0.18);
}
.form-check-input:checked {
	background-color: var(--violet-500);
	border-color: var(--violet-500);
}

/* ---------- Buttons ---------- */

.btn { font-weight: 400; }

.btn-primary {
	--bs-btn-bg: var(--violet-500);
	--bs-btn-border-color: var(--violet-500);
	--bs-btn-hover-bg: var(--violet-700);
	--bs-btn-hover-border-color: var(--violet-700);
	--bs-btn-active-bg: var(--violet-900);
	--bs-btn-active-border-color: var(--violet-900);
	--bs-btn-disabled-bg: var(--violet-300);
	--bs-btn-disabled-border-color: var(--violet-300);
	--bs-btn-focus-shadow-rgb: 119, 22, 255;
}

.btn-outline-primary {
	--bs-btn-color: var(--violet-500);
	--bs-btn-border-color: var(--violet-300);
	--bs-btn-hover-bg: var(--violet-500);
	--bs-btn-hover-border-color: var(--violet-500);
	--bs-btn-active-bg: var(--violet-700);
	--bs-btn-active-border-color: var(--violet-700);
	--bs-btn-focus-shadow-rgb: 119, 22, 255;
}

/* Flashy button: Dusk fill, Bloom border. On hover/focus the border's
   gradient rotates around the button - the "active" effect. */
@property --flashy-angle {
	syntax: '<angle>';
	initial-value: 0deg;
	inherits: false;
}

.btn-flashy {
	--bs-btn-color: #fff;
	--bs-btn-hover-color: #fff;
	--bs-btn-active-color: #fff;
	--bs-btn-border-color: transparent;
	--bs-btn-hover-border-color: transparent;
	--bs-btn-active-border-color: transparent;
	--bs-btn-disabled-border-color: transparent;
	--bs-btn-disabled-color: #fff;
	--bs-btn-border-width: 2px;
	--bs-btn-focus-box-shadow: var(--glow);
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(47, 0, 113, 0.45);
	background:
		var(--grad-dusk) padding-box,
		conic-gradient(from var(--flashy-angle), #69006D, #CEACFF, #69006D, #CEACFF, #69006D) border-box;
	box-shadow: var(--shadow-md);
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.btn-flashy:hover,
.btn-flashy:focus-visible {
	box-shadow: var(--glow);
	transform: translateY(-1px);
	animation: flashy-spin 2.4s linear infinite;
}

.btn-flashy:active { transform: translateY(0); }

@keyframes flashy-spin {
	to { --flashy-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
	.btn-flashy:hover, .btn-flashy:focus-visible {
		animation: none;
		transform: none;
	}
}

/* Quiet button for use on gradient backgrounds */
.btn-ghost-light {
	--bs-btn-color: #fff;
	--bs-btn-border-color: rgba(255, 255, 255, 0.55);
	--bs-btn-hover-color: var(--violet-900);
	--bs-btn-hover-bg: #fff;
	--bs-btn-hover-border-color: #fff;
	--bs-btn-active-color: var(--violet-900);
	--bs-btn-active-bg: #fff;
}

/* ---------- Brand mark (the piggy bank) ---------- */

.brand-mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: 0.6rem;
	border: 1.5px solid transparent;
	background:
		var(--grad-dusk) padding-box,
		var(--grad-bloom-full) border-box;
	color: #fff;
	font-size: 1.05rem;
	line-height: 1;
	flex: 0 0 auto;
}
.brand-mark-lg {
	width: 4rem;
	height: 4rem;
	border-radius: 1.1rem;
	border-width: 2px;
	font-size: 2rem;
	box-shadow: var(--shadow-md);
}
/* Feature icons on the landing page use the same tile */
.brand-mark-md {
	width: 3rem;
	height: 3rem;
	border-radius: 0.9rem;
	font-size: 1.4rem;
}

/* ---------- Shell ---------- */

.navbar.bg-brand {
	background: var(--violet-900);
}
.navbar.bg-brand .navbar-brand { font-weight: 600; letter-spacing: -0.01em; }

.sidebar.bg-light { background: var(--surface) !important; border-color: var(--line) !important; }
.sidebar .nav-link { color: var(--ink); }
.sidebar .nav-link:hover { background-color: var(--surface-tint); }
.sidebar .nav-link.active {
	color: #fff;
	font-weight: 600;
	background: var(--grad-dusk);
	box-shadow: var(--shadow-md);
}
.sidebar .sidebar-heading { color: var(--ink-muted) !important; }

/* ---------- Cards & important boxes ---------- */

.card {
	border-color: var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
}

/* Full-gradient box. Keep text on the dark (left/top) side. */
.box-dusk, .box-bloom {
	color: #fff;
	border: 0;
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
}
.box-dusk  { background: var(--grad-dusk); }
.box-bloom { background: var(--grad-bloom); }
.box-dusk .text-muted, .box-bloom .text-muted { color: rgba(255, 255, 255, 0.75) !important; }

/* Important data box: gradient border + gradient header band, white body,
   so tables and numbers stay on a plain background. */
.card-important {
	border: 2px solid transparent;
	background:
		linear-gradient(var(--surface), var(--surface)) padding-box,
		var(--grad-bloom-full) border-box;
	box-shadow: var(--shadow-md);
}
.card-important > .card-header {
	background: var(--grad-dusk);
	color: #fff;
	border: 0;
	border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0;
	font-weight: 600;
	padding: 0.65rem 1rem;
}
.card-important > .card-header .text-muted { color: rgba(255, 255, 255, 0.75) !important; }

/* ---------- Tables ---------- */

.table {
	--bs-table-border-color: var(--line);
	--bs-table-color: var(--ink);
	margin-bottom: 0;
}

.table > thead th,
.table > thead.table-light th {
	--bs-table-bg: var(--surface-tint);
	--bs-table-color: var(--violet-700);
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	white-space: nowrap;
	border-bottom: 2px solid var(--violet-100);
	padding-top: 0.6rem;
	padding-bottom: 0.6rem;
}

.table > tbody > tr > td { vertical-align: middle; }

/* Breathing room at the edges, so text doesn't touch a card's border */
.table > :not(caption) > tr > *:first-child { padding-left: 1rem; }
.table > :not(caption) > tr > *:last-child { padding-right: 1rem; }

/* Every table gets a soft hover, not just .table-hover ones */
.table > tbody > tr:hover > * {
	--bs-table-bg-state: #FAF6FF;
}

/* Totals row */
.table > tbody > tr.fw-bold > td {
	--bs-table-bg: var(--surface-tint);
	border-top: 2px solid var(--violet-100);
}

/* New-entry row in the entries table */
.table > tbody > tr.table-info > * {
	--bs-table-bg: #FDF3FF;
	--bs-table-color: var(--ink);
	--bs-table-border-color: #F3D9F7;
}
.table > tbody > tr.table-info > td:first-child {
	box-shadow: inset 3px 0 0 var(--magenta-500);
}

/* Bordered entries table: hairline verticals only */
.budget-table.table-bordered > :not(caption) > * > * {
	border-left-width: 0;
	border-right-width: 0;
}
.budget-table th, .budget-table td { padding: 0.45rem 0.4rem; }
/* Fixed, narrow columns: let headers wrap instead of overlapping */
.budget-table > thead th,
.budget-table > thead.table-light th {
	white-space: normal;
	vertical-align: bottom;
	letter-spacing: 0.03em;
	overflow-wrap: normal;
	word-wrap: normal;
}

/* Cards that hold a table edge to edge: clip the table to the card's corners */
.card > .card-body.p-0, .card > .table-responsive {
	border-radius: inherit;
	overflow: hidden;
}

/* ---------- Bits ---------- */

.text-gradient {
	background: var(--grad-dusk-full);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.badge { font-weight: 600; }
.text-bg-primary { background-color: var(--violet-500) !important; }

.alert { border-radius: var(--radius); }

/* ---------- Landing: hero ---------- */

.hero {
	position: relative;
	overflow: hidden;
	color: #fff;
	border-radius: var(--radius-lg);
	background: var(--grad-bloom);
	padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 5vw, 4.5rem);
	box-shadow: var(--shadow-md);
	isolation: isolate;
}
/* Soft light blobs for depth, on the light side only */
.hero::before, .hero::after {
	content: "";
	position: absolute;
	border-radius: 50%;
	filter: blur(60px);
	z-index: -1;
	pointer-events: none;
}
.hero::before {
	width: 28rem; height: 28rem;
	right: -6rem; top: -8rem;
	background: rgba(252, 164, 255, 0.55);
}
.hero::after {
	width: 22rem; height: 22rem;
	right: 18%; bottom: -12rem;
	background: rgba(119, 22, 255, 0.45);
}

.hero-eyebrow {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	padding: 0.35rem 0.8rem;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	border: 1px solid rgba(255, 255, 255, 0.25);
	margin-bottom: 1.25rem;
}
.hero-title {
	font-weight: 900;
	font-size: clamp(2.2rem, 5vw, 3.75rem);
	line-height: 1.05;
	letter-spacing: -0.035em;
	margin-bottom: 1.25rem;
}
.hero-lead {
	font-size: 1.2rem;
	font-weight: 300;
	color: rgba(255, 255, 255, 0.85);
	max-width: 34rem;
	margin-bottom: 2rem;
}

/* Product teaser card floating on the hero's light side */
.hero-mock {
	color: var(--ink);
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: blur(8px);
	border-radius: var(--radius-lg);
	box-shadow: 0 24px 60px -20px rgba(47, 0, 113, 0.6);
	padding: 1.5rem;
	transform: rotate(-2deg);
}
.hero-mock .mock-label {
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-muted);
}
.hero-mock .mock-value { font-size: 2rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.progress-brand { height: 0.5rem; background: var(--surface-tint); border-radius: 999px; }
.progress-brand .progress-bar { background: var(--grad-dusk-full); border-radius: 999px; }

.cta-panel {
	background: var(--surface-tint);
	border-radius: var(--radius-lg);
	border: 1px solid var(--violet-100);
}

/* ---------- /design specimen page ---------- */

.swatch {
	border-radius: var(--radius);
	height: 4.5rem;
	display: flex;
	align-items: flex-end;
	padding: 0.5rem 0.65rem;
	font-size: 0.75rem;
	font-weight: 400;
	font-variant-numeric: tabular-nums;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.swatch-grad { height: 7rem; }
.spec-label {
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-muted);
}
.spec-code {
	font-size: 0.8rem;
	background: var(--surface-tint);
	color: var(--violet-700);
	border-radius: 0.4rem;
	padding: 0.1rem 0.4rem;
}
