/* infra.limited — Swiss-disciplined contemplative atlas */

:root {
    --ink-stone: #1a0e10;
    --burgundy: #5b1929;
    --burgundy-slate: #8a2c3e;
    --pearl-outline: #d4c8b8;
    --pearl: #f4ede2;
    --mist: #e8dcc6;

    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);

    --margin-side: 12vw;
    --rail-width: 40px;

    --hex-edge: 132px;
    --hex-w: calc(var(--hex-edge) * 1.732);
    --hex-h: calc(var(--hex-edge) * 2);

    --ease-still: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-draw: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Archivo', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 16.5px;
    line-height: 1.65;
    font-weight: 400;
    color: var(--ink-stone);
    background-color: var(--pearl);
    overflow-x: hidden;

    /* Subtle paper substrate of empty hex outlines as background SVG */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='254' viewBox='0 0 220 254'><g fill='none' stroke='%23d4c8b8' stroke-width='0.5'><polygon points='55,2 165,2 219,64 165,126 55,126 1,64'/><polygon points='165,128 275,128 329,190 275,252 165,252 111,190'/><polygon points='-55,128 55,128 109,190 55,252 -55,252 -109,190'/></g></svg>");
    background-repeat: repeat;
    background-position: center top;
}

main.atlas {
    scroll-snap-type: y proximity;
    overflow: hidden;
}

/* ----- Navigation rail ----- */
.rail {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--rail-width);
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: transparent;
    border-right: 0.5px solid var(--pearl-outline);
}

.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--pearl-outline);
    text-decoration: none;
    transition: color 180ms var(--ease-still);
    cursor: pointer;
}

