/* ============================================================
   FinanceFrameworks — Main Stylesheet
   Design System: Dark Terminal Editorial
   Bloomberg Terminal meets luxury financial publication.
   ============================================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,400;1,9..144,600&family=JetBrains+Mono:wght@400;500;600&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* --- CSS Variables --- */
:root {
    /* Backgrounds */
    --color-bg:          #0a0b0f;
    --color-surface:     #0f1118;
    --color-surface-alt: #141720;
    --color-surface-raised: #191e2a;

    /* Borders */
    --color-border:      #1e2535;
    --color-border-dim:  #161b27;

    /* Text */
    --color-text:        #e8ecf4;
    --color-text-muted:  #c4ceda;
    --color-text-dim:    #b0baca;

    /* Gold Accent System */
    --color-gold:        #d4a853;
    --color-gold-bright: #e8c06e;
    --color-gold-dim:    rgba(212, 168, 83, 0.12);
    --color-gold-glow:   rgba(212, 168, 83, 0.25);

    /* Tier Colors */
    --color-tier-control:  #dc2626;
    --color-tier-monitor:  #f59e0b;
    --color-tier-optimize: #10b981;

    /* Status */
    --color-success:     #10b981;
    --color-error:       #ef4444;

    /* Fonts */
    --font-display: 'Fraunces', 'Georgia', serif;
    --font-sans:    'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'IBM Plex Mono', monospace;

    /* Type Scale (+5px from original) */
    --text-xs:    1.125rem;    /* 18px */
    --text-sm:    1.25rem;     /* 20px */
    --text-base:  1.375rem;    /* 22px */
    --text-lg:    1.5rem;      /* 24px */
    --text-xl:    1.6875rem;   /* 27px */
    --text-2xl:   2rem;        /* 32px */
    --text-3xl:   2.375rem;    /* 38px */
    --text-4xl:   2.9375rem;   /* 47px */
    --text-5xl:   3.6875rem;   /* 59px */
    --text-display: clamp(2.75rem, 5vw, 4.25rem);

    /* Radius */
    --radius-sm:  2px;
    --radius-md:  4px;
    --radius-lg:  8px;

    /* Transitions */
    --transition-fast:   0.12s ease;
    --transition-base:   0.2s ease;
    --transition-slow:   0.35s ease;

    /* Shadows */
    --shadow-card:   0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-gold:   0 0 24px rgba(212, 168, 83, 0.15), 0 0 48px rgba(212, 168, 83, 0.06);
    --shadow-raised: 0 4px 24px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* --- Keyframe Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes scanline {
    0%   { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

@keyframes goldShimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes pulseGold {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 83, 0); }
    50%       { box-shadow: 0 0 0 4px rgba(212, 168, 83, 0.12); }
}

@keyframes borderGlow {
    0%   { opacity: 0; }
    50%  { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes stagger-1 {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

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

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.00;
    color: var(--color-text);
    background-color: var(--color-bg);
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.018) 1px, transparent 0);
    background-size: 24px 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Noise overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.024;
    pointer-events: none;
    z-index: 0;
}

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

a {
    color: var(--color-gold);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-gold-bright);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 1.5px solid var(--color-gold);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

ul, ol {
    list-style: none;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.0;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p {
    font-family: var(--font-sans);
}

/* --- Layout --- */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 32px;
    position: relative;
    z-index: 1;
}

.container--narrow {
    max-width: 760px;
}

.site-main {
    flex: 1;
}

/* --- Section --- */
.section {
    padding: 64px 0;
    position: relative;
}

.section__title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 500;
    margin-bottom: 6px;
    letter-spacing: -0.025em;
    position: relative;
    display: inline-block;
}

/* Gold accent bar before section titles */
.section__title::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--color-gold);
    border-radius: 2px;
    opacity: 0.8;
}

.section__subtitle {
    color: var(--color-text-muted);
    margin-bottom: 40px;
    font-size: var(--text-base);
    font-family: var(--font-sans);
    font-weight: 400;
}

.section__intro {
    color: var(--color-text-muted);
    margin-bottom: 32px;
    line-height: 1.05;
    font-family: var(--font-sans);
}

.section__content p {
    color: var(--color-text-muted);
    line-height: 1.05;
    max-width: 640px;
    font-family: var(--font-sans);
}

