/* ============================================================
   namu.systems - Neubrutalist Magazine-Spread Publication
   Colors: cool-grays palette with Chlorophyll accent
   Fonts: Roboto Slab, Source Sans 3, IBM Plex Mono
   ============================================================ */

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

html {
    scroll-behavior: auto;
    overflow: hidden;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    color: #1a1a1e;
    background-color: #e8e8ec;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* --- Risograph Grain Texture --- */
.riso-filter {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* --- Page Container (Snap Scroll) --- */
.page-container {
    width: 100%;
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: auto;
}

/* --- Spread Base --- */
.spread {
    min-height: 100vh;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

/* --- Shared Grid --- */
.spread-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    column-gap: 2px;
    width: 100%;
    height: 100%;
    padding: 2rem;
    position: relative;
}

/* ============================================================
   SPREAD 1: The Masthead
   ============================================================ */
.spread-1 {
    background-color: #e8e8ec;
}

.masthead-photo {
    grid-column: 5 / 13;
    grid-row: 1 / 4;
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 600ms ease-out;
    border: 4px solid #1a1a1e;
    overflow: hidden;
}

.masthead-photo.visible {
    opacity: 1;
}

.duotone-container {
    width: 100%;
    height: 100%;
    background-color: #2a2a34;
    position: relative;
}

.duotone-leaves {
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
}

.masthead-title {
    grid-column: 1 / 9;
    grid-row: 2 / 4;
    align-self: end;
    padding-bottom: 15vh;
    font-family: 'Roboto Slab', serif;
    font-weight: 900;
    font-size: clamp(3.2rem, 8.5vw, 7.5rem);
    line-height: 0.92;
    letter-spacing: -0.025em;
    color: #1a1a1e;
    z-index: 2;
    position: relative;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 500ms ease-out;
}

.masthead-title.visible {
    clip-path: inset(0 0 0 0);
}

.masthead-meta {
    grid-column: 9 / 13;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding-top: 2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    color: #6b6b78;
    z-index: 3;
    opacity: 0;
    transition: opacity 300ms ease-out;
}

.masthead-meta.visible {
    opacity: 1;
}

.meta-date,
.meta-version,
.meta-tagline {
    display: block;
    text-transform: uppercase;
}

.masthead-rule {
    position: absolute;
    top: 50%;
    left: 2rem;
    right: 2rem;
    height: 4px;
    background-color: #1a1a1e;
    z-index: 4;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 400ms ease-out;
}

.masthead-rule.visible {
    transform: scaleX(1);
}

/* ============================================================
   SPREAD 2: The Statement
   ============================================================ */
.spread-2 {
    background-color: #f4f4f7;
}

.spread-2 .spread-grid {
    align-items: center;
}

.statement-pullquote {
    grid-column: 1 / 6;
    grid-row: 1 / 2;
    align-self: center;
    padding-right: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.statement-pullquote.visible {
    opacity: 1;
    transform: translateY(0);
}

.statement-pullquote blockquote p {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.2vw, 2.6rem);
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: #1a1a1e;
}

.pullquote-underline {
    display: block;
    width: 100%;
    height: 4px;
    background-color: #4a7c59;
    margin-top: 1.5rem;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms ease-out;
}

.pullquote-underline.visible {
    transform: scaleX(1);
}

.pullquote-attribution {
    display: block;
    margin-top: 1rem;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #3a3a42;
    font-style: normal;
}

.statement-gutter {
    grid-column: 6 / 7;
    grid-row: 1 / 2;
    position: relative;
    display: flex;
    justify-content: center;
}

.gutter-line {
    width: 1px;
    height: 100%;
    background-color: #c8c8d0;
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 600ms ease-out;
}

.gutter-line.visible {
    transform: scaleY(1);
}

.statement-body {
    grid-column: 7 / 13;
    grid-row: 1 / 2;
    align-self: center;
    column-count: 2;
    column-gap: 1.5rem;
    padding-left: 1rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.statement-body.visible {
    opacity: 1;
    transform: translateY(0);
}

.statement-body p {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.65;
    color: #1a1a1e;
    margin-bottom: 1rem;
}

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

.leaf-divider {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 1.5rem 0;
    break-inside: avoid;
    column-span: all;
}

.divider-leaf {
    display: inline-block;
}

/* ============================================================
   SPREAD 3: The System Map
   ============================================================ */
.spread-3 {
    background-color: #e8e8ec;
    position: relative;
}

.system-map-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2a2a34;
    overflow: hidden;
}

.canopy-photo {
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
}

.system-map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.grid-lines {
    position: absolute;
    top: 10%;
    left: 5%;
    width: 90%;
    height: 80%;
}

/* Horizontal lines */
.h-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.3);
    transform: scaleX(0);
    transform-origin: left;
}

