/* ============================================================
   layer-2.report: Editorial Design System
   ============================================================ */

/* ============================================================
   CSS Custom Properties (Color Palette)
   ============================================================ */
:root {
    /* Monochrome ink palette */
    --color-ink: #0A0A0A;
    --color-text: #1C1C1E;
    --color-secondary: #5A5A5E;
    --color-tertiary: #8E8E93;
    --color-hairline: #C7C7CC;
    --color-paper: #F5F3EF;
    --color-bright-paper: #FAFAF7;
    --color-signal-red: #C41E1E;

    /* Typography */
    --font-body: "Cormorant Garamond", serif;
    --font-display: "Space Grotesk", sans-serif;
    --font-mono: "IBM Plex Mono", monospace;

    /* Layout */
    --content-width: 680px;
    --gutter-width: 200px;
    --baseline: 28px;

    /* Timing */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============================================================
   Global Styles & Resets
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-paper);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    position: relative;
}

/* Noise texture SVG background overlay */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="4" seed="2" /></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.04"/></svg>');
    background-size: 200px 200px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
}

/* Grid-line underlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(var(--baseline) - 1px),
        var(--color-hairline) calc(var(--baseline) - 1px),
        var(--color-hairline) var(--baseline)
    );
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
}

.page-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100vh;
}

/* ============================================================
   Reading Progress Indicator
   ============================================================ */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background-color: var(--color-ink);
    width: 0%;
    z-index: 1000;
    transition: width 0.1s linear;
}

/* ============================================================
   Masthead Section
   ============================================================ */
.masthead {
    width: 100%;
    height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: var(--color-paper);
    position: relative;
    overflow: hidden;
}

.masthead::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise2"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="4" seed="3" /></filter><rect width="100" height="100" filter="url(%23noise2)" opacity="0.08"/></svg>');
    background-size: 200px 200px;
    opacity: 0.08;
    pointer-events: none;
}

.masthead-domain {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-ink);
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
}

.masthead-rule-heavy {
    width: var(--content-width);
    max-width: 90%;
    height: 3px;
    background-color: var(--color-ink);
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
}

.masthead-dateline {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    color: var(--color-secondary);
    margin-bottom: 3rem;
    position: relative;
    z-index: 2;
    font-style: italic;
}

.masthead-title {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 6vw, 4.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.08;
    color: var(--color-ink);
    text-align: center;
    max-width: 90%;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(12px);
}

/* ============================================================
   Content Sections
   ============================================================ */
.content-section {
    width: 100%;
    max-width: var(--content-width);
    padding: 4rem 2rem;
    margin: 0 auto;
    position: relative;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
}

.content-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Ghost section numbers */
.section-ghost-number {
    position: absolute;
    left: -120px;
    top: 4rem;
    font-family: var(--font-display);
    font-size: 180px;
    font-weight: 700;
    color: var(--color-ink);
    opacity: 0.06;
    line-height: 1;
    pointer-events: none;
}

@media (max-width: 1200px) {
    .section-ghost-number {
        display: none;
    }
}

/* Headings */
h2 {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text);
    margin-bottom: 1.5rem;
    margin-top: 0;
}

