/* ============================================
   CHEEKY MEAD — DOCUMENT STYLES
   Warm, readable long-form document layout
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,500&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── RESET & VARIABLES ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #D4A843;
    --gold-bright: #E8B84B;
    --gold-light: rgba(212, 168, 67, 0.10);
    --gold-glow: rgba(232, 184, 75, 0.20);
    --charcoal: #111111;
    --cream: #FDF8F0;
    --white: #FFFFFF;
    --text: #111111;
    --text-body: #3D3936;
    --muted: #6B6B6B;
    --border: #E8E0D4;
    --sidebar-width: 280px;
    --toolbar-height: 56px;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text-body);
    background: var(--cream);
    line-height: 1.6;
    overflow-x: hidden;
    font-kerning: normal;
    font-feature-settings: 'kern' 1, 'liga' 1;
}

/* Accessibility: respect motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   LAYOUT: sidebar + main
   ============================================ */
.doc-layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.doc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--charcoal);
    letter-spacing: 2px;
    text-decoration: none;
    display: block;
    margin-bottom: 0.2rem;
}

.sidebar-subtitle {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
}

.sidebar-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    margin-top: 0.75rem;
    transition: color 0.2s;
}

.sidebar-back:hover {
    color: var(--gold);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 1rem 1.25rem 0.4rem;
}

.sidebar-nav a {
    display: block;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-body);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.sidebar-nav a:hover {
    color: var(--gold);
    background: var(--gold-light);
    border-left-color: var(--gold);
}

.sidebar-nav a:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: -2px;
    border-radius: 4px;
}

.sidebar-nav a.active {
    color: var(--gold);
    background: var(--gold-light);
    border-left-color: var(--gold);
    font-weight: 600;
}

/* ── MAIN ── */
.doc-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── TOOLBAR ── */
.doc-toolbar {
    position: sticky;
    top: 0;
    z-index: 150;
    height: var(--toolbar-height);
    background: rgba(253, 248, 240, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.toolbar-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--charcoal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--charcoal);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-download:hover {
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 2px 8px var(--gold-glow);
}

.btn-download:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* ── HAMBURGER (mobile) ── */
.doc-hamburger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 300;
    width: 40px;
    height: 40px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: border-color 0.2s;
}

.doc-hamburger:hover {
    border-color: var(--gold);
}

.doc-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--charcoal);
    border-radius: 2px;
    transition: 0.3s;
}

.doc-hamburger span + span {
    margin-top: 4px;
}

/* ── OVERLAY (mobile backdrop) ── */
.doc-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(45, 41, 38, 0.4);
    z-index: 190;
    backdrop-filter: blur(4px);
}

.doc-overlay.visible {
    display: block;
}

/* ============================================
   CONTENT TYPOGRAPHY
   ============================================ */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

/* Headings — tight spacing, McKinsey-level hierarchy */
h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    color: var(--charcoal);
    line-height: 1.12;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

h2 {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--charcoal);
    line-height: 1.18;
    margin-top: 2.75rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--gold-light);
}

h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--charcoal);
    line-height: 1.25;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
}

h4 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--charcoal);
    line-height: 1.3;
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
}

/* Body text */
p {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-body);
    margin-bottom: 1.15rem;
    orphans: 3;
    widows: 3;
}

strong {
    font-weight: 700;
    color: var(--charcoal);
}

em {
    font-style: italic;
}

/* Links */
a {
    color: var(--gold);
    text-decoration: underline;
    text-decoration-color: rgba(212, 168, 67, 0.3);
    text-underline-offset: 2.5px;
    text-decoration-thickness: 1px;
    text-decoration-skip-ink: auto;
    transition: all 0.2s;
}

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

a:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
    border-radius: 2px;
}

/* Horizontal rules */
hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 2.5rem 0;
}

/* ── LISTS ── */
ul, ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

li {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-body);
    margin-bottom: 0.45rem;
    orphans: 3;
    widows: 3;
}

