/* Budget & Impact Calculator */

:root {
    color-scheme: light dark;
    /* Warm sand + teal (alternative to blue) */
    --btn-from: #0d9488;
    --btn-to: #0f766e;
    --bg: #f5f2eb;
    --bg-gradient: radial-gradient(ellipse 880px 480px at 12% -8%, rgba(13, 148, 136, 0.14) 0%, transparent 52%),
        radial-gradient(ellipse 720px 420px at 92% 8%, rgba(180, 83, 9, 0.08) 0%, transparent 48%),
        radial-gradient(ellipse 640px 380px at 48% 102%, rgba(13, 148, 136, 0.06) 0%, transparent 42%),
        var(--bg);
    --surface: #fffcf7;
    --surface-elevated: #fffcf7;
    --text: #1c1917;
    --text-muted: #78716c;
    --accent: #0f766e;
    --accent-hover: #115e59;
    --accent-soft: rgba(13, 148, 136, 0.1);
    --accent-line: rgba(13, 148, 136, 0.5);
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --error-bg: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
    --error-border: #fecaca;
    --error-text: #991b1b;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 1px 3px rgba(28, 25, 23, 0.05), 0 14px 36px rgba(28, 25, 23, 0.07);
    --shadow-stat: 0 1px 2px rgba(28, 25, 23, 0.04);
    --shadow-focus: 0 0 0 3px rgba(13, 148, 136, 0.28);
    --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --btn-from: #2dd4bf;
        --btn-to: #14b8a6;
        --bg: #0c0f0e;
        --bg-gradient: radial-gradient(ellipse 880px 480px at 12% -8%, rgba(45, 212, 191, 0.12) 0%, transparent 52%),
            radial-gradient(ellipse 720px 420px at 92% 8%, rgba(251, 146, 60, 0.06) 0%, transparent 48%),
            var(--bg);
        --surface: #141a18;
        --surface-elevated: #1a2220;
        --text: #f5f5f4;
        --text-muted: #a8a29e;
        --accent: #5eead4;
        --accent-hover: #99f6e4;
        --accent-soft: rgba(45, 212, 191, 0.12);
        --accent-line: rgba(94, 234, 212, 0.45);
        --border: #292524;
        --border-strong: #44403c;
        --error-bg: linear-gradient(135deg, rgba(127, 29, 29, 0.35) 0%, rgba(153, 27, 27, 0.18) 100%);
        --error-border: #b91c1c;
        --error-text: #fecaca;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 16px 44px rgba(0, 0, 0, 0.42);
        --shadow-stat: 0 1px 2px rgba(0, 0, 0, 0.25);
        --shadow-focus: 0 0 0 3px rgba(45, 212, 191, 0.35);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-gradient);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 30rem;
    margin: 0 auto;
    padding: clamp(1.75rem, 5vw, 3rem) clamp(1.1rem, 4vw, 1.75rem) 3.5rem;
}

/* —— Header —— */
.page-header {
    margin-bottom: 2rem;
    text-align: center;
}

h1 {
    font-size: clamp(1.65rem, 5vw, 2.05rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin: 0 0 0.65rem;
    color: var(--text);
}

.intro {
    margin: 0 auto;
    max-width: 26rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* —— Cards —— */
.card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.35rem;
    margin-bottom: 1.35rem;
    box-shadow: var(--shadow);
}

.card--form {
    padding-bottom: 1.6rem;
}

.card--results {
    padding-top: 1.5rem;
}

.card-heading {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: none;
    color: var(--text);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent-soft);
}

/* —— Form —— */
.field {
    margin-bottom: 1.15rem;
}

.field:last-of-type {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
    color: var(--text);
    margin-bottom: 0.45rem;
}

.field .input-num {
    width: 100%;
    padding: 0.72rem 0.95rem;
    font-family: inherit;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field .input-num::placeholder {
    color: var(--text-muted);
    opacity: 0.65;
}

.field .input-num:hover {
    border-color: var(--accent);
}

.field .input-num:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
    background: var(--surface-elevated);
}

.form-actions {
    margin-top: 1.5rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--border);
}

.btn-primary {
    width: 100%;
    padding: 0.82rem 1.25rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(180deg, var(--btn-from) 0%, var(--btn-to) 100%);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.35), 0 8px 24px rgba(15, 118, 110, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    text-align: center;
    box-sizing: border-box;
}

a.btn-primary {
    display: block;
    text-decoration: none;
}

a.btn-primary:hover {
    color: #fff;
}

button.btn-primary {
    cursor: pointer;
}

.btn-primary:hover {
    filter: brightness(1.06);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.38), 0 12px 32px rgba(15, 118, 110, 0.22);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus), 0 4px 16px rgba(13, 148, 136, 0.3);
}

/* —— Errors —— */
.messages {
    padding: 1rem 1.15rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.35rem;
    border-left: 4px solid #dc2626;
}

.messages.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-left: 4px solid #dc2626;
    color: var(--error-text);
}

.messages strong {
    font-size: 0.9rem;
}

.messages ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.messages li {
    margin-bottom: 0.3rem;
}

/* Anchor target after submit — avoid heavy focus ring on whole card */
#impact-results:focus {
    outline: none;
}

/* —— Results grid —— */
.results-grid {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 520px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat--wide {
        grid-column: 1 / -1;
    }
}

.stat {
    margin: 0;
    padding: 1rem 1rem 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-line);
    box-shadow: var(--shadow-stat);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat:hover {
    border-left-color: var(--accent);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
    .stat:hover {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    }
}

.results dt {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.4rem;
    line-height: 1.35;
}

.results dd {
    margin: 0;
    font-size: 1.28rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1.2;
}

/* —— Secondary actions —— */
.results-actions {
    display: grid;
    gap: 0.65rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

@media (min-width: 400px) {
    .results-actions {
        grid-template-columns: 1fr 1fr;
    }
}

.btn-secondary {
    width: 100%;
    padding: 0.68rem 0.9rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    filter: none;
    box-shadow: none;
}

.btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.share-status {
    min-height: 1.25rem;
    margin: 0.65rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}

.social-share {
    margin-top: 1rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}

.social-share-label {
    margin: 0 0 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.social-share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-social {
    padding: 0.45rem 0.75rem;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-social:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-social:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.social-share-hint {
    margin: 0.65rem 0 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.results-reset {
    margin-top: 0.85rem;
}

@media (min-width: 560px) {
    .page {
        max-width: 38rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }

    .btn-primary:active {
        transform: none;
    }
}
