/* ==========================================================================
   FeeCheck — Clean Financial Calculator Design
   Inspired by Square, NerdWallet, and Bankrate calculators.
   Professional, trustworthy, clean.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- Design Tokens --- */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-footer: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;

    --accent-primary: #1e40af;
    --accent-primary-hover: #1e3a8a;
    --accent-danger: #dc2626;
    --accent-danger-bg: #fef2f2;
    --accent-success: #16a34a;
    --accent-success-bg: #f0fdf4;
    --accent-warning: #d97706;
    --accent-warning-bg: #fffbeb;
    --accent-action: #0f172a;
    --accent-action-hover: #1e293b;

    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --focus-ring: #3b82f6;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);

    --space-xs: 0.4rem;
    --space-sm: 0.75rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
    --space-2xl: 6rem;
}

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

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-weight: 400;
    font-size: 16px;
    overflow-x: hidden;
}

/* --- Scroll-triggered fade-in (subtle) --- */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.08s; }
.reveal-delay-2 { transition-delay: 0.16s; }
.reveal-delay-3 { transition-delay: 0.24s; }

/* --- Page Container --- */
.page-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.page-container-wide {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- Header / Nav --- */
.site-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-family: var(--font);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.site-logo:hover {
    color: var(--accent-primary);
}

.site-nav-link {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.site-nav-link:hover {
    color: var(--text-primary);
}

/* --- Buttons --- */
.btn-primary {
    display: inline-block;
    background: var(--accent-action);
    color: var(--text-inverse);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.85rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    background: var(--accent-action-hover);
    box-shadow: var(--shadow-md);
}

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

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary:disabled:hover {
    background: var(--accent-action);
    box-shadow: none;
}

.btn-secondary {
    display: inline-block;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.65rem 1.4rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    background: var(--bg-secondary);
}

/* --- Cards --- */
.card-flat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* --- Form Elements --- */
.form-input {
    width: 100%;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    font-family: var(--font);
    font-size: 0.92rem;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-select {
    width: auto;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.6rem 2.2rem 0.6rem 0.9rem;
    font-family: var(--font);
    font-size: 0.92rem;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    transition: border-color 0.2s ease;
    outline: none;
}

.form-select:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    margin-bottom: 0.4rem;
}

/* --- Fund Row (app.html) --- */
.fund-row {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.fund-row:hover {
    border-color: var(--border-hover);
}

.fund-row:focus-within {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.fund-row .fund-number {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-tertiary);
}

.fund-row .remove-fund {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
    font-family: var(--font);
}

.fund-row .remove-fund:hover {
    color: var(--accent-danger);
}

/* --- Search Autocomplete Dropdown --- */
.search-results {
    scrollbar-width: thin;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.search-result-item {
    transition: background 0.15s ease;
}

.search-result-item:hover {
    background: var(--bg-secondary) !important;
}

.search-result-item:last-child {
    border-bottom: none;
}

/* --- Error / Success Messages --- */
.msg-error {
    background: var(--accent-danger-bg);
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--accent-danger);
    font-size: 0.88rem;
    line-height: 1.5;
}

.msg-success {
    background: var(--accent-success-bg);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--accent-success);
    font-size: 0.88rem;
}

/* --- Rating Badges --- */
.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
}

.badge-green {
    background: #dcfce7;
    color: var(--accent-success);
}

.badge-yellow {
    background: #fef3c7;
    color: var(--accent-warning);
}

.badge-red {
    background: #fee2e2;
    color: var(--accent-danger);
}

/* --- Bento Grid (results page) --- */
.bento-grid {
    display: grid;
    gap: 0.75rem;
}

.bento-grid-stats {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

@media (max-width: 768px) {
    .bento-grid-stats {
        grid-template-columns: 1fr 1fr;
    }
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-value.danger {
    color: var(--accent-danger);
}

.stat-card .stat-value.success {
    color: var(--accent-success);
}

/* --- Table --- */
.data-table {
    width: 100%;
    font-size: 0.88rem;
    border-collapse: collapse;
}

.data-table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1.5px solid var(--border);
}

.data-table thead th.text-right {
    text-align: right;
}

.data-table thead th.text-center {
    text-align: center;
}

.data-table tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- AI Narrative Block --- */
.narrative-block {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 1.5rem;
}

.narrative-block .narrative-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin-bottom: 0.75rem;
}

.narrative-block .narrative-text {
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.7;
}

.narrative-block .narrative-text p {
    margin-bottom: 0.5rem;
}

.narrative-block .narrative-text p:last-child {
    margin-bottom: 0;
}

.narrative-block .narrative-text ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.narrative-block .narrative-text li {
    margin-bottom: 0.35rem;
    line-height: 1.6;
}

.narrative-block .narrative-text li:last-child {
    margin-bottom: 0;
}

/* --- Signup Option Cards --- */
.signup-option {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 0.9rem 1.1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.signup-option:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.signup-option.selected {
    border-color: var(--accent-primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.08);
}

/* --- Loading Spinner --- */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- "Gut Punch" Number --- */
.gut-punch-number {
    font-family: var(--font);
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    font-weight: 700;
    color: var(--accent-danger);
    line-height: 1;
    letter-spacing: -0.03em;
}

/* --- Footer --- */
.site-footer {
    background: var(--bg-footer);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: var(--space-xl);
}

.site-footer p {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    line-height: 1.7;
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
}

.site-footer p + p {
    margin-top: 0.5rem;
}

/* --- Landing Page: Hero --- */
.hero {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-xl) 1.5rem var(--space-lg);
    text-align: center;
}

.hero-content {
    max-width: 620px;
}

.hero-headline {
    font-family: var(--font);
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}

.hero-headline em {
    font-style: normal;
    color: var(--accent-danger);
}

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

.hero-cta-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.hero-cta-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* --- Landing Page: Steps Section --- */
.steps-section {
    padding: var(--space-xl) 0 var(--space-2xl);
}

.steps-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .steps-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
}

.step-number {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-inverse);
    background: var(--accent-action);
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 0.75rem;
}

.step-title {
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.step-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Next Steps List --- */
.next-steps-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0;
}

.next-steps-item + .next-steps-item {
    border-top: 1px solid var(--border);
}

.next-steps-number {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-inverse);
    background: var(--accent-success);
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.next-steps-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* --- Section Headings --- */
.section-heading {
    font-family: var(--font);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* --- Add Fund Link Button --- */
.add-fund-link {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    cursor: pointer;
    padding: 0.4rem 0;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.add-fund-link:hover {
    color: var(--accent-primary-hover);
}

.add-fund-link::before {
    content: '+';
    font-size: 1.1em;
    font-weight: 400;
}

/* --- Toggle Link --- */
.toggle-link {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 0.78rem;
    color: var(--text-tertiary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

.toggle-link:hover {
    color: var(--text-primary);
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .hero-headline {
        font-size: clamp(1.8rem, 8vw, 2.8rem);
    }

    .card-flat {
        padding: 1.15rem;
    }

    .page-container, .page-container-wide {
        padding: 0 1rem;
    }

    #projection-chart {
        min-height: 240px;
    }
}

/* --- Print Styles --- */
@media print {
    .site-header,
    .site-footer,
    #cta-submit,
    #cta-email,
    .remove-fund,
    .signup-option {
        display: none !important;
    }

    body {
        background: white;
    }

    .card-flat {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* --- Hidden utility --- */
.hidden {
    display: none !important;
}
