/* ============================================================
   monopole.city - Neubrutalist Scholarly Collage
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --blueprint-wash: #e8f0f8;
    --vellum-white: #f8f5f0;
    --xerox-warm: #f0ede6;
    --ink-midnight: #1a1a2e;
    --slate-graphite: #2d3142;
    --cyanotype: #5b7fa6;
    --washed-cyan: #a3c4e0;
    --pushpin-scarlet: #cc3333;
    --pushpin-bright: #dd4444;
    --letterpress-black: #0d0d0d;
    --masking-cream: #e8dfc4;
    --masking-cream-alpha: rgba(232, 223, 196, 0.7);

    /* Dynamic background - modified by JS on scroll */
    /* Scroll depth colors: #e8f0f8 -> #dde8f4 -> #d4e0f0 */
    --bg-wash: #e8f0f8;

    /* Typography scale */
    --font-display: 'Caveat', cursive;
    --font-body: 'Libre Baskerville', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --hero-scale: clamp(2.2rem, 5.5vw, 4.5rem);
    --card-heading: clamp(1.3rem, 2.5vw, 1.8rem);
    --pinned-note-size: clamp(1rem, 2vw, 1.3rem);
    --body-scale: clamp(0.95rem, 1.8vw, 1.1rem);
    --nav-scale: 0.85rem;
    --meta-scale: 0.75rem;
    --ref-scale: 0.7rem;
    --mono-scale: 0.7rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--body-scale);
    color: var(--ink-midnight);
    background-color: var(--bg-wash);
    line-height: 1.65;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    position: relative;
}

/* --- Cyanotype Grid Underlay --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(163, 196, 224, 0.08) 0px,
            rgba(163, 196, 224, 0.08) 1px,
            transparent 1px,
            transparent 48px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(163, 196, 224, 0.08) 0px,
            rgba(163, 196, 224, 0.08) 1px,
            transparent 1px,
            transparent 48px
        );
    z-index: 0;
    pointer-events: none;
}

/* ============================================================
   HERO / Full-Screen Narrative Entry
   ============================================================ */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background-color: var(--blueprint-wash);
    z-index: 10;
    overflow: hidden;
}

.hero-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.grid-line {
    position: absolute;
    background: var(--washed-cyan);
    opacity: 0.15;
}

.grid-h {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: scaleX(0);
    transform-origin: center;
    animation: drawH 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 300ms forwards;
}

.grid-v {
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    transform: scaleY(0);
    transform-origin: center;
    animation: drawV 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 300ms forwards;
}

@keyframes drawH {
    to { transform: scaleX(1); }
}

@keyframes drawV {
    to { transform: scaleY(1); }
}

.hero-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.hero-title-svg {
    width: clamp(300px, 60vw, 800px);
    height: auto;
    opacity: 0;
    animation: fadeInTitle 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 700ms forwards;
}

.hero-title-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 80px;
    fill: none;
    stroke: var(--letterpress-black);
    stroke-width: 1.5;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawText 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 700ms forwards;
}

@keyframes drawText {
    to {
        stroke-dashoffset: 0;
        fill: var(--letterpress-black);
    }
}

@keyframes fadeInTitle {
    to { opacity: 1; }
}

/* Rubber Stamp: ARCHIVE */
.stamp-label {
    display: inline-block;
    border: 2px dashed var(--slate-graphite);
    border-radius: 4px;
    padding: 6px 20px;
    transform: rotate(-3deg);
    opacity: 0;
    animation: stampDrop 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55) 2000ms forwards;
}

.stamp-text {
    font-family: var(--font-mono);
    font-size: var(--mono-scale);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--slate-graphite);
}

@keyframes stampDrop {
    0% {
        opacity: 0;
        transform: rotate(-5deg) translateY(-16px);
    }
    60% {
        opacity: 1;
        transform: rotate(-3deg) translateY(2px);
    }
    80% {
        transform: rotate(-3.5deg) translateY(-1px);
    }
    100% {
        opacity: 1;
        transform: rotate(-3deg) translateY(0);
    }
}

/* Scroll Hint */
.scroll-hint {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fadeInHint 500ms ease 2500ms forwards;
}

@keyframes fadeInHint {
    to { opacity: 0.5; }
}

.scroll-hint svg {
    animation: bobDown 1.5s ease-in-out infinite;
}

@keyframes bobDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* ============================================================
   HEADER STRIP
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 64px;
    padding: 0 48px;
    background-color: var(--blueprint-wash);
    border-bottom: 4px solid var(--letterpress-black);
}

.header-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: var(--letterpress-black);
    letter-spacing: 0.01em;
    line-height: 1.35;
}

.header-nav {
    display: flex;
    gap: 24px;
}