li::marker {
    color: var(--gold);
}

ul ul, ol ol, ul ol, ol ul {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

/* ── BLOCKQUOTES ── */
blockquote {
    background: linear-gradient(135deg, rgba(253,248,240,0.7), rgba(212,168,67,0.06));
    border-left: 4px solid var(--gold);
    border-radius: 0 12px 12px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
}

blockquote p {
    font-size: 1rem;
    color: var(--charcoal);
    line-height: 1.7;
    margin-bottom: 0;
}

blockquote p + p {
    margin-top: 0.75rem;
}

/* ── TABLES ── */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.92rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

thead {
    background: var(--charcoal);
}

thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gold-bright);
    border-bottom: 2px solid var(--gold);
}

tbody tr {
    background: var(--white);
    transition: background 0.15s;
}

tbody tr:nth-child(even) {
    background: rgba(253, 248, 240, 0.5);
}

tbody tr:hover {
    background: var(--gold-light);
}

tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-body);
    line-height: 1.5;
}

/* ── CODE BLOCKS ── */
code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.88em;
    background: rgba(212, 168, 67, 0.08);
    color: var(--charcoal);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

pre {
    background: var(--charcoal);
    color: #E8E0D4;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.88rem;
    line-height: 1.6;
}

pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* ── KEY STAT CALLOUT ── */
.key-stat {
    background: linear-gradient(135deg, var(--white), rgba(253,248,240,0.8));
    border: 1px solid rgba(212, 168, 67, 0.2);
    border-left: 4px solid var(--gold);
    border-radius: 0 12px 12px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

.key-stat .stat-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.2;
}

.key-stat .stat-label {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* ── IMAGES ── */
img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem 0;
}

/* ── CARDS (for content sections) ── */
.doc-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    margin: 1.5rem 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.03);
}

/* ============================================
   RESPONSIVE: Sidebar collapses on mobile
   ============================================ */