.rail-hex {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.rail-hex svg {
    transition: stroke-width 180ms var(--ease-still);
}

.rail-num {
    font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rail-item.is-active,
.rail-item:hover {
    color: var(--burgundy);
}

.rail-item.is-active .rail-hex svg,
.rail-item:hover .rail-hex svg {
    stroke-width: 2px;
}

/* ----- Terraces ----- */
.terrace {
    position: relative;
    width: 100%;
    padding: 100px var(--margin-side) 100px calc(var(--margin-side) + var(--rail-width));
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.terrace--i {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 120px;
}

.terrace--ii,
.terrace--iii,
.terrace--iv {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.terrace--v {
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.terrace--vi {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.terrace-num {
    position: absolute;
    top: 40px;
    left: calc(var(--margin-side) + var(--rail-width));
    font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--burgundy);
    font-weight: 500;
}

.terrace-lede {
    max-width: 540px;
    margin: 60px 0 80px;
    font-size: 17px;
    line-height: 1.7;
    color: var(--ink-stone);
    font-weight: 400;
}

/* ----- Hex base ----- */
.hex {
    position: relative;
    width: var(--hex-w);
    height: var(--hex-h);
    clip-path: var(--hex-clip);
    -webkit-clip-path: var(--hex-clip);
    background: var(--pearl);
    transition: background 200ms var(--ease-still);
}

.hex::before {
    /* Inner pearl + burgundy hairline border via clip-path layer */
    content: '';
    position: absolute;
    inset: 0;
    background: var(--burgundy);
    clip-path: var(--hex-clip);
    -webkit-clip-path: var(--hex-clip);
    z-index: 0;
}

.hex::after {
    content: '';
    position: absolute;
    inset: 1.25px;
    background: var(--pearl);
    clip-path: var(--hex-clip);
    -webkit-clip-path: var(--hex-clip);
    z-index: 0;
    transition: inset 180ms var(--ease-still);
}

.hex--lit:hover::before {
    background: var(--burgundy-slate);
}

.hex--lit:hover::after {
    inset: 2px;
}

.hex-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18%;
    text-align: center;
}

/* ----- Terrace I — Threshold ----- */
.terrace--i {
    position: relative;
}

.hex-field--i {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='254' viewBox='0 0 220 254'><g fill='none' stroke='%23d4c8b8' stroke-width='0.5'><polygon points='55,2 165,2 219,64 165,126 55,126 1,64'/><polygon points='165,128 275,128 329,190 275,252 165,252 111,190'/><polygon points='-55,128 55,128 109,190 55,252 -55,252 -109,190'/></g></svg>");
    background-repeat: repeat;
    opacity: 0.95;
    z-index: 0;
}

.terrace-i-contour {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.threshold {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 70px;
}

.threshold-cell {
    width: 320px;
    height: 370px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hex--threshold {
    width: 100%;
    height: 100%;
}

.hex--threshold .hex-inner {
    padding: 14%;
    gap: 14px;
}

.wordmark {
    font-family: 'Archivo', sans-serif;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--burgundy);
    text-transform: lowercase;
}

.elevation {
    font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--ink-stone);
    letter-spacing: 0.04em;
}

.thesis {
    font-family: 'Archivo', sans-serif;
    font-size: 22px;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.5;
    text-align: center;
    color: var(--ink-stone);
    max-width: 540px;
}

/* ----- Terrace II — Discipline / Flower ----- */
.terrace--ii {
    align-items: center;
    text-align: center;
}

.terrace--ii .terrace-lede {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.flower {
    position: relative;
    width: min(720px, 100%);
    height: 720px;
    margin: 40px auto 80px;
}

.petal {
    position: absolute;
    width: 200px;
    height: 230px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 480ms var(--ease-still), width 480ms var(--ease-still), height 480ms var(--ease-still);
    opacity: 0;
}

.flower.is-revealed .petal {
    opacity: 1;
}

.petal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--burgundy);
    clip-path: var(--hex-clip);
    -webkit-clip-path: var(--hex-clip);
    transition: background 180ms var(--ease-still);
}

.petal::after {
    content: '';
    position: absolute;
    inset: 1.25px;
    background: var(--pearl);
    clip-path: var(--hex-clip);
    -webkit-clip-path: var(--hex-clip);
    transition: inset 180ms var(--ease-still);
}

.petal:hover::before {
    background: var(--burgundy-slate);
}

.petal:hover::after {
    inset: 2px;
}

.petal-icon,
.petal-label,
.petal-body {
    position: relative;
    z-index: 2;
}

.petal-icon {
    display: block;
    width: 60px;
    height: 60px;
    margin: 50px auto 12px;
    color: var(--burgundy);
}

.petal-icon svg {
    width: 100%;
    height: 100%;
}

.petal-label {
    display: block;
    font-family: 'Archivo', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--burgundy);
    text-align: center;
    padding: 0 12px;
}

.petal-body {
    display: block;
    margin: 14px 24px 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--ink-stone);
    text-align: center;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 380ms var(--ease-still) 200ms, max-height 480ms var(--ease-still);
}

.petal.is-open {
    width: 380px;
    height: 430px;
    z-index: 5;
}

.petal.is-open .petal-icon {
    margin-top: 70px;
    width: 40px;
    height: 40px;
}

.petal.is-open .petal-body {
    opacity: 1;
    max-height: 280px;
    margin-top: 12px;
}

.petal.is-shifted-out {
    transform: translate(var(--shift-x, 0), var(--shift-y, 0));
}

/* Flower positioning — center plus 6 hex petals */
.petal--center { left: 260px; top: 260px; }
.petal--p1 { left: 260px; top: 50px; }   /* top */
.petal--p2 { left: 440px; top: 155px; }  /* upper-right */
.petal--p3 { left: 440px; top: 365px; }  /* lower-right */
.petal--p4 { left: 260px; top: 470px; }  /* bottom */
.petal--p5 { left: 80px;  top: 365px; }  /* lower-left */
.petal--p6 { left: 80px;  top: 155px; }  /* upper-left */

/* Open state shifts neighbors gently outward */
.petal.is-open.petal--center { left: 170px; top: 195px; }

/* ----- Terrace III — Map ----- */
.terrace--iii {
    align-items: center;
}

.terrace--iii .terrace-lede {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.map-graph {
    position: relative;
    width: min(800px, 100%);
    height: 540px;
    margin: 20px auto;
}

.map-edges {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.edge {
    stroke: var(--burgundy);
    stroke-width: 1px;
    transition: stroke 180ms var(--ease-still), stroke-width 180ms var(--ease-still);
    pointer-events: stroke;
    cursor: pointer;
}

.edge.is-highlight {
    stroke: var(--burgundy-slate);
    stroke-width: 2px;
}

.edge-group {
    pointer-events: auto;
}

.node {
    position: absolute;
    width: 130px;
    height: 150px;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.hex--node {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.hex--node .hex-inner {
    padding: 16%;
    gap: 6px;
}

.node-icon {
    display: block;
    width: 44px;
    height: 44px;
    color: var(--burgundy);
}

.node-icon svg {
    width: 100%;
    height: 100%;
}

.node-label {
    font-family: 'Archivo', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--burgundy);
}

.node.is-dim .hex {
    opacity: 0.35;
}

.node.is-chain .hex::before {
    background: var(--burgundy-slate);
}

.map-caption {
    margin: 60px auto 0;
    max-width: 540px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--ink-stone);
    opacity: 0.85;
}

/* ----- Terrace IV — Field Notes ----- */
.terrace--iv {
    align-items: center;
}

.terrace--iv .terrace-lede {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.notes {
    width: min(640px, 100%);
    margin: 0 auto 80px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.note {
    position: relative;
    padding: 28px 36px;
    background: var(--pearl);
    border: 0.5px solid var(--pearl-outline);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px));
    transition: opacity 480ms var(--ease-still), transform 480ms var(--ease-still), border-color 200ms var(--ease-still), max-height 600ms var(--ease-still);
    cursor: pointer;
    opacity: 0.18;
    pointer-events: auto;
    transform: translateY(8px);
    max-height: 80px;
    overflow: hidden;
}

.note.is-revealed {
    opacity: 1;
    transform: translateY(0);
    max-height: 220px;
}

.note.is-revealed:hover {
    border-color: var(--burgundy-slate);
}

.note-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--burgundy);
}

.note-num {
    font-weight: 500;
}

.note-date {
    color: var(--ink-stone);
    opacity: 0.7;
}

.note-body {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-stone);
}

