/* ============================================================
   namu.biz — watercolor meditation on living systems
   palette  : duotone (indigo + ochre) on aged paper
   layout   : modular-blocks on a 12-column loom
   typography: EB Garamond + Cormorant Garamond
   ============================================================ */

:root {
    /* Duotone Ink System — exact hex values from DESIGN.md */
    --ink-primary:    #1B2A4A;   /* indigo */
    --ink-secondary:  #C4873B;   /* ochre */
    --ink-deep:       #2C3E50;   /* deep ink module ground */
    --paper:          #F4EFE6;   /* unbleached cotton-rag */
    --paper-warm:     #F0E4D0;   /* wash warm */
    --wash-light:     #D5DAE4;   /* wash light */
    --accent-dark:    #0E1520;   /* near-black concentrated ink */
    --counter-amber:  #D4752E;   /* burnt amber for numerals */
    --mixed-tone:     #6B5A42;   /* indigo + ochre overlap */

    /* Scroll-linked paper aging variable */
    --paper-age: 0;

    /* Grid: 12 columns, 20px gutter */
    --gutter: 20px;
    --col-count: 12;
    --row-unit: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: var(--paper);
    scroll-behavior: smooth;
}

body {
    font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
    font-weight: 400;
    color: var(--ink-primary);
    /* aged-paper ground that warms slightly as the user scrolls */
    background-color: hsl(36, calc(28% - (var(--paper-age) * 4%)), calc(92% - (var(--paper-age) * 3%)));
    background-image:
        radial-gradient(circle at 18% 22%, rgba(196, 135, 59, 0.06) 0%, transparent 35%),
        radial-gradient(circle at 78% 64%, rgba(27, 42, 74, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 50% 88%, rgba(107, 90, 66, 0.04) 0%, transparent 30%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* hanji paper-fiber overlay across the whole page */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            92deg,
            rgba(107, 90, 66, 0.018) 0px,
            rgba(107, 90, 66, 0.018) 1px,
            transparent 1px,
            transparent 3px
        ),
        repeating-linear-gradient(
            178deg,
            rgba(27, 42, 74, 0.012) 0px,
            rgba(27, 42, 74, 0.012) 1px,
            transparent 1px,
            transparent 5px
        );
    z-index: 1;
    mix-blend-mode: multiply;
}

/* speckle / fiber noise */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(107, 90, 66, 0.07) 1px, transparent 1px),
                      radial-gradient(rgba(27, 42, 74, 0.05) 1px, transparent 1px);
    background-size: 7px 7px, 11px 11px;
    background-position: 0 0, 3px 4px;
    opacity: 0.55;
    z-index: 1;
    mix-blend-mode: multiply;
}

/* ============================================================
   Top header strip
   ============================================================ */
.top-strip {
    position: relative;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px clamp(28px, 5vw, 80px) 22px;
    border-bottom: 1px solid rgba(27, 42, 74, 0.18);
}

.strip-mark {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.brand-glyph {
    font-family: "EB Garamond", serif;
    font-weight: 700;
    font-size: 28px;
    color: var(--ink-secondary);
    line-height: 1;
}

.brand-text {
    font-family: "EB Garamond", serif;
    font-weight: 500;
    font-style: italic;
    font-size: 19px;
    letter-spacing: 0.04em;
    color: var(--ink-primary);
}

.strip-meta {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--mixed-tone);
}

/* ============================================================
   Composition: vertical scroll of panels
   ============================================================ */
.composition {
    position: relative;
    z-index: 2;
    padding: clamp(40px, 6vw, 90px) clamp(20px, 4vw, 70px) 80px;
    display: flex;
    flex-direction: column;
    gap: clamp(60px, 8vw, 120px);
}

.panel {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--gutter);
    grid-auto-rows: var(--row-unit);
    position: relative;
}

/* Panels stagger horizontally to keep at least one visible margin */
.panel-1 { padding-left: clamp(0px, 4vw, 60px); padding-right: clamp(0px, 2vw, 30px); }
.panel-2 { padding-left: clamp(0px, 1vw, 20px); padding-right: clamp(0px, 5vw, 80px); }
.panel-3 { padding-left: clamp(0px, 5vw, 70px); padding-right: clamp(0px, 1vw, 20px); }
.panel-4 { padding-left: clamp(0px, 2vw, 30px); padding-right: clamp(0px, 4vw, 60px); }
.panel-5 { padding-left: clamp(0px, 3vw, 50px); padding-right: clamp(0px, 3vw, 50px); }
.panel-6 { padding-left: 0; padding-right: 0; }