/* Individual section modifiers */
.section--what-is {
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.section--featured {
    padding-top: 72px;
}

.section--browse {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.section--ctas {
    text-align: center;
    padding: 72px 0 80px;
}

.section--library {
    padding-top: 40px;
}

.section--form {
    padding: 48px 0 80px;
}

/* --- Hero --- */
.hero {
    padding: 88px 0 72px;
    border-bottom: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
}

/* Scanline effect */
.hero::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        rgba(212, 168, 83, 0.3) 30%,
        rgba(212, 168, 83, 0.6) 50%,
        rgba(212, 168, 83, 0.3) 70%,
        transparent
    );
    animation: scanline 8s linear infinite;
    pointer-events: none;
}

/* Hero gradient glow */
.hero::before {
    content: '';
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(212, 168, 83, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.hero__title {
    font-family: var(--font-display);
    font-size: var(--text-display);
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: -0.03em;
    line-height: 1.0;
    background: linear-gradient(135deg, #e8ecf4 0%, #c8d0e0 50%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 0.7s ease both;
}

.hero__subtitle {
    color: var(--color-text-muted);
    font-size: var(--text-lg);
    max-width: 580px;
    line-height: 1.0;
    font-family: var(--font-sans);
    font-weight: 400;
    animation: fadeInUp 0.7s 0.15s ease both;
}

/* --- Header --- */
.site-header {
    background: rgba(10, 11, 15, 0.92);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 200;
}

/* Header gold top line */
.site-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        var(--color-gold-dim),
        rgba(212, 168, 83, 0.25),
        var(--color-gold-dim),
        transparent
    );
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 130px;
}

.site-header__logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.site-header__logo:hover {
    opacity: 0.85;
}

.site-header__logo-img {
    height: 110px;
    width: auto;
    display: block;
}

.site-header__toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.site-header__toggle:hover {
    color: var(--color-text);
}

.site-header__hamburger {
    display: block;
    width: 18px;
    height: 1.5px;
    background: currentColor;
    position: relative;
    transition: background var(--transition-fast);
}

.site-header__hamburger::before,
.site-header__hamburger::after {
    content: '';
    display: block;
    width: 18px;
    height: 1.5px;
    background: currentColor;
    position: absolute;
    left: 0;
    transition: transform var(--transition-base), top var(--transition-base);
}

.site-header__hamburger::before { top: -6px; }
.site-header__hamburger::after  { top: 6px; }

.site-header__menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-header__menu a {
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 400;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
    letter-spacing: 0.005em;
}

.site-header__menu a:hover,
.site-header__menu a.is-active {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
}

.site-header__menu a.is-active {
    color: var(--color-gold);
}

/* --- Footer --- */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 40px 0 32px;
    margin-top: auto;
    position: relative;
}

.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(212, 168, 83, 0.2),
        transparent
    );
}

.site-footer__inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.site-footer__brand {
    flex: 1;
    min-width: 200px;
}

.site-footer__logo-text {
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-footer__logo-text strong {
    font-weight: 600;
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

.site-footer__tagline {
    color: var(--color-text-dim);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    margin-top: 6px;
    letter-spacing: 0.03em;
}

.site-footer__nav {
    display: flex;
    align-items: center;
}

.site-footer__menu {
    display: flex;
    gap: 20px;
    align-items: center;
}

.site-footer__menu a {
    color: var(--color-text-dim);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color var(--transition-fast);
}

.site-footer__menu a:hover {
    color: var(--color-gold);
}

.site-footer__copy {
    color: var(--color-text-dim);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    width: 100%;
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-dim);
    letter-spacing: 0.02em;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1.4;
    letter-spacing: 0.01em;
    position: relative;
    white-space: nowrap;
}

.btn--primary {
    background: var(--color-gold);
    color: #0a0b0f;
    border-color: var(--color-gold);
    font-weight: 600;
}

.btn--primary:hover {
    background: var(--color-gold-bright);
    border-color: var(--color-gold-bright);
    color: #0a0b0f;
    box-shadow: var(--shadow-gold);
    transform: translateY(-1px);
}

.btn--secondary {
    background: transparent;
    color: var(--color-gold);
    border-color: rgba(212, 168, 83, 0.35);
}

.btn--secondary:hover {
    background: var(--color-gold-dim);
    border-color: var(--color-gold);
    color: var(--color-gold-bright);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

.btn--ghost:hover {
    color: var(--color-text);
    background: var(--color-surface-alt);
    border-color: rgba(255,255,255,0.08);
}

.btn--download {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    border-color: var(--color-border);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.btn--download:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
    background: var(--color-gold-dim);
}

.btn--small {
    padding: 5px 12px;
    font-size: var(--text-xs);
}

.btn--load-more {
    margin-top: 24px;
    width: 100%;
    justify-content: center;
    border-style: dashed;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* --- Framework Grid --- */
.framework-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 32px;
}

/* Homepage featured — single row, auto-fit to count */
.framework-grid--featured {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    grid-auto-rows: 1fr;
}

/* --- No Results --- */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 64px 24px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    letter-spacing: 0.03em;
}

.no-results::before {
    content: '// ';
    color: var(--color-text-dim);
}

/* --- Browse Section --- */
.browse-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 40px;
}