h3 {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--color-text);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* Paragraph styles */
p {
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

p:last-child {
    margin-bottom: 0;
}

/* Emphasis styles */
.emphasis-strong {
    font-weight: 600;
}

em,
i {
    font-style: italic;
}

strong {
    font-weight: 600;
}

/* Section rules */
.section-rule-medium {
    height: 1.5px;
    background-color: var(--color-text);
    margin: 2.5rem 0;
    opacity: 0.8;
}

.colophon-rule-heavy {
    height: 3px;
    background-color: var(--color-ink);
    margin-bottom: 2rem;
}

/* Hairline rules (between paragraphs) */
.section-rule-hairline {
    height: 0.5px;
    background-color: var(--color-tertiary);
    margin: 2rem 0;
    opacity: 0.6;
}

/* ============================================================
   Diagram Styling
   ============================================================ */
.diagram-container {
    margin: 3rem 0;
    padding: 2rem 0;
}

.diagram {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 1rem;
}

.diagram-path {
    animation: drawPath 1200ms var(--ease-out) forwards;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.diagram-label {
    opacity: 0;
    animation: fadeIn 400ms var(--ease-out) 1000ms forwards;
}

@keyframes drawPath {
    from {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dasharray: 1000;
        stroke-dashoffset: 0;
    }
}

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

.diagram-caption {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-secondary);
    line-height: 1.6;
    margin-top: 1rem;
    font-style: italic;
}

/* ============================================================
   Callout Boxes
   ============================================================ */
.callout-box {
    margin: 2.5rem 0;
    padding: 1.5rem 1.5rem 1.5rem 2.5rem;
    background-color: var(--color-bright-paper);
    border-left: 3px solid var(--color-signal-red);
    position: relative;
}

.callout-marker {
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    font-family: var(--font-body);
    font-size: 1.3rem;
    color: var(--color-secondary);
}

.callout-box p {
    margin-bottom: 0;
    font-size: 0.95em;
    color: var(--color-secondary);
}

/* ============================================================
   Footnote Gutter (Responsive)
   ============================================================ */
@media (min-width: 1200px) {
    .content-section {
        display: grid;
        grid-template-columns: var(--content-width) var(--gutter-width);
        gap: 2rem;
        align-items: start;
    }

    .section-ghost-number {
        grid-column: 1;
    }

    .gutter-content {
        grid-column: 2;
        font-family: var(--font-mono);
        font-size: 0.82rem;
        color: var(--color-secondary);
        line-height: 1.6;
    }
}

/* ============================================================
   Colophon / Footer
   ============================================================ */
.colophon {
    width: 100%;
    max-width: var(--content-width);
    padding: 4rem 2rem;
    margin: 2rem auto;
    text-align: center;
}

.colophon-text {
    font-size: 0.95rem;
    color: var(--color-secondary);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.colophon-attribution {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-tertiary);
    letter-spacing: 0.05em;
}

.ornament {
    margin: 0 0.5rem;
    font-style: italic;
    color: var(--color-secondary);
}

/* ============================================================
   Animations & Interactions
   ============================================================ */

/* Ripple effect from section boundary */
@keyframes ripple {
    0% {
        opacity: 0.03;
    }
    50% {
        opacity: 0.15;
    }
    100% {
        opacity: 0.03;
    }
}

@keyframes rippleWave {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(200px);
    }
}

/* Ink drop ripple on footnote click */
@keyframes inkRipple {
    0% {
        r: 0;
        opacity: 1;
    }
    100% {
        r: 60px;
        opacity: 0;
    }
}

/* Hover effects on interactive elements */
a {
    color: var(--color-text);
    text-decoration: underline;
    cursor: pointer;
    transition: color 200ms ease;
}

a:hover {
    color: var(--color-ink);
}

/* Focus styles (minimal, invisible) */
a:focus {
    outline: none;
}

/* ============================================================
   Responsive Design
   ============================================================ */
@media (max-width: 768px) {
    .masthead {
        height: 60vh;
    }

    .masthead-title {
        font-size: 2rem;
    }

    .content-section {
        padding: 2.5rem 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .diagram-container {
        margin: 2rem 0;
        padding: 1rem 0;
    }
}

/* ============================================================
   Print Stylesheet
   ============================================================ */
@media print {
    body::before,
    body::after {
        display: none;
    }

    .masthead::before {
        display: none;
    }

    .reading-progress {
        display: none;
    }

    .masthead {
        height: auto;
        page-break-after: avoid;
    }

    .content-section {
        page-break-inside: avoid;
    }

    p {
        orphans: 3;
        widows: 3;
    }

    body {
        font-size: 11pt;
        line-height: 1.6;
    }

    .section-ghost-number {
        display: none;
    }

    .diagram-path,
    .diagram-label {
        animation: none;
        stroke-dasharray: none;
        stroke-dashoffset: none;
        opacity: 1;
    }

    @page {
        margin: 1in;
    }
}