.nav-link {
    font-family: var(--font-body);
    font-size: var(--nav-scale);
    color: var(--slate-graphite);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--cyanotype);
    transition: color 200ms ease, text-decoration-color 200ms ease;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    color: var(--cyanotype);
    text-decoration-color: var(--pushpin-scarlet);
}

/* ============================================================
   SECTION STAMP DIVIDERS
   ============================================================ */
.section-stamp {
    display: flex;
    justify-content: center;
    padding: 32px 0 16px;
    position: relative;
    z-index: 1;
}

.section-stamp-inner {
    grid-column: 1 / -1;
    padding: 24px 0 8px;
}

.stamp-inner {
    display: inline-block;
    border: 2px dashed var(--slate-graphite);
    border-radius: 4px;
    padding: 6px 16px;
    font-family: var(--font-mono);
    font-size: var(--mono-scale);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--slate-graphite);
    transform: rotate(-3deg);
}

/* ============================================================
   CORKBOARD / CARD GRID
   ============================================================ */
.corkboard {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    row-gap: 24px;
    column-gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 48px 80px;
}

/* ============================================================
   TAPE STRIPS
   ============================================================ */
.tape-strip {
    position: absolute;
    width: 140px;
    height: 24px;
    background: var(--masking-cream-alpha);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    z-index: 5;
    pointer-events: none;
    border-radius: 1px;
}

.tape-strip-1 {
    top: 80px;
    right: 80px;
    transform: rotate(-2deg);
}

.tape-strip-2 {
    top: 50%;
    left: 60px;
    transform: rotate(-4deg);
    width: 160px;
}

.tape-strip-3 {
    bottom: 300px;
    right: 120px;
    transform: rotate(3deg);
    width: 120px;
}

/* ============================================================
   CARD BASE STYLES
   ============================================================ */
.card {
    position: relative;
    cursor: pointer;
    transition: border-color 200ms ease, box-shadow 200ms ease;
    opacity: 0;
    transform: translateY(24px);
}

.card.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 400ms ease, transform 400ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.card.hidden-filter {
    display: none;
}

.card-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: 12px 40px 12px 16px;
    cursor: pointer;
    user-select: none;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--card-heading);
    letter-spacing: 0.01em;
    line-height: 1.35;
    color: var(--letterpress-black);
    flex: 1;
}

.card-ref {
    position: absolute;
    top: 8px;
    right: 12px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cyanotype);
}

.card-arrow {
    position: absolute;
    right: 12px;
    bottom: 12px;
    transition: transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
}

.card.expanded .card-arrow {
    transform: rotate(90deg);
}

/* Card Body - collapsed by default */
.card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 0 16px;
}

.card.expanded .card-body {
    max-height: 800px;
    padding: 0 16px 16px;
}

.card-body p {
    margin-bottom: 12px;
    line-height: 1.65;
}

.card-body p:last-child {
    margin-bottom: 0;
}

/* Page Fold Triangle */
.page-fold {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 16px 16px;
    border-color: transparent transparent rgba(45, 49, 66, 0.2) transparent;
}

/* Citation style */
.citation {
    font-family: var(--font-mono);
    font-size: var(--meta-scale);
    color: var(--cyanotype);
    letter-spacing: 0.04em;
    font-style: italic;
}

/* ============================================================
   CARD TYPE 1: INDEX CARD
   ============================================================ */
.index-card {
    background-color: var(--vellum-white);
    border: 3px solid var(--slate-graphite);
    border-radius: 0;
}

.index-card:hover {
    border-color: var(--cyanotype);
    box-shadow: 0 0 0 2px rgba(163, 196, 224, 0.4);
}

.index-card .card-rule {
    width: 100%;
    height: 2px;
    background-color: var(--pushpin-scarlet);
    margin-bottom: 12px;
}

/* ============================================================
   CARD TYPE 2: TORN PAGE (spans 2 columns)
   ============================================================ */
.torn-page {
    grid-column: span 2;
    background-color: #fff;
    border: 3px solid var(--slate-graphite);
    border-radius: 0;
    clip-path: polygon(
        0% 0%,
        100% 0%,
        100% 100%,
        0% 100%,
        2% 95%,
        0% 90%,
        1% 85%,
        0% 80%,
        2% 75%,
        0% 70%,
        1% 65%,
        0% 60%,
        2% 55%,
        0% 50%,
        1% 45%,
        0% 40%,
        2% 35%,
        0% 30%,
        1% 25%,
        0% 20%,
        2% 15%,
        0% 10%,
        1% 5%
    );
    padding-left: 12px;
}

.torn-page:hover {
    border-color: var(--cyanotype);
    box-shadow: 0 0 0 2px rgba(163, 196, 224, 0.4);
}

.torn-page .card-body {
    position: relative;
}