.browse-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
    animation: fadeInUp 0.5s ease both;
}

.browse-card:nth-child(1) { animation-delay: 0.05s; }
.browse-card:nth-child(2) { animation-delay: 0.12s; }
.browse-card:nth-child(3) { animation-delay: 0.19s; }

.browse-card:hover {
    border-color: rgba(212, 168, 83, 0.25);
    transform: translateY(-2px);
    box-shadow: var(--shadow-raised);
}

.browse-card__title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.browse-card__desc {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-bottom: 20px;
    line-height: 1.0;
    font-family: var(--font-sans);
}

.browse-card__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* --- CTA Row --- */
.cta-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
}

.section--ctas .section__title {
    font-size: var(--text-3xl);
    margin-bottom: 12px;
}

.section--ctas .section__title::before {
    display: none;
}

.section--ctas .section__subtitle {
    margin-bottom: 32px;
    font-size: var(--text-lg);
}

/* --- Page Content (generic pages) --- */
.page-content {
    line-height: 1.05;
    font-family: var(--font-sans);
    animation: fadeIn 0.4s ease both;
}

.page-content h2 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 500;
    margin: 40px 0 14px;
    padding-left: 16px;
    border-left: 2px solid var(--color-gold);
    letter-spacing: -0.02em;
}

.page-content h3 {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    margin: 28px 0 10px;
}

.page-content p {
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

.page-content ul,
.page-content ol {
    margin: 12px 0 20px 0;
    color: var(--color-text-muted);
}

.page-content ul  { list-style: none; }
.page-content ol  { list-style: decimal; padding-left: 24px; }

.page-content ul li {
    padding-left: 16px;
    position: relative;
    margin-bottom: 8px;
}

.page-content ul li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--color-gold);
    font-family: var(--font-mono);
}

.page-content ol li {
    margin-bottom: 8px;
}

.page-content strong {
    color: var(--color-text);
    font-weight: 600;
}

.page-content a {
    color: var(--color-gold);
    text-decoration: underline;
    text-decoration-color: rgba(212, 168, 83, 0.3);
    text-underline-offset: 3px;
}

.page-content a:hover {
    text-decoration-color: var(--color-gold);
}

/* --- Legal Content --- */
.legal-content {
    font-family: var(--font-sans);
}

.legal-content h2 {
    padding-top: 32px;
    margin-top: 32px;
    border-top: 1px solid var(--color-border);
}

/* --- Submit Guidelines --- */
.submit-guidelines {
    list-style: none;
    margin: 0 0 24px;
    color: var(--color-text-muted);
    font-family: var(--font-sans);
}

.submit-guidelines li {
    padding-left: 20px;
    position: relative;
    margin-bottom: 10px;
    font-size: var(--text-sm);
    line-height: 1.05;
}

.submit-guidelines li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--color-gold);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* --- Notice --- */
.notice {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-gold);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 14px 20px;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    line-height: 1.6;
}

/* --- Utility Classes --- */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.is-loading {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}

.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* --- Stagger animation utility for grid items --- */
.framework-grid > *:nth-child(1)  { animation-delay: 0.04s; }
.framework-grid > *:nth-child(2)  { animation-delay: 0.08s; }
.framework-grid > *:nth-child(3)  { animation-delay: 0.12s; }
.framework-grid > *:nth-child(4)  { animation-delay: 0.16s; }
.framework-grid > *:nth-child(5)  { animation-delay: 0.20s; }
.framework-grid > *:nth-child(6)  { animation-delay: 0.24s; }
.framework-grid > *:nth-child(7)  { animation-delay: 0.28s; }
.framework-grid > *:nth-child(8)  { animation-delay: 0.32s; }
.framework-grid > *:nth-child(9)  { animation-delay: 0.36s; }
.framework-grid > *:nth-child(10) { animation-delay: 0.40s; }
.framework-grid > *:nth-child(11) { animation-delay: 0.44s; }
.framework-grid > *:nth-child(12) { animation-delay: 0.48s; }