/* ============================================================
   Modules: discrete bounded blocks
   ============================================================ */
.module {
    position: relative;
    overflow: hidden;
    padding: clamp(22px, 2.6vw, 38px);
    background: var(--paper);
    border: 1px solid rgba(27, 42, 74, 0.10);
    box-shadow: 0 0 0 1px rgba(244, 239, 230, 0.4) inset,
                0 1px 0 rgba(27, 42, 74, 0.06);
    /* the entrance state — overridden when .is-revealed is added */
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
    will-change: opacity, transform;
}

.module.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Module sizing — column / row spans */
.module-2x2  { grid-column: span 2;  grid-row: span 2; }
.module-3x2  { grid-column: span 3;  grid-row: span 2; }
.module-3x3  { grid-column: span 3;  grid-row: span 3; }
.module-3x4  { grid-column: span 3;  grid-row: span 4; }
.module-3x5  { grid-column: span 3;  grid-row: span 5; }
.module-4x3  { grid-column: span 4;  grid-row: span 3; }
.module-4x4  { grid-column: span 4;  grid-row: span 4; }
.module-4x5  { grid-column: span 4;  grid-row: span 5; }
.module-5x5  { grid-column: span 5;  grid-row: span 5; }
.module-6x4  { grid-column: span 6;  grid-row: span 4; }
.module-6x6  { grid-column: span 6;  grid-row: span 6; }
.module-8x5  { grid-column: span 8;  grid-row: span 5; }
.module-12x3 { grid-column: span 12; grid-row: span 3; }

/* ============================================================
   Module variants
   ============================================================ */

/* Ink modules — deep indigo background, light text */
.module-ink {
    background: var(--ink-deep);
    color: var(--paper);
    border-color: rgba(14, 21, 32, 0.6);
}

.module-ink .caption,
.module-ink .body,
.module-ink .pull-quote,
.module-ink .display,
.module-ink .heading-md,
.module-ink .heading-lg,
.module-ink .lede {
    color: var(--paper);
}

.module-ink em.italic {
    color: var(--ink-secondary);
    font-style: italic;
}

/* Wash modules — translucent blocks with watercolor bleed */
.module-wash {
    background: linear-gradient(135deg, var(--paper) 0%, var(--paper-warm) 100%);
    color: var(--ink-primary);
}

/* Void modules — empty-ish blocks holding a single motif */
.module-void {
    background: transparent;
    border: 1px dashed rgba(27, 42, 74, 0.2);
    box-shadow: none;
}

/* Counter modules */
.module-counter {
    background: linear-gradient(160deg, var(--paper) 0%, var(--paper-warm) 100%);
    color: var(--ink-primary);
}

/* ============================================================
   Watercolor bleed layers (rendered behind module content)
   ============================================================ */
.ink-wash,
.wash-bleed,
.ochre-wash {
    position: absolute;
    inset: -8%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.85;
    mix-blend-mode: multiply;
}

.module-ink .ink-wash {
    background:
        radial-gradient(ellipse at 22% 18%, rgba(27, 42, 74, 0.85) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 70%, rgba(14, 21, 32, 0.7) 0%, transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(107, 90, 66, 0.4) 0%, transparent 60%);
    filter: url(#watercolor-1);
    mix-blend-mode: screen;
    opacity: 0.6;
}

.module-wash .wash-bleed {
    background:
        radial-gradient(ellipse at 30% 30%, rgba(27, 42, 74, 0.18) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 65%, rgba(196, 135, 59, 0.16) 0%, transparent 50%),
        radial-gradient(circle at 60% 90%, rgba(107, 90, 66, 0.10) 0%, transparent 65%);
    filter: url(#watercolor-2);
}

.module-counter .ochre-wash {
    background:
        radial-gradient(ellipse at 35% 35%, rgba(196, 135, 59, 0.30) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(212, 117, 46, 0.22) 0%, transparent 55%),
        radial-gradient(circle at 50% 50%, rgba(240, 228, 208, 0.5) 0%, transparent 70%);
    filter: url(#watercolor-3);
}

.module-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 1.5vw, 22px);
    justify-content: flex-start;
}

.void-inner {
    align-items: center;
    justify-content: center;
}

/* ============================================================
   Typography
   ============================================================ */
.caption {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 12px;
    line-height: 1.6;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--mixed-tone);
}