.h-line-1 { top: 0%; }
.h-line-2 { top: 33.33%; }
.h-line-3 { top: 66.66%; }
.h-line-4 { top: 100%; }

.h-line.visible {
    transform: scaleX(1);
    transition: transform 200ms ease-out;
}

/* Vertical lines */
.v-line {
    position: absolute;
    top: 0;
    height: 100%;
    width: 1px;
    background-color: rgba(255, 255, 255, 0.3);
    transform: scaleY(0);
    transform-origin: top;
}

.v-line-1 { left: 0%; }
.v-line-2 { left: 20%; }
.v-line-3 { left: 40%; }
.v-line-4 { left: 60%; }
.v-line-5 { left: 80%; }
.v-line-6 { left: 100%; }

.v-line.visible {
    transform: scaleY(1);
    transition: transform 200ms ease-out;
}

/* Grid labels */
.grid-label {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 300ms ease-out;
    white-space: nowrap;
    padding: 4px 8px;
    background-color: rgba(42, 42, 52, 0.5);
}

.grid-label.visible {
    opacity: 1;
}

/* ============================================================
   SPREAD 4: The Index
   ============================================================ */
.spread-4 {
    background-color: #f4f4f7;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.index-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 4rem);
}

.index-card {
    border: 4px solid #1a1a1e;
    position: relative;
    overflow: hidden;
}

.card-skeleton-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #c8c8d0;
    z-index: 2;
    transition: opacity 300ms ease-out;
}

.index-card.skeleton .card-skeleton-fill {
    animation: skeletonShimmer 1.8s linear infinite;
}

@keyframes skeletonShimmer {
    0% {
        background-image: linear-gradient(90deg, transparent 0%, rgba(244, 244, 247, 0.4) 50%, transparent 100%);
        background-size: 200% 100%;
        background-position: 200% 0;
    }
    100% {
        background-image: linear-gradient(90deg, transparent 0%, rgba(244, 244, 247, 0.4) 50%, transparent 100%);
        background-size: 200% 100%;
        background-position: -200% 0;
    }
}

.card-content {
    position: relative;
    z-index: 1;
    padding: 1.2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 400ms ease-out;
}

.index-card.revealed .card-skeleton-fill {
    opacity: 0;
    animation: none;
}

.index-card.revealed .card-content {
    clip-path: inset(0 0 0 0);
}

.card-number {
    font-family: 'Roboto Slab', serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1;
    color: #1a1a1e;
    letter-spacing: -0.025em;
}

.card-text {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(0.8rem, 0.95vw, 0.95rem);
    line-height: 1.55;
    color: #3a3a42;
    margin-top: 0.5rem;
}

.card-thumb {
    width: 100%;
    height: 100%;
    border: 4px solid #1a1a1e;
}

.card-thumb svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   SPREAD 5: The Colophon
   ============================================================ */
.spread-5 {
    background-color: #1a1a1e;
    display: flex;
    align-items: center;
    justify-content: center;
}

.colophon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    opacity: 0;
    transition: opacity 400ms ease-out;
}

