/* ==========================================================================
   Clarifolio brand system
   Tokens per BRANDING.md — quiet forest green + muted gold, editorial serif
   headings, calm grotesk body. Default: prefers-color-scheme. An explicit
   [data-theme] (set by the nav toggle, persisted to localStorage) overrides
   the system preference in either direction.
   ========================================================================== */

/* Self-hosted variable fonts (same-origin — no third-party font request, no
   extra DNS/TLS round trip). Both are the real Google Fonts variable files,
   latin subset only (this site's content doesn't need cyrillic/greek/vietnamese),
   deduped to one file per family and declared with a font-weight range so the
   browser interpolates every weight actually used (400/600 heading, 400-700 body)
   from a single download instead of one file per weight. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/inter-variable-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Fraunces';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('../fonts/fraunces-variable-latin.woff2') format('woff2');
}

:root {
    color-scheme: light dark;

    --bg: #F7F4EE;
    --surface: #FFFFFF;
    --text-primary: #1F2A24;
    --text-secondary: #5C6B62;
    --brand: #1B4332;
    --accent: #C9A227;
    --border: #E4DFD3;
    --positive: #2F6B4F;
    --negative: #8C4A3B;

    --font-heading: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --container-width: 1200px;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101512;
        --surface: #171E1A;
        --text-primary: #EDEAE1;
        --text-secondary: #9AA79E;
        --brand: #6FBF97;
        --accent: #E0B94A;
        --border: #2A332D;
        --positive: #5FA786;
        --negative: #B2685A;
    }
}

[data-theme="light"] {
    --bg: #F7F4EE;
    --surface: #FFFFFF;
    --text-primary: #1F2A24;
    --text-secondary: #5C6B62;
    --brand: #1B4332;
    --accent: #C9A227;
    --border: #E4DFD3;
    --positive: #2F6B4F;
    --negative: #8C4A3B;
}

[data-theme="dark"] {
    --bg: #101512;
    --surface: #171E1A;
    --text-primary: #EDEAE1;
    --text-secondary: #9AA79E;
    --brand: #6FBF97;
    --accent: #E0B94A;
    --border: #2A332D;
    --positive: #5FA786;
    --negative: #B2685A;
}

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

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg);
    font-size: 16px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--brand);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

ul {
    list-style: none;
}

/* 2. Layout & Guardrails */
.container {
    width: 100%;
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 768px) {
    .container {
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: var(--container-width);
    }
}

section {
    padding: var(--spacing-lg) 0;
}

.section-alt {
    background-color: var(--surface);
}

/* 3. Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.35rem; }
p { margin-bottom: 1rem; color: var(--text-secondary); }

.text-center { text-align: center; }
.text-lead { font-size: 1.15rem; color: var(--text-secondary); }
.text-small { font-size: 0.875rem; }
.text-negative { color: var(--negative); }

.section-heading {
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    h1 { font-size: 3.25rem; }
    h2 { font-size: 2.25rem; }
}

/* 4. Components */
/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--brand);
    color: var(--surface);
    border-color: var(--brand);
}

.btn-primary:hover {
    opacity: 0.9;
    text-decoration: none;
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-outline:hover {
    border-color: var(--brand);
    color: var(--brand);
    text-decoration: none;
}

.btn-on-brand {
    background-color: var(--surface);
    color: var(--brand);
    border-color: var(--surface);
    font-weight: 700;
}

.btn-on-brand:hover {
    opacity: 0.9;
    text-decoration: none;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none;
    padding: 0.75rem 0.25rem;
}

.btn-link:hover {
    color: var(--brand);
    text-decoration: none;
}

/* Navigation */
.navbar {
    padding: 0.25rem 0;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 60px;
    width: auto;
}

.brand-logo-dark { display: none; }

@media (prefers-color-scheme: dark) {
    .brand-logo-light { display: none; }
    .brand-logo-dark { display: block; }
}

[data-theme="light"] .brand-logo-light { display: block; }
[data-theme="light"] .brand-logo-dark { display: none; }
[data-theme="dark"] .brand-logo-light { display: none; }
[data-theme="dark"] .brand-logo-dark { display: block; }

.nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
}

.nav-toggle-icon {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    position: relative;
    transition: background-color 0.2s;
    border-radius: 2px;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--text-primary);
    transition: transform 0.2s;
    border-radius: 2px;
}

.nav-toggle-icon::before { top: -8px; }
.nav-toggle-icon::after { top: 8px; }

.nav-links {
    display: none;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.nav-links.active {
    display: flex;
}

@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }

    .nav-links {
        display: flex;
        flex-direction: row;
        gap: 1.5rem;
        align-items: center;
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
}

/* Page Content Wrapper for consistent padding */
.page-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

@media (min-width: 768px) {
    .page-content {
        padding: 4rem 0;
    }
}

.page-content section {
    padding: 2rem 0;
}

.page-content a {
    color: var(--brand);
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
}

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

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    flex-shrink: 0;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
    .theme-toggle .icon-sun { display: block; }
    .theme-toggle .icon-moon { display: none; }
}

