/* ═══════════════════════════════════════════════════════════
   CoastCalc — Styles
   Premium dark theme with teal/green financial accent
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    /* Palette */
    --bg-primary:     hsl(220, 25%, 8%);
    --bg-secondary:   hsl(220, 22%, 12%);
    --bg-card:        hsla(220, 22%, 14%, 0.65);
    --bg-card-hover:  hsla(220, 22%, 18%, 0.75);
    --border-glass:   hsla(180, 60%, 55%, 0.12);
    --border-glow:    hsla(168, 80%, 50%, 0.30);

    --text-primary:   hsl(210, 20%, 92%);
    --text-secondary: hsl(215, 15%, 60%);
    --text-muted:     hsl(215, 12%, 42%);

    --accent:         hsl(168, 80%, 50%);
    --accent-dim:     hsl(168, 60%, 38%);
    --accent-glow:    hsla(168, 80%, 50%, 0.25);
    --accent-subtle:  hsla(168, 80%, 50%, 0.08);

    --green-up:       hsl(145, 65%, 50%);
    --red-down:       hsl(0, 70%, 58%);
    --amber-warn:     hsl(38, 90%, 55%);

    /* Typography */
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --space-xs:  0.375rem;
    --space-sm:  0.75rem;
    --space-md:  1.25rem;
    --space-lg:  2rem;
    --space-xl:  3rem;
    --space-2xl: 5rem;

    /* Radii */
    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;

    /* Shadows */
    --shadow-card: 0 4px 24px hsla(0, 0%, 0%, 0.35), 0 1px 4px hsla(0, 0%, 0%, 0.2);
    --shadow-glow: 0 0 30px var(--accent-glow), 0 0 60px hsla(168, 80%, 50%, 0.08);

    /* Transitions */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --duration: 0.3s;
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle animated gradient background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, hsla(220, 60%, 18%, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, hsla(168, 50%, 15%, 0.35) 0%, transparent 55%);
    z-index: -1;
    pointer-events: none;
}

.mono {
    font-family: var(--font-mono);
}

.accent {
    color: var(--accent);
}

/* ─── Layout ─── */
.section {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
}

/* ─── Header ─── */
#site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: hsla(220, 25%, 8%, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border-glass);
    padding: var(--space-sm) var(--space-md);
}

.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.logo-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    display: none;
}

/* ─── Hero ─── */
#hero-section {
    text-align: center;
    padding-top: var(--space-xl);
    padding-bottom: var(--space-lg);
}

.hero-text h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-sm);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero-text p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ─── Glass Cards ─── */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow-card);
    padding: var(--space-lg);
    transition: border-color var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out);
}

.glass-card:hover {
    border-color: var(--border-glow);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

/* ─── Calculator Layout ─── */
.calc-layout {
    display: grid;
    gap: var(--space-lg);
}

/* ─── Input Panel ─── */
.input-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.input-group label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid hsla(220, 20%, 25%, 0.6);
    border-radius: var(--radius-sm);
    transition: border-color var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out);
}

.input-wrapper:focus-within {
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0.7rem 0.85rem;
    appearance: textfield;
    -moz-appearance: textfield;
}

.input-wrapper input::-webkit-outer-spin-button,
.input-wrapper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.has-prefix input {
    padding-left: 0;
}

.input-prefix {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent);
    padding-left: 0.85rem;
    flex-shrink: 0;
    user-select: none;
}

.input-unit {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-right: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    user-select: none;
}

/* ─── Calculate Button ─── */
#calculate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 0.9rem 1.5rem;
    margin-top: var(--space-xs);
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    color: hsl(220, 25%, 8%);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out),
                filter var(--duration) var(--ease-out);
    box-shadow: 0 4px 20px var(--accent-glow);
}

#calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
    filter: brightness(1.08);
}

#calculate-btn:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.btn-icon {
    font-size: 1.2rem;
    transition: transform var(--duration) var(--ease-out);
}

#calculate-btn:hover .btn-icon {
    transform: translateX(4px);
}

/* ─── Results Panel ─── */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Verdict Card */
.verdict-card {
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    position: relative;
    overflow: hidden;
}

.verdict-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, var(--accent-subtle), transparent 70%);
    opacity: 0;
    transition: opacity 0.6s var(--ease-out);
    pointer-events: none;
}

.verdict-card.active::before {
    opacity: 1;
}

.verdict-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
    line-height: 1;
}

.verdict-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto;
}

.verdict-card.active .verdict-text {
    color: var(--text-primary);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.stat-card {
    text-align: center;
    padding: var(--space-md) var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    transition: transform var(--duration) var(--ease-out),
                border-color var(--duration) var(--ease-out);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

/* ─── Chart Section ─── */
.chart-card {
    position: relative;
}

.chart-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 280px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
    transition: opacity 0.4s var(--ease-out);
}

.chart-hint.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ─── Explainer Section ─── */
.explainer-card {
    padding: var(--space-xl) var(--space-lg);
}

.explainer-grid {
    display: grid;
    gap: var(--space-lg);
}

.explainer-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.explainer-icon {
    font-size: 1.6rem;
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.explainer-item h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.explainer-item p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ─── Ad Slots ─── */
.ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed hsla(220, 20%, 30%, 0.5);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: var(--space-md) auto;
    background: hsla(220, 22%, 12%, 0.4);
}

.ad-mobile {
    width: 320px;
    height: 50px;
    max-width: 100%;
}

.ad-desktop {
    width: 728px;
    height: 90px;
    max-width: 100%;
    display: none;
}

/* ─── Footer ─── */
#site-footer {
    border-top: 1px solid var(--border-glass);
    padding: var(--space-lg) var(--space-md);
    margin-top: var(--space-xl);
}

.footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    text-align: center;
}

#site-footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.footer-disclaimer {
    margin-top: var(--space-xs);
    font-style: italic;
}

/* ─── Animations ─── */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50%      { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px hsla(168, 80%, 50%, 0.1); }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.animate-in {
    animation: fadeSlideUp 0.6s var(--ease-out) both;
}

.stat-card.animate-in {
    animation: countUp 0.5s var(--ease-out) both;
}

.verdict-card.celebrate {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Desktop Enhancements (min-width)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 640px) {
    .tagline {
        display: block;
    }

    .stats-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .explainer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .calc-layout {
        grid-template-columns: 380px 1fr;
        align-items: start;
    }

    .ad-mobile {
        display: none;
    }

    .ad-desktop {
        display: flex;
    }

    .chart-container {
        aspect-ratio: 16 / 9;
    }
}

@media (min-width: 1100px) {
    .section {
        padding-left: var(--space-lg);
        padding-right: var(--space-lg);
    }

    .hero-text h2 {
        font-size: 2.5rem;
    }

    .stat-value {
        font-size: 1.6rem;
    }
}
