/* ================================================================
   SHARED BASE STYLES — 51 Insights
   Variables, reset, typography, buttons, nav, footer, sections
   ================================================================ */

:root {
    --bg: #000000;
    --surface: #0a0a0a;
    --elevated: #111111;
    --elevated-2: #171717;
    --elevated-3: #1c1c1c;

    --border-faint: rgba(255,255,255,0.04);
    --border-subtle: rgba(255,255,255,0.07);
    --border-default: rgba(255,255,255,0.12);
    --border-strong: rgba(255,255,255,0.20);

    --text-primary: #ededed;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --text-faint: #444444;

    --brand: #0A06E5;
    --brand-light: #58C7F7;
    --brand-green: #98EA65;
    --brand-red: #ff6b6b;
    --brand-glow: rgba(10,6,229,0.15);

    --page-width: 1200px;
    --page-gutter: 24px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 100px;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-snappy: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================================================================
   LIGHT MODE
   ================================================================ */
[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f7f7f9;
    --elevated: #efeff2;
    --elevated-2: #e6e6eb;
    --elevated-3: #dddde3;

    --border-faint: rgba(0,0,0,0.04);
    --border-subtle: rgba(0,0,0,0.07);
    --border-default: rgba(0,0,0,0.12);
    --border-strong: rgba(0,0,0,0.22);

    --text-primary: #111111;
    --text-secondary: #4a4a4a;
    --text-muted: #7a7a7a;
    --text-faint: #aaaaaa;

    --brand: #0A06E5;
    --brand-light: #2563eb;
    --brand-green: #16a34a;
    --brand-red: #dc2626;
    --brand-glow: rgba(10,6,229,0.08);
}
[data-theme="light"] .nav {
    background: rgba(255,255,255,0.85);
    border-bottom-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .btn-primary { background: #111; color: #fff; }
[data-theme="light"] .btn-primary:hover { background: #222; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
[data-theme="light"] .btn-brand { background: linear-gradient(135deg, #0A06E5, #3a35ff); color: #fff; }
[data-theme="light"] .btn-secondary { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
[data-theme="light"] .btn-secondary:hover { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25); background: rgba(0,0,0,0.02); }
[data-theme="light"] .nav-link-badge { background: rgba(22,163,74,0.1); color: #16a34a; }
[data-theme="light"] .mobile-menu { background: rgba(255,255,255,0.97); }
[data-theme="light"] .mobile-menu a { color: var(--text-secondary); }
[data-theme="light"] .mobile-menu a:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }

/* Theme toggle */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%; border: none;
    background: transparent; color: var(--text-muted); cursor: pointer;
    transition: all 0.2s var(--ease-out); margin-right: 4px;
}
.theme-toggle:hover { color: var(--text-primary); background: rgba(128,128,128,0.1); }
.theme-toggle svg { width: 18px; height: 18px; transition: transform 0.3s var(--ease-out); }
.theme-toggle:hover svg { transform: rotate(15deg); }
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* Smooth theme transition */
html[data-theme] body, html[data-theme] .nav,
html[data-theme] .mobile-menu, html[data-theme] .site-footer,
html[data-theme] .btn-primary, html[data-theme] .btn-secondary, html[data-theme] .btn-brand {
    transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ================================================================
   RESET
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -webkit-overflow-scrolling: touch; }

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.55;
    overflow-x: hidden;
    animation: pageIn 0.4s ease-out;
}
@keyframes pageIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
    font-family: 'Sora', sans-serif;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    line-height: 1.08;
    font-weight: 600;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

.container {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 var(--page-gutter);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s var(--ease-out);
    white-space: nowrap;
}
.btn-lg {
    height: 48px;
    padding: 0 28px;
    font-size: 15px;
    border-radius: var(--radius-pill);
}
.btn-md {
    height: 40px;
    padding: 0 20px;
    font-size: 14px;
    border-radius: var(--radius-pill);
}
.btn-sm {
    height: 34px;
    padding: 0 16px;
    font-size: 13px;
    border-radius: var(--radius-pill);
}
.btn-primary {
    background: #fff;
    color: #000;
}
.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255,255,255,0.1);
}
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border-default);
}
.btn-secondary:hover {
    box-shadow: inset 0 0 0 1px var(--border-strong);
    background: rgba(255,255,255,0.03);
}
.btn-brand {
    background: linear-gradient(135deg, var(--brand), #3a35ff);
    color: #fff;
}
.btn-brand:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 24px rgba(10,6,229,0.4);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0;
    height: auto;
}
.btn-ghost:hover { color: var(--text-primary); }

.btn svg { width: 16px; height: 16px; }
.btn-icon-right { transition: transform 0.2s var(--ease-out); }
.btn:hover .btn-icon-right { transform: translateX(2px); }

/* ================================================================
   NAVIGATION
   ================================================================ */
.nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: 56px;
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-faint);
}
.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 var(--page-gutter);
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 32px;
}
.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Sora', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.nav-logo-mark {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
}
.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border-default);
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-link {
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s var(--ease-out);
}
.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}
.nav-link--active {
    color: var(--text-primary);
}
.nav-link-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    background: rgba(152,234,101,0.12);
    color: var(--brand-green);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 4px;
}
.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-right-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 16px;
}
.nav-mobile-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

@media (max-width: 900px) {
    .nav-links { display: none; }
    .nav-divider { display: none; }
    .nav-right-links { display: none; }
    .nav-actions .btn:first-child { display: none; }
    .nav-mobile-btn { display: block; }
}