.torn-page .notebook-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 23px,
        #c8d8e8 23px,
        #c8d8e8 24px
    );
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.torn-page .card-body p,
.torn-page .card-body blockquote {
    position: relative;
    z-index: 1;
}

/* Pull Quote */
.pull-quote {
    position: relative;
    margin: 12px 0 16px;
    padding: 8px 16px 8px 32px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    line-height: 1.45;
    color: var(--slate-graphite);
}

.pull-quote::before {
    content: '\201C';
    position: absolute;
    left: -4px;
    top: -12px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 4rem;
    color: rgba(91, 127, 166, 0.3);
    line-height: 1;
}

/* ============================================================
   CARD TYPE 3: PHOTOCOPY
   ============================================================ */
.photocopy {
    background-color: var(--xerox-warm);
    border: 4px solid var(--letterpress-black);
    border-radius: 0;
    position: relative;
}

.photocopy::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.photocopy .card-header,
.photocopy .card-body {
    position: relative;
    z-index: 1;
}

.photocopy:hover {
    border-color: var(--cyanotype);
    box-shadow: 0 0 0 2px rgba(163, 196, 224, 0.4);
}

.photocopy .card-body p {
    color: var(--ink-midnight);
}

/* ============================================================
   CARD TYPE 4: PINNED NOTE
   ============================================================ */
.pinned-note {
    background-color: var(--vellum-white);
    border: 3px solid var(--slate-graphite);
    border-radius: 0;
    transform: rotate(1.5deg) translateY(24px);
    max-width: 300px;
}

.pinned-note.visible {
    transform: rotate(1.5deg) translateY(0);
}

.pinned-note:hover {
    border-color: var(--cyanotype);
    box-shadow: 0 0 0 2px rgba(163, 196, 224, 0.4);
}

.pinned-note .card-title {
    font-size: var(--pinned-note-size);
}

.pinned-note .card-body {
    font-family: var(--font-display);
    font-size: var(--pinned-note-size);
    line-height: 1.45;
}

/* Pushpin */
.pushpin {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--pushpin-scarlet) 40%, #991111 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: box-shadow 200ms ease, background 200ms ease;
}

.pinned-note:hover .pushpin {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
    background: radial-gradient(circle, var(--pushpin-bright) 40%, var(--pushpin-scarlet) 100%);
}

/* ============================================================
   UNDERLINE TARGETS (hand-drawn SVG underlines)
   ============================================================ */
.underline-target {
    position: relative;
    display: inline;
}

.underline-svg {
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 8px;
    overflow: visible;
}

.underline-path {
    stroke: rgba(204, 51, 51, 0.6);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 600ms ease;
}

.underline-path.drawn {
    stroke-dashoffset: 0;
}

/* ============================================================
   MARGIN ANNOTATIONS
   ============================================================ */
.margin-annotations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    display: none;
}

@media (min-width: 1200px) {
    .margin-annotations {
        display: block;
    }
}

.margin-note {
    position: absolute;
    left: 24px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 160px;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.margin-note.visible {
    opacity: 1;
    transform: translateX(0);
}

.margin-line {
    display: inline-block;
    width: 24px;
    min-width: 24px;
    height: 1px;
    background-color: var(--cyanotype);
    margin-top: 8px;
}

.margin-text {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--cyanotype);
    line-height: 1.35;
}

/* ============================================================
   SVG NOISE FILTER (for photocopy grain)
   ============================================================ */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .site-header {
        padding: 0 16px;
        height: 56px;
    }

    .header-nav {
        gap: 12px;
    }

    .nav-link {
        font-size: 0.75rem;
    }

    .corkboard {
        grid-template-columns: 1fr;
        padding: 16px;
        row-gap: 16px;
        column-gap: 12px;
    }

    .torn-page {
        grid-column: span 1;
        clip-path: none;
        padding-left: 0;
    }

    .pinned-note {
        max-width: 100%;
    }

    .tape-strip {
        display: none;
    }

    .section-stamp-inner {
        grid-column: span 1;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 1.2rem;
    }

    .header-nav {
        gap: 8px;
    }

    .corkboard {
        padding: 12px;
    }
}

/* ============================================================
   TRANSITION CLASSES FOR CARDS IN VIEWPORT
   ============================================================ */
.card.enter-from-left {
    transform: translateX(-32px);
    opacity: 0;
}

.card.enter-from-left.visible {
    transform: translateX(0);
    opacity: 1;
}

/* Stagger delays applied via JS data attribute */
.card[data-stagger="0"] { transition-delay: 0ms; }
.card[data-stagger="1"] { transition-delay: 80ms; }
.card[data-stagger="2"] { transition-delay: 160ms; }
.card[data-stagger="3"] { transition-delay: 240ms; }
.card[data-stagger="4"] { transition-delay: 320ms; }