/* ----- Terrace V — The Range ----- */
.terrace--v {
    padding-left: 0;
    padding-right: 0;
}

.terrace--v .terrace-num {
    left: var(--margin-side);
}

.range-band {
    position: relative;
    width: 100%;
    height: 60vh;
    min-height: 420px;
    overflow: hidden;
    margin: 80px 0 40px;
}

.mist-layer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 25%;
    height: 30%;
    background: var(--mist);
    opacity: 0.6;
    z-index: 1;
}

.range-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.ridge-line {
    stroke-dasharray: 6000;
    stroke-dashoffset: 6000;
    transition: stroke-dashoffset 4500ms var(--ease-draw);
}

.ridge-fill {
    opacity: 0;
    transition: opacity 1000ms var(--ease-still) 3500ms;
}

.range-band.is-drawn .ridge-line {
    stroke-dashoffset: 0;
}

.range-band.is-drawn .ridge-fill {
    opacity: 1;
}

.bench-mark {
    opacity: 0;
    transition: opacity 200ms var(--ease-still);
}

.bench-mark.is-shown {
    opacity: 1;
}

.range-coords {
    position: absolute;
    bottom: 30px;
    left: var(--margin-side);
    right: var(--margin-side);
    z-index: 3;
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--burgundy);
    letter-spacing: 0.04em;
}

.range-cells {
    margin: 60px var(--margin-side) 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
}

.hex--small {
    width: 110px;
    height: 127px;
}

.hex--small .hex-inner {
    padding: 22%;
}

.cell-icon {
    display: inline-flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: var(--burgundy);
}

.cell-icon svg {
    width: 100%;
    height: 100%;
}

/* ----- Terrace VI — Coordinates ----- */
.coord-grid {
    width: min(720px, 100%);
    margin: 60px auto 50px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 110px;
    gap: 14px 8px;
    align-items: center;
}

.hex--coord {
    width: 92px;
    height: 106px;
    margin: 0 auto;
    transition: transform 220ms var(--ease-still);
}

.hex--coord:hover {
    transform: translateY(-2px);
}

.hex--coord .hex-inner {
    padding: 22%;
    color: var(--burgundy);
}

.hex--coord .hex-inner svg {
    width: 100%;
    height: 100%;
}

/* Offset row for honeycomb feel */
.coord-grid > .hex--coord:nth-child(n+7) {
    transform: translateX(40px);
}
.coord-grid > .hex--coord:nth-child(n+7):hover {
    transform: translateX(40px) translateY(-2px);
}

.motto {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--burgundy);
    letter-spacing: 0.06em;
    margin-top: 50px;
    text-align: center;
}

.footer-coord {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--ink-stone);
    opacity: 0.6;
    letter-spacing: 0.08em;
    margin-top: 14px;
    text-align: center;
}

/* ----- Initial reveal states ----- */
.terrace--ii .petal {
    transition-property: opacity, transform, width, height;
    transition-duration: 380ms, 480ms, 480ms, 480ms;
    transition-timing-function: var(--ease-still);
}

/* ----- Mobile ----- */
@media (max-width: 768px) {
    :root {
        --margin-side: 6vw;
        --hex-edge: 96px;
    }

    .rail {
        width: 32px;
    }

    .terrace {
        padding-left: calc(var(--margin-side) + 32px);
        padding-right: var(--margin-side);
    }

    .terrace-num {
        left: calc(var(--margin-side) + 32px);
        font-size: 10px;
    }

    .threshold-cell {
        width: 240px;
        height: 277px;
    }

    .wordmark {
        font-size: 22px;
    }

    .thesis {
        font-size: 17px;
    }

    .flower {
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 14px;
        align-items: center;
    }

    .petal {
        position: relative;
        left: auto !important;
        top: auto !important;
        width: 200px;
        height: 230px;
    }

    .petal.is-open {
        width: 280px;
        height: 320px;
    }

    .map-graph {
        height: 700px;
    }

    .node {
        width: 100px;
        height: 116px;
    }

    .node-icon {
        width: 32px;
        height: 32px;
    }

    .node-label {
        font-size: 9px;
    }

    .range-cells {
        gap: 12px;
    }

    .hex--small {
        width: 78px;
        height: 90px;
    }

    .coord-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: 90px;
    }

    .hex--coord {
        width: 72px;
        height: 83px;
    }

    .coord-grid > .hex--coord:nth-child(n+7) {
        transform: translateX(0);
    }

    .coord-grid > .hex--coord:nth-child(n+7):hover {
        transform: translateY(-2px);
    }

    .range-coords {
        flex-direction: column;
        gap: 4px;
        bottom: 16px;
    }
}