/* Mobile menu */
.mobile-menu {
    display: none;
    position: fixed;
    top: 56px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(20px);
    z-index: 99;
    padding: 24px;
}
.mobile-menu.is-open { display: flex; flex-direction: column; gap: 4px; }
.mobile-menu a {
    display: block;
    padding: 14px 16px;
    color: var(--text-secondary);
    font-size: 16px;
    border-radius: var(--radius-md);
    transition: background 0.2s var(--ease-out);
}
.mobile-menu a:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

/* ================================================================
   SECTION SYSTEM
   ================================================================ */
.section { position: relative; z-index: 2; }
.section-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
}
.section-heading {
    font-size: clamp(28px, 3.5vw, 44px);
    margin-bottom: 16px;
}
.section-desc {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 480px;
    line-height: 1.6;
}

/* ================================================================
   FOOTER
   ================================================================ */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 48px 0;
    z-index: 2;
    position: relative;
}
[data-theme="light"] .site-footer {
    transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 48px;
    margin-bottom: 40px;
}
.footer-brand {
    font-family: 'Sora', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.footer-brand-mark {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
    color: #fff;
}
.nav-logo-img {
    height: 26px;
    width: auto;
    object-fit: contain;
}
.footer-brand-img {
    height: 20px;
    width: auto;
    object-fit: contain;
}
.footer-desc {
    font-size: 13px;
    color: var(--text-faint);
    line-height: 1.6;
}
.footer-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
}
.footer-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.footer-link {
    font-size: 13px;
    color: var(--text-faint);
    transition: color 0.2s var(--ease-out);
}
.footer-link:hover { color: var(--text-primary); }

.footer-social {
    display: flex;
    gap: 12px;
}
.footer-social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-faint);
    background: var(--elevated);
    box-shadow: inset 0 0 0 1px var(--border-subtle);
    transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.footer-social-link:hover {
    color: var(--text-primary);
    background: var(--elevated-2);
    box-shadow: inset 0 0 0 1px var(--border-default);
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 24px;
    border-top: 1px solid var(--border-faint);
}
.footer-copy {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text-faint);
}

@media (max-width: 768px) {
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
    .footer-bottom { flex-direction: column; gap: 12px; align-items: flex-start; }
}

/* ================================================================
   DIVIDERS & ANIMATIONS
   ================================================================ */
.divider {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    height: 1px;
    background: var(--border-subtle);
}

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

/* Reveal — only activate after JS loads to prevent blank page flash */
.js-ready .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.js-ready .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.js-ready .reveal-d1 { transition-delay: 0.1s; }
.js-ready .reveal-d2 { transition-delay: 0.2s; }
.js-ready .reveal-d3 { transition-delay: 0.3s; }

/* ================================================================
   SHARED MOBILE
   ================================================================ */
@media (max-width: 900px) {
    html { overflow-x: hidden; -webkit-overflow-scrolling: touch; }
    body { overflow-x: hidden; }
    .btn, a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
    .mobile-menu { padding: 16px 20px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); flex-direction: column; gap: 2px; transition: opacity .3s var(--ease-out), transform .3s var(--ease-out); overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .mobile-menu.is-open { display: flex; animation: mobileMenuIn .3s var(--ease-out) forwards; }
    @keyframes mobileMenuIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
    .mobile-menu a { padding: 16px; font-size: 17px; font-weight: 500; min-height: 52px; display: flex; align-items: center; border-bottom: 1px solid var(--border-faint); }
    .mobile-menu a:last-child { border-bottom: none; margin-top: 8px; justify-content: center; background: rgba(10,6,229,.1); border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px rgba(10,6,229,.25); }
    .nav-mobile-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; padding: 0; border-radius: var(--radius-sm); }
    .nav-mobile-btn svg { width: 22px; height: 22px; }
    .nav-mobile-btn.is-active svg path:nth-child(1) { d: path("M6 6l12 12"); }
    .nav-mobile-btn.is-active svg path:nth-child(2) { opacity: 0; }
    .nav-mobile-btn.is-active svg path:nth-child(3) { d: path("M6 18L18 6"); }
    .nav-mobile-btn svg path { transition: all .25s var(--ease-out); }
    .section-heading { font-size: clamp(24px, 6vw, 44px); }
    .section-desc { font-size: 15px; }
    .site-footer { padding: 36px 0; padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px)); }
    .footer-grid { gap: 28px; margin-bottom: 28px; }
    .footer-link { min-height: 44px; display: flex; align-items: center; }
    .footer-social-link { min-width: 44px; min-height: 44px; }
}
@media (max-width: 480px) {
    :root { --page-gutter: 20px; }
    .section-heading { font-size: clamp(22px, 5.5vw, 36px); }
    .site-footer { padding: 28px 0; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
    .footer-grid > div:first-child { grid-column: span 2; }
    .footer-desc { font-size: 12px; margin-bottom: 0; }
    .footer-heading { margin-bottom: 10px; font-size: 10px; }
    .footer-links { gap: 6px; }
    .footer-link { min-height: 0; font-size: 12px; }
    .footer-social-link { min-width: 36px; min-height: 36px; width: 36px; height: 36px; }
    .footer-bottom { flex-direction: column; gap: 8px; align-items: center; text-align: center; padding-top: 16px; }
}
@media (max-width: 375px) {
    :root { --page-gutter: 16px; }
}
@media (max-width: 320px) {
    :root { --page-gutter: 12px; }
    .nav-logo span { font-size: 12px; }
}