.colophon-content.visible {
    opacity: 1;
}

.colophon-leaf {
    margin-bottom: 2rem;
}

/* Leaf path draw animations */
.leaf-outline {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

.leaf-outline.draw {
    animation: drawOutline 800ms ease-out forwards;
}

@keyframes drawOutline {
    to { stroke-dashoffset: 0; }
}

.leaf-midrib {
    stroke-dasharray: 210;
    stroke-dashoffset: 210;
}

.leaf-midrib.draw {
    animation: drawMidrib 400ms ease-out forwards;
}

@keyframes drawMidrib {
    to { stroke-dashoffset: 0; }
}

.leaf-vein {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
}

.leaf-vein.draw {
    animation: drawVein 300ms ease-out forwards;
}

@keyframes drawVein {
    to { stroke-dashoffset: 0; }
}

.colophon-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 1.15;
    color: #f4f4f7;
    margin-bottom: 1rem;
}

.colophon-credits {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    line-height: 1.65;
    color: #9a9aac;
    max-width: 28rem;
}

/* ============================================================
   Navigation Rail
   ============================================================ */
.spread-nav {
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    z-index: 1000;
}

.nav-item {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    color: #6b6b78;
    position: relative;
    z-index: 2;
    line-height: 1;
}

.nav-indicator {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #4a7c59;
    z-index: 1;
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.nav-item.active .nav-number {
    color: #1a1a1e;
}

.nav-item.active .nav-indicator {
    opacity: 1;
}

/* Colophon spread: light navigation text */
.spread-nav.on-dark .nav-number {
    color: #9a9aac;
}

.spread-nav.on-dark .nav-item.active .nav-number {
    color: #f4f4f7;
}

/* ============================================================
   Responsive: Below 768px
   ============================================================ */
@media (max-width: 768px) {
    .spread-grid {
        grid-template-columns: repeat(4, 1fr);
        padding: 1.5rem;
    }

    /* Spread 1 Mobile */
    .masthead-photo {
        grid-column: 1 / 5;
        grid-row: 1 / 2;
    }

    .masthead-title {
        grid-column: 1 / 5;
        grid-row: 2 / 3;
        padding-bottom: 2rem;
    }

    .masthead-meta {
        grid-column: 1 / 5;
        grid-row: 3 / 4;
        flex-direction: row;
        gap: 1.5rem;
        padding-top: 0;
    }

    .masthead-rule {
        left: 1.5rem;
        right: 1.5rem;
    }

    /* Spread 2 Mobile */
    .spread-2 .spread-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        padding: 2rem 1.5rem;
        overflow-y: auto;
    }

    .statement-pullquote {
        padding-right: 0;
    }

    .statement-gutter {
        display: none;
    }

    .statement-body {
        column-count: 1;
        padding-left: 0;
    }

    /* Spread 3 Mobile */
    .grid-lines {
        top: 10%;
        left: 3%;
        width: 94%;
        height: 80%;
    }

    .grid-label {
        font-size: 0.55rem;
    }

    /* Spread 4 Mobile */
    .index-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(6, 1fr);
    }

    .spread-4 {
        padding: 1.5rem;
    }

    /* Navigation */
    .spread-nav {
        right: 0.75rem;
    }

    .nav-number {
        font-size: 0.6rem;
    }

    /* Replace circle with leaf icon on small screens */
    .nav-indicator {
        width: 16px;
        height: 16px;
        background-color: transparent;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='12' cy='12' rx='10' ry='5' fill='none' stroke='%234a7c59' stroke-width='1.5'/%3E%3Cline x1='12' y1='7' x2='12' y2='17' stroke='%234a7c59' stroke-width='1'/%3E%3C/svg%3E");
        background-size: contain;
        background-repeat: no-repeat;
    }
}

/* ============================================================
   Utility
   ============================================================ */
::selection {
    background-color: #4a7c59;
    color: #f4f4f7;
}