.module-ink .caption { color: rgba(244, 239, 230, 0.65); }

.display {
    font-family: "EB Garamond", serif;
    font-weight: 700;
    font-size: clamp(40px, 5vw, 68px);
    line-height: 1.12;
    letter-spacing: 0.02em;
    /* hanok-curve baseline — subtle arc lift via skew/perspective */
    transform-origin: bottom;
}

.display-line {
    display: block;
}

.display-line.italic {
    font-style: italic;
    font-weight: 500;
    color: var(--ink-secondary);
    padding-left: 0.4em;
}

.heading-lg {
    font-family: "EB Garamond", serif;
    font-weight: 700;
    font-size: clamp(28px, 3.2vw, 44px);
    line-height: 1.18;
    letter-spacing: 0.02em;
}

.heading-md {
    font-family: "EB Garamond", serif;
    font-weight: 700;
    font-size: clamp(22px, 2.4vw, 32px);
    line-height: 1.25;
    letter-spacing: 0.015em;
}

.lede {
    font-family: "Cormorant Garamond", serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(17px, 1.45vw, 21px);
    line-height: 1.7;
    max-width: 38em;
    color: rgba(244, 239, 230, 0.85);
}

.body {
    font-family: "Cormorant Garamond", serif;
    font-weight: 400;
    font-size: clamp(16px, 1.15vw, 18px);
    line-height: 1.75;
    color: var(--ink-primary);
}

.body.italic { font-style: italic; }
.body.small { font-size: 14px; line-height: 1.6; }

.pull-quote {
    font-family: "EB Garamond", serif;
    font-weight: 500;
    font-style: italic;
    font-size: clamp(20px, 2vw, 30px);
    line-height: 1.35;
    color: var(--ink-primary);
    text-indent: -0.18em;
}

.pull-quote-lg {
    font-size: clamp(24px, 2.6vw, 36px);
    line-height: 1.32;
}

em.italic {
    font-style: italic;
    color: var(--ink-secondary);
    font-family: "EB Garamond", serif;
    font-weight: 500;
}

.attribution {
    margin-top: 8px;
}

.two-col {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: clamp(20px, 3vw, 48px);
    align-items: start;
}

.two-col .col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ============================================================
   Counter
   ============================================================ */
.counter {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: auto;
}

.counter-row {
    gap: 18px;
}

.counter-num {
    font-family: "EB Garamond", serif;
    font-weight: 800;
    font-size: clamp(72px, 9vw, 144px);
    line-height: 1;
    color: var(--counter-amber);
    letter-spacing: 0.01em;
    font-variant-numeric: oldstyle-nums;
    display: inline-block;
    transform: translateY(0);
    transition: transform 80ms ease-out;
}

.counter-num.counter-light {
    color: var(--ink-secondary);
}

.counter-num.counter-mid {
    font-size: clamp(48px, 5.4vw, 80px);
}

.counter-num.counting {
    animation: counterFlutter 120ms ease-in-out infinite;
}

@keyframes counterFlutter {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
}

.counter-divider {
    font-family: "EB Garamond", serif;
    font-weight: 500;
    color: var(--mixed-tone);
    font-size: clamp(48px, 5vw, 72px);
}

.counter-label {
    font-family: "EB Garamond", serif;
    font-weight: 500;
    font-style: italic;
    font-size: clamp(15px, 1.25vw, 20px);
    color: var(--mixed-tone);
    letter-spacing: 0.02em;
}

/* ============================================================
   Geometric SVG illustrations
   ============================================================ */
.rings-svg {
    width: 80%;
    max-width: 220px;
    height: auto;
    animation: ringBreath 4s ease-in-out infinite;
    transform-origin: center;
}

@keyframes ringBreath {
    0%, 100% { transform: scale(1.0); }
    50%      { transform: scale(1.02); }
}

.branch-svg {
    width: 100%;
    height: auto;
    margin-top: auto;
}

