/* =====================================================================
   Fundwise Legal — shared design tokens & components
   Editorial system mirroring Scalar Law's sister-brand structure.
   ===================================================================== */

:root {
    /* — Palette ——————————————————————————————————————————————— */
    --terracotta: #d96b3f;        /* terracotta accent */
    --terracotta-dark: #b15528;
    --terracotta-tint: #f0b896;
    --fw-green: #1a2421;        /* Fundwise brand mark color */
    --fw-green-soft: #243029;
    --ink: #1A1A1A;
    --ink-soft: #2D2D2D;
    --navy: #264653;        /* Fundwise existing deep teal-navy */
    --cream: #EAE5DA;
    --cream-deep: #DDD6C4;
    --paper: #F4F0E6;
    --line: #1A1A1A;
    --line-soft: rgba(26,26,26,0.18);
    --line-faint: rgba(26,26,26,0.10);
    --muted: #6B6660;
    --muted-2: #8C867E;

    --bg: var(--cream);
    --fg: var(--ink);
    --accent: var(--terracotta);

    /* — Type ————————————————————————————————————————————————— */
    --serif: 'Newsreader', 'Cambria', 'Iowan Old Style', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;

    --fs-mono: 11px;
    --fs-eyebrow: 11px;
    --fs-body: 16px;
    --fs-lede: 19px;
    --fs-h3: clamp(1.25rem, 1.6vw, 1.5rem);
    --fs-h2: clamp(2rem, 4.2vw, 3.6rem);
    --fs-h1: clamp(2.6rem, 7vw, 6rem);
    --fs-display: clamp(3rem, 9vw, 8.5rem);

    /* — Layout ——————————————————————————————————————————————— */
    --gutter: clamp(20px, 4vw, 56px);
    --rail: 64px;            /* left section index rail on desktop */
    --section-py: clamp(80px, 11vw, 160px);
    --max: 1360px;

    /* — Motion ——————————————————————————————————————————————— */
    --ease: cubic-bezier(0.4, 0, 0.1, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    font-size: var(--fs-body);
    line-height: 1.55;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    font-feature-settings: "ss01", "cv11";
}

/* Subtle paper grain across whole site */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.035;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

::selection { background: var(--terracotta); color: #fff; }

/* — Typography utilities ——————————————————————————————————————— */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.012em; }
.mono  { font-family: var(--mono); font-weight: 400; }

.eyebrow {
    font-family: var(--mono);
    font-size: var(--fs-eyebrow);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
    font-weight: 500;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.018em; line-height: 1.05; text-wrap: balance; }
h2 { font-size: var(--fs-h2); line-height: 1.02; }
h3 { font-size: var(--fs-h3); line-height: 1.18; letter-spacing: -0.01em; }

p { text-wrap: pretty; }

/* — Page chrome (top bar) ——————————————————————————————————————— */
.chrome {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px var(--gutter);
    mix-blend-mode: normal;
    transition: background .35s var(--ease), border-color .35s var(--ease);
    border-bottom: 1px solid transparent;
}
.chrome.scrolled {
    background: color-mix(in oklab, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom-color: var(--line-faint);
}
.chrome--dark { color: #F4F0E6; }
.chrome--dark.scrolled {
    background: color-mix(in oklab, var(--ink) 88%, transparent);
    border-bottom-color: rgba(255,255,255,0.08);
}

.brand {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.brand__mark {
    width: 28px; height: 28px; border-radius: 6px;
    background: var(--fw-green);
    color: #fff; display: grid; place-items: center;
    font-family: var(--sans); font-weight: 600; font-size: 11px;
    letter-spacing: 0;
}
.brand__name { font-weight: 500; letter-spacing: 0.22em; }
.brand__name em { font-style: normal; opacity: .55; font-weight: 400; margin-left: 2px;}

.nav {
    display: flex; gap: 28px; align-items: center;
    font-family: var(--mono);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.nav a {
    position: relative;
    padding: 6px 0;
    white-space: nowrap;
    transition: color .2s var(--ease);
}
.nav a .num { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.chrome--dark .nav a .num { color: rgba(255,255,255,0.5); }
.nav a:hover { color: var(--terracotta); }
.nav a.active::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -2px;
    height: 1px; background: currentColor;
}
.nav__cta {
    padding: 9px 14px;
    border: 1px solid currentColor;
    white-space: nowrap;
    border-radius: 999px;
    transition: background .25s var(--ease), color .25s var(--ease);
}
.nav__cta:hover { background: var(--terracotta); border-color: var(--terracotta); color: #fff !important; }

.menu-toggle { display: none; }

.mobile-menu {
    position: fixed; inset: 0; z-index: 40;
    background: var(--bg); padding: 80px var(--gutter) 40px;
    display: flex; flex-direction: column; gap: 8px;
    transform: translateY(-100%);
    visibility: hidden;
    transition: transform .4s var(--ease), visibility .4s var(--ease);
}
.mobile-menu.open { transform: translateY(0); visibility: visible; }
.mobile-menu a { font-family: var(--serif); font-size: clamp(2rem, 8vw, 3rem); padding: 6px 0; border-bottom: 1px solid var(--line-faint); }
.mobile-menu a .num { font-family: var(--mono); font-size: 12px; vertical-align: super; opacity: .5; margin-right: 10px; }

@media (max-width: 880px) {
    .nav { display: none; }
    .menu-toggle {
        display: inline-flex; flex-direction: column; gap: 4px;
        padding: 10px;
    }
    .menu-toggle span { display:block; width:22px; height:1px; background: currentColor; transition: transform .3s var(--ease), opacity .3s var(--ease); }
    .menu-toggle.open span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
    .menu-toggle.open span:nth-child(2) { opacity: 0; }
    .menu-toggle.open span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }
}

/* — Page section scaffold ————————————————————————————————————— */
.page { position: relative; }
.page > main { position: relative; z-index: 2; }

.section {
    position: relative;
    padding: var(--section-py) var(--gutter);
}
.section__inner { max-width: var(--max); margin: 0 auto; position: relative; }

/* Section number rail (top-left of each section) */
.section__index {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--mono);
    font-size: var(--fs-mono);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 56px;
}
.section__index .bar { flex: 1; height: 1px; background: var(--line-soft); max-width: 280px; }
.section--dark .section__index { color: rgba(255,255,255,0.55); }
.section--dark .section__index .bar { background: rgba(255,255,255,0.16); }

.section--dark { background: var(--ink); color: var(--paper); }
.section--navy { background: var(--navy); color: var(--paper); }
.section--paper { background: var(--paper); }

/* — Buttons / links ————————————————————————————————————————————— */
.btn {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 16px 28px;
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    transition: transform .25s var(--ease), background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
    border: 1px solid transparent;
}
.btn .arrow { transition: transform .25s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn--primary { background: var(--terracotta); color: #fff; }
.btn--primary:hover { background: var(--ink); }
.btn--ghost { border-color: currentColor; }
.btn--ghost:hover { background: currentColor; color: var(--bg); }
.section--dark .btn--ghost:hover, .section--navy .btn--ghost:hover { color: var(--ink); }

.link-arrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    border-bottom: 1px solid currentColor;
    padding-bottom: 4px;
    transition: gap .2s var(--ease), color .2s var(--ease);
}
.link-arrow:hover { gap: 14px; color: var(--terracotta); }

/* — Reveal animation ——————————————————————————————————————————— */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal--slow { transition-duration: 1.4s; }
.reveal[data-d="1"] { transition-delay: .08s; }
.reveal[data-d="2"] { transition-delay: .16s; }
.reveal[data-d="3"] { transition-delay: .24s; }
.reveal[data-d="4"] { transition-delay: .32s; }
.reveal[data-d="5"] { transition-delay: .4s; }

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
}

/* — Footer (shared) ————————————————————————————————————————————— */
.foot {
    background: var(--ink);
    color: var(--paper);
    padding: 100px var(--gutter) 36px;
    position: relative;
    z-index: 2;
}
.foot__inner { max-width: var(--max); margin: 0 auto; }
.foot__top {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 60px;
    padding-bottom: 80px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.foot__big {
    font-family: var(--serif);
    font-size: clamp(2rem, 4.5vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -0.018em;
    margin-bottom: 28px;
}
.foot__big a { border-bottom: 1px solid rgba(255,255,255,0.25); padding-bottom: 4px; }
.foot__big a:hover { color: var(--terracotta-tint); border-color: var(--terracotta-tint); }
.foot__col h4 {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-bottom: 18px;
    font-weight: 500;
}
.foot__col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.foot__col a { color: rgba(255,255,255,0.78); transition: color .2s; }
.foot__col a:hover { color: #fff; }

.foot__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 36px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
}
.foot__bottom a { color: rgba(255,255,255,0.65); }
.foot__bottom a:hover { color: #fff; }
.foot__sister { display: flex; align-items: center; gap: 10px; }
.foot__sister a { color: var(--terracotta-tint); border-bottom: 1px solid rgba(226,184,158,0.4); padding-bottom: 2px; }

/* Big monogram in footer */
.foot__monogram {
    font-family: var(--serif);
    font-size: clamp(7rem, 24vw, 22rem);
    line-height: 0.85;
    letter-spacing: -0.04em;
    color: rgba(255,255,255,0.04);
    margin-top: -40px;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
}

@media (max-width: 880px) {
    .foot__top { grid-template-columns: 1fr 1fr; gap: 40px; padding-bottom: 50px; }
    .foot__big { grid-column: 1 / -1; }
    .foot__bottom { flex-direction: column; gap: 14px; align-items: flex-start; }
}

/* — Disclaimer banner (used on Reg pages) ————————————————————— */
.disclaimer {
    background: var(--ink);
    color: rgba(244,240,230,0.7);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    padding: 12px var(--gutter);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.disclaimer a { color: var(--terracotta-tint); border-bottom: 1px solid rgba(226,184,158,0.4); }

/* — Tweaks panel hooks ————————————————————————————————————————— */
body[data-density="cozy"] { --section-py: clamp(60px, 8vw, 120px); --fs-h1: clamp(2.4rem, 6vw, 5rem); }
body[data-density="airy"] { --section-py: clamp(120px, 14vw, 220px); }

body[data-accent="ink"]    { --accent: var(--ink); --terracotta: #1A1A1A; --terracotta-dark: #000; }
body[data-accent="sage"]   { --accent: #6B7F6A; --terracotta: #6B7F6A; --terracotta-dark: #54664E; --terracotta-tint: #B5C2A8; }
body[data-accent="cobalt"] { --accent: #2B4A8C; --terracotta: #2B4A8C; --terracotta-dark: #1F3768; --terracotta-tint: #A8B6D2; }
/* default = terracotta */

body[data-display="sans"] { --serif: 'Inter', sans-serif; }
body[data-display="sans"] h1, body[data-display="sans"] h2, body[data-display="sans"] h3, body[data-display="sans"] h4 { font-weight: 500; letter-spacing: -0.025em; }