[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Grid System */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }

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

/* Cards */
.card {
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Toggle Switch (billing period, on Pricing) */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 54px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: var(--surface);
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--brand);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--brand);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.toggle-label {
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

.toggle-label.active {
    color: var(--text-primary);
    font-weight: 700;
}

/* Pricing Cards */
.pricing-card {
    text-align: center;
    position: relative;
    padding: 3rem 2rem;
    transition: transform 0.2s;
}

.pricing-card:hover {
    transform: translateY(-5px);
}

.pricing-price {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-primary);
}

.pricing-price-caption {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
    color: var(--text-secondary);
}

.pricing-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.pricing-feature-excluded {
    color: var(--text-secondary);
    text-decoration: line-through;
    font-weight: 400;
    opacity: 0.7;
}

.pricing-card-dark p {
    color: var(--surface);
    opacity: 0.75;
}

.pricing-card-dark .pricing-price-caption {
    color: var(--surface);
    opacity: 0.75;
}

.pricing-card-dark .pricing-feature {
    color: var(--surface);
}

.pricing-card-dark .pricing-feature-excluded {
    color: var(--surface);
    opacity: 0.4;
}

.pricing-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--surface);
    padding: 0.25rem 0.85rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.pricing-badge-accent {
    background-color: var(--accent);
    color: var(--text-primary);
}

.pricing-badge-brand {
    background-color: var(--brand);
}

.pricing-card-dark {
    background-color: var(--brand);
    color: var(--surface);
    border: none;
}

.pricing-card-dark h3,
.pricing-card-dark .pricing-price {
    color: var(--surface);
}

.btn-white {
    background-color: var(--surface);
    color: var(--brand);
    border: 1px solid var(--surface);
}

.btn-white:hover {
    opacity: 0.9;
    text-decoration: none;
}

.price-yearly { display: none; }
.price-monthly { display: block; }

body.show-yearly .price-yearly { display: block; }
body.show-yearly .price-monthly { display: none; }

/* 5. Specific sections — Home */

/* Hero */
.hero {
    padding-top: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
}

.hero-grid {
    display: grid;
    gap: var(--spacing-lg);
    align-items: center;
}

@media (min-width: 992px) {
    .hero-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.hero-subhead {
    max-width: 520px;
    margin: 0 0 2rem;
    font-size: 1.15rem;
    color: var(--text-secondary);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
}

/* Illustrative mock cards (hero "review view" + year in review) */
.mock-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.75rem;
    box-shadow: 0 1.5rem 3rem rgba(27, 67, 50, 0.08);
}

.mock-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.mock-card-title {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
}

.mock-card-caption {
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.mock-holdings li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.mock-holdings li:last-child { border-bottom: none; }

.mock-ticker {
    font-weight: 700;
    color: var(--text-primary);
    width: 4rem;
}

.mock-detail {
    color: var(--text-secondary);
    flex: 1;
    text-align: left;
    padding-left: 1rem;
}

.mock-value {
    font-weight: 600;
    color: var(--text-primary);
}

.mock-divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

.mock-dividend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.mock-pill {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
}

/* The problem */
.problem-inner {
    max-width: 720px;
}

/* How it works */
.steps {
    margin-top: 1rem;
}

.step {
    text-align: left;
}

.step-number {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

/* Feature grid */
.feature-icon {
    color: var(--brand);
    margin-bottom: 1rem;
}

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

.feature-card p:last-child {
    margin-bottom: 0;
}

.badge-coming {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 0.1rem 0.5rem;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.feature-card-muted {
    background-color: transparent;
    border-style: dashed;
}

.feature-card-muted h3,
.feature-card-muted p {
    color: var(--text-secondary);
}

.feature-card-cta {
    background-color: var(--brand);
    color: var(--surface);
    justify-content: center;
    text-align: center;
}

.feature-card-cta h3,
.feature-card-cta p {
    color: var(--surface);
}

.feature-card-cta p {
    opacity: 0.85;
}

/* Year in review */
.year-review-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2.5rem;
}

@media (min-width: 768px) {
    .year-review-card {
        padding: 3.5rem;
    }
}

.year-review-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.year-review-header h2 {
    margin-bottom: 0;
}

.year-review-stats {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .year-review-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.split-bar-wrap .stat-label {
    display: block;
    margin-bottom: 0.5rem;
}

.split-bar {
    display: flex;
    height: 10px;
    border-radius: 1rem;
    overflow: hidden;
    background: var(--border);
}

.split-bar-reinvested { background: var(--positive); }
.split-bar-withdrawn { background: var(--text-secondary); opacity: 0.5; }

.split-bar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.split-bar-legend .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

.dot-positive { background: var(--positive); }
.dot-muted { background: var(--text-secondary); opacity: 0.5; }

/* Footer */
footer {
    padding: var(--spacing-lg) 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .footer-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .footer-links {
        margin-bottom: 0;
    }
}