.branch-svg .branch {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    transition: stroke-dashoffset 1.8s cubic-bezier(.22,.61,.36,1);
}

.branch-svg.is-drawn .branch {
    stroke-dashoffset: 0;
}

.branch-svg .branch:nth-child(1)  { transition-delay: 0ms; }
.branch-svg .branch:nth-child(2)  { transition-delay: 100ms; }
.branch-svg .branch:nth-child(3)  { transition-delay: 100ms; }
.branch-svg .branch:nth-child(4)  { transition-delay: 220ms; }
.branch-svg .branch:nth-child(5)  { transition-delay: 240ms; }
.branch-svg .branch:nth-child(6)  { transition-delay: 220ms; }
.branch-svg .branch:nth-child(7)  { transition-delay: 240ms; }
.branch-svg .branch:nth-child(8)  { transition-delay: 360ms; }
.branch-svg .branch:nth-child(9)  { transition-delay: 380ms; }
.branch-svg .branch:nth-child(10) { transition-delay: 400ms; }
.branch-svg .branch:nth-child(11) { transition-delay: 420ms; }
.branch-svg .branch:nth-child(12) { transition-delay: 440ms; }
.branch-svg .branch:nth-child(13) { transition-delay: 460ms; }
.branch-svg .branch:nth-child(14) { transition-delay: 480ms; }
.branch-svg .branch:nth-child(15) { transition-delay: 500ms; }

.branch-caption {
    margin-top: 8px;
}

.tess-svg {
    width: 80%;
    max-width: 240px;
    height: auto;
}

.rotsq-svg {
    width: 75%;
    max-width: 220px;
    height: auto;
    animation: rotsqDrift 18s ease-in-out infinite;
    transform-origin: center;
}

@keyframes rotsqDrift {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(6deg); }
}

/* ============================================================
   Seal stamps (nakgwan)
   ============================================================ */
.seal {
    position: absolute;
    bottom: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
    z-index: 2;
    opacity: 0.92;
}

.seal svg {
    width: 100%;
    height: 100%;
    display: block;
}

.seal-dark svg rect,
.seal-dark svg circle {
    /* keeps inline color */
}

.seal-large {
    position: static;
    width: 80px;
    height: 80px;
}

.sealcap {
    text-align: center;
    margin-top: 8px;
    color: var(--mixed-tone);
}

/* ============================================================
   Colophon (panel-6)
   ============================================================ */
.colophon {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: clamp(20px, 3vw, 56px);
    align-items: start;
}

.colo-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.colo-seal {
    align-items: flex-end;
}

/* ============================================================
   Floor strip
   ============================================================ */
.floor-strip {
    position: relative;
    z-index: 5;
    border-top: 1px solid rgba(27, 42, 74, 0.18);
    padding: 22px clamp(28px, 5vw, 80px);
    background: rgba(244, 239, 230, 0.5);
}

.floor-progress {
    position: absolute;
    top: -1px;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--ink-secondary), var(--counter-amber));
    width: 0%;
    transition: width 200ms linear;
}

.floor-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--mixed-tone);
}

/* ============================================================
   Responsive — collapse the 12-col grid on narrow screens
   ============================================================ */
@media (max-width: 900px) {
    :root { --row-unit: 60px; }

    .panel {
        grid-template-columns: repeat(6, 1fr);
        gap: 14px;
    }

    .module-2x2,
    .module-3x2,
    .module-3x3,
    .module-3x4,
    .module-3x5,
    .module-4x3,
    .module-4x4,
    .module-4x5,
    .module-5x5 { grid-column: span 6; }

    .module-6x4,
    .module-6x6,
    .module-8x5,
    .module-12x3 { grid-column: span 6; }

    .two-col,
    .colophon {
        grid-template-columns: 1fr;
    }

    .panel-1, .panel-2, .panel-3, .panel-4, .panel-5 {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (max-width: 540px) {
    .top-strip {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .strip-meta {
        font-size: 10px;
    }

    .composition {
        padding: 30px 16px 60px;
        gap: 50px;
    }

    .panel {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .module {
        grid-column: span 1 !important;
        grid-row: auto !important;
        min-height: 200px;
        padding: 22px;
    }

    .module-counter,
    .module-ink {
        min-height: 240px;
    }
}