@media (max-width: 900px) {
    .doc-sidebar {
        transform: translateX(-100%);
    }

    .doc-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    .doc-main {
        margin-left: 0;
    }

    .doc-hamburger {
        display: flex;
    }

    .doc-toolbar {
        padding-left: 3.5rem;
    }

    .container {
        padding: 2rem 1.25rem 4rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    table {
        font-size: 0.82rem;
    }

    thead th, tbody td {
        padding: 0.5rem 0.7rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1.5rem 1rem 3rem;
    }

    p, li {
        font-size: 0.95rem;
    }

    .toolbar-title {
        font-size: 0.82rem;
    }
}

/* ---- EXECUTIVE CALLOUT BOXES ---- */
.executive-callout {
    background: linear-gradient(135deg, #FDF8F0, rgba(212, 168, 67, 0.04));
    border-left: 4px solid #D4A843;
    padding: 1.25rem 1.75rem;
    margin: 1.75rem 0;
    margin-left: -0.15rem;
    border-radius: 0 10px 10px 0;
    box-shadow: 0 1px 6px rgba(212, 168, 67, 0.08);
}
.executive-callout .callout-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #D4A843;
    margin-bottom: 0.4rem;
}
.executive-callout p {
    font-size: 1.02rem;
    line-height: 1.65;
    color: #111111;
    margin: 0;
    font-weight: 500;
}

/* ---- DROP CAP — opening paragraphs of major sections ---- */
.drop-cap::first-letter {
    font-family: 'Playfair Display', Georgia, serif;
    float: left;
    font-size: 3.8rem;
    line-height: 0.78;
    font-weight: 700;
    color: #D4A843;
    margin: 0.06em 0.12em 0 0;
    padding: 0;
}

/* ---- PREMIUM CONSULTING COMPONENTS ---- */

.pull-quote {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-style: italic;
    color: #D4A843;
    border-left: 4px solid #D4A843;
    padding: 1.25rem 1.75rem 1.25rem 2.5rem;
    margin: 2rem 0 2rem -0.2rem;
    background: linear-gradient(135deg, rgba(212, 168, 67, 0.05), rgba(232, 184, 75, 0.02));
    border-radius: 0 10px 10px 0;
    line-height: 1.45;
    position: relative;
}
.pull-quote::before {
    content: '\201C';
    font-size: 4.5rem;
    color: rgba(212, 168, 67, 0.22);
    position: absolute;
    top: -0.3rem;
    left: 0.35rem;
    font-family: 'Playfair Display', serif;
    line-height: 1;
}

.key-insight {
    background: linear-gradient(135deg, #111111, #3D3936);
    color: #FDF8F0;
    padding: 1.75rem 2rem;
    border-radius: 12px;
    margin: 2rem 0 2rem -0.1rem;
    border-left: 4px solid #D4A843;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}
.key-insight::before {
    content: 'KEY INSIGHT';
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: #D4A843;
    margin-bottom: 0.6rem;
}
.key-insight p { color: #FDF8F0; margin: 0; font-size: 1.02rem; line-height: 1.7; }

.stat-callout {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    margin: 2rem 0;
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.stat-callout .stat-number {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: #D4A843;
    white-space: nowrap;
    line-height: 1;
}
.stat-callout .stat-label { font-size: 1.05rem; color: #6B6B6B; line-height: 1.5; }

.framework-box {
    border: 2px solid #D4A843;
    border-radius: 12px;
    padding: 2rem;
    margin: 2.5rem 0;
    background: rgba(212, 168, 67, 0.03);
}
.framework-box h4 {
    font-family: 'Playfair Display', serif;
    color: #111111;
    font-size: 1.3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(212, 168, 67, 0.3);
}

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #D4A843, #E8B84B);
    z-index: 10000;
    box-shadow: 0 0 8px rgba(212, 168, 67, 0.35);
    transition: width 0.1s linear;
}

.section-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #D4A843, #E8B84B);
    margin: 3rem auto;
    border-radius: 2px;
}

@media (max-width: 768px) {
    .pull-quote { font-size: 1.2rem; padding: 1rem 1.5rem; }
    .stat-callout { flex-direction: column; text-align: center; gap: 0.75rem; }
/* ============================================
   PRINT / PDF — Premium consulting output
   Chrome Print > Save as PDF optimized
   Page numbers, headers, footers (Chrome 131+)
   ============================================ */
@media print {
    /* ── Page setup with margin boxes ── */
    @page {
        size: letter;
        margin: 1in 0.9in 0.85in 0.9in;
        @top-right {
            content: "CONFIDENTIAL";
            font-family: 'DM Sans', sans-serif;
            font-size: 7pt;
            color: #ccc;
            letter-spacing: 0.15em;
            text-transform: uppercase;
        }
        @bottom-left {
            content: "Genesis Strategic Intelligence  ·  Day 7 PBC";
            font-family: 'DM Sans', sans-serif;
            font-size: 7pt;
            color: #bbb;
        }
        @bottom-right {
            content: counter(page);
            font-family: 'Playfair Display', serif;
            font-size: 9pt;
            font-weight: 600;
            color: #999;
        }
    }
    @page :first {
        margin: 0;
        @top-right { content: none; }
        @bottom-left { content: none; }
        @bottom-right { content: none; }
    }

    /* ── Global color preservation ── */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ── Hide non-print elements ── */
    .doc-sidebar, .doc-toolbar, .doc-hamburger, .doc-overlay,
    .reading-progress, .btn-download, .toolbar-actions, .sidebar-back {
        display: none !important;
    }

    /* ── Full-width layout ── */
    .doc-layout { display: block !important; }
    .doc-main { margin-left: 0 !important; width: 100% !important; }
    .container { max-width: 100% !important; padding: 0 !important; margin: 0 auto !important; }

    /* ── Premium typography ── */
    body { background: white !important; color: #1a1a1a !important; font-size: 11pt; line-height: 1.45; }
    h1 { font-size: 24pt; line-height: 1.12; letter-spacing: -0.01em; }
    h2 { font-size: 18pt; line-height: 1.2; border-bottom-color: #ddd; margin-top: 24pt; margin-bottom: 10pt; break-before: page; page-break-before: always; break-after: avoid; page-break-after: avoid; }
    h3 { font-size: 13pt; line-height: 1.3; margin-top: 16pt; break-after: avoid; page-break-after: avoid; }
    h4 { font-size: 11pt; break-after: avoid; page-break-after: avoid; }

    /* First h2 — no blank page after cover */
    h2:first-of-type,
    .container > h2:first-of-type,
    .vol-cover ~ .container h2:first-of-type,
    .cover-page ~ .container h2:first-of-type {
        break-before: auto !important;
        page-break-before: auto !important;
    }

    /* Justified body text */
    p { text-align: justify; -webkit-hyphens: auto; hyphens: auto; margin-bottom: 7pt; }
    p, li, dd, dt { orphans: 3; widows: 3; }

    /* ── Links ── */
    a { color: #1a1a1a !important; text-decoration: none !important; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.72em; color: #888; word-break: break-all; }
    .sidebar-nav a::after, .volume-card::after, a.volume-card::after,
    a[href^="#"]::after, a[href$=".html"]::after { content: none !important; }

    /* ── Cover pages ── */
    .vol-cover, .cover-page { break-after: page; page-break-after: always; min-height: auto !important; padding: 3rem 2rem !important; background: white !important; }
    .vol-cover::before, .vol-cover::after, .cover-page::before, .cover-page::after { display: none !important; }

    /* ── Content blocks — keep together ── */
    blockquote, figure, .key-insight, .pull-quote, .framework-box,
    .stat-callout, .stat-callout-mini, .executive-callout, .key-stat,
    .doc-card, .principle-card, .method-card, .volume-card,
    .scenario-card, .okr-card, .persona-card, .tier-card,
    .clv-hero-card, .v2mom-tier, .revelation-block, .opening-note {
        break-inside: avoid; page-break-inside: avoid; box-shadow: none !important;
    }

    /* Kill hover artifacts */
    *:hover { transform: none !important; box-shadow: none !important; }
    tbody tr:hover { background: inherit !important; }

    /* ── Tables — repeating headers ── */
    table { box-shadow: none !important; break-inside: auto; page-break-inside: auto; font-size: 9pt; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
    tr { break-inside: avoid; page-break-inside: avoid; }
    table, thead, tbody, tr, th, td { min-width: 0 !important; }

    /* ── Code blocks ── */
    pre { background: #f5f5f5 !important; color: #333 !important; border: 1px solid #ddd; break-inside: avoid; page-break-inside: avoid; }

    /* ── SVG diagrams ── */
    svg { max-width: 100% !important; height: auto !important; break-inside: avoid; page-break-inside: avoid; }
    .diagram-wrap, .svg-visual, .diagram-container, .flywheel-wrap, .flywheel-container,
    .chart-container, .risk-matrix-container, .gantt-container { break-inside: avoid; page-break-inside: avoid; box-shadow: none !important; }

    /* ── Images ── */
    img { max-width: 100% !important; break-inside: avoid; page-break-inside: avoid; }

    /* ── Page flow ── */
    .colophon-block { break-before: page; page-break-before: always; }
    .letter-section { break-after: page; page-break-after: always; }

    /* ── Composite sections — keep whole ── */
    .reading-flow, .volume-cards, .stat-row, .principle-grid, .method-cards,
    .price-ladder, .tier-progression, .clv-hero-grid, .persona-grid,
    .okr-quarter, .v2mom-cascade, .errc-grid, .tiers-visual { break-inside: avoid; page-break-inside: avoid; }

    /* Financial tables CAN span pages */
    .pl-table { break-inside: auto; page-break-inside: auto; }

    .doc-footer { break-before: auto; margin-top: 24pt; }
}
