/* ========================================
   graphers.dev - Hexagonal Crystalline Lattice
   ======================================== */

:root {
    --aged-vellum: #F5ECD7;
    --parchment-shadow: #E8D9B8;
    --walnut-bistre: #5C4A32;
    --iron-gall: #3A3127;
    --burnt-sienna: #A0522D;
    --oxidized-copper: #5B7B6A;
    --foxed-page: #C9B896;
    --lampblack: #1E1A14;
    --hex-size: clamp(180px, 20vw, 320px);
    --hex-gap: 6px;
    --ease-crystal: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-draw: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--aged-vellum);
    color: var(--walnut-bistre);
    font-family: 'Source Serif 4', serif;
    font-weight: 350;
    font-variation-settings: 'wght' 350, 'opsz' 16;
    line-height: 1.7;
    overflow-x: hidden;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Paper Grain --- */
.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: multiply;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* --- Typography --- */
h1 {
    font-family: 'Recursive', monospace;
    font-variation-settings: 'MONO' 0, 'CASL' 1, 'wght' 800, 'slnt' -12, 'CRSV' 1;
    font-size: clamp(2rem, 6vw, 5rem);
    letter-spacing: 0.02em;
    line-height: 1.2;
    color: var(--iron-gall);
}

h2 {
    font-family: 'Recursive', monospace;
    font-variation-settings: 'MONO' 0, 'CASL' 0.8, 'wght' 700, 'slnt' -8, 'CRSV' 1;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.02em;
    line-height: 1.2;
    color: var(--iron-gall);
    margin-bottom: 1rem;
}

p {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.7;
    letter-spacing: 0.015em;
    margin-bottom: 1rem;
    max-width: 38em;
}

a {
    color: var(--burnt-sienna);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--oxidized-copper);
}

/* --- Navigation --- */
.hex-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
}

.hex-nav-trigger {
    width: 36px;
    height: 36px;
    cursor: pointer;
}

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

.hex-nav-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    transition: opacity 0.4s ease, transform 0.4s var(--ease-crystal);
    max-width: 180px;
}

.hex-nav.open .hex-nav-menu {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.hex-nav-item {
    font-family: 'Recursive', monospace;
    font-variation-settings: 'MONO' 0, 'CASL' 1, 'wght' 500, 'slnt' 0, 'CRSV' 1;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--walnut-bistre);
    background: var(--parchment-shadow);
    padding: 6px 12px;
    clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
    display: block;
    text-align: center;
    transition: background 0.3s ease;
}

.hex-nav-item:hover {
    background: var(--foxed-page);
    color: var(--burnt-sienna);
}

/* --- Zones --- */
.zone {
    position: relative;
}

/* Zone 1: The Mark */
.zone-mark {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--aged-vellum);
}

.mark-hex-frame {
    position: relative;
    width: 85vmin;
    height: 85vmin;
    max-width: 600px;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mark-hex-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.mark-hex-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawHex 2s var(--ease-draw) forwards;
}

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

.mark-title {
    position: relative;
    z-index: 1;
}

.mark-guideline {
    width: 10px;
    height: 100px;
    margin-top: 2rem;
}

.guideline-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawLine 1.5s var(--ease-draw) 2s forwards;
}

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

/* --- Honeycomb Grid --- */
.honeycomb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--hex-gap);
    padding: 4rem 2rem;
}

.hex-row {
    display: flex;
    gap: var(--hex-gap);
    justify-content: center;
}

.hex-row-offset {
    transform: translateX(calc(var(--hex-size) / 2 + var(--hex-gap) / 2));
}

.hex-row-center {
    justify-content: center;
}

.hex-cell {
    width: var(--hex-size);
    height: calc(var(--hex-size) * 1.1547);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    opacity: 0;
    transform: scale(0.7);
    filter: blur(2px);
    transition: opacity 0.6s var(--ease-crystal), transform 0.6s var(--ease-crystal), filter 0.6s var(--ease-crystal);
}

.hex-cell.revealed {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

.hex-void {
    background: var(--aged-vellum);
}

.hex-void::before {
    content: "";
    position: absolute;
    width: 80%;
    height: 80%;
    background-image:
        repeating-linear-gradient(60deg, transparent, transparent 11px, rgba(201, 184, 150, 0.06) 11px, rgba(201, 184, 150, 0.06) 11.5px),
        repeating-linear-gradient(-60deg, transparent, transparent 11px, rgba(201, 184, 150, 0.06) 11px, rgba(201, 184, 150, 0.06) 11.5px);
}

.hex-content {
    background: var(--parchment-shadow);
    border: 1.5px solid var(--walnut-bistre);
    position: relative;
}

.hex-crystal {
    background: var(--foxed-page);
    position: relative;
}

.hex-text {
    font-family: 'Source Serif 4', serif;
    font-variation-settings: 'wght' 350, 'opsz' 16;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: var(--walnut-bistre);
    line-height: 1.5;
    max-width: none;
    margin: 0;
}

.hex-annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--burnt-sienna);
    display: block;
    margin-top: 0.5rem;
}

.crystal-svg {
    width: 80%;
    height: 80%;
}

/* Zone 2: The Line */
.zone-line {
    min-height: 120vh;
    padding: 6rem 0;
}

/* Zone 3: The Lattice */
.zone-lattice {
    min-height: 150vh;
    padding: 4rem 0;
    background: linear-gradient(180deg, var(--aged-vellum) 0%, var(--parchment-shadow) 50%, var(--aged-vellum) 100%);
}

.honeycomb-dense .hex-row {
    margin-bottom: calc(var(--hex-gap) - var(--hex-size) * 0.13);
}

/* Zone 4: The Facet */
.zone-facet {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.facet-hex {
    width: 70vmin;
    max-width: 500px;
}

.facet-svg {
    width: 100%;
    height: auto;
}

.facet-piece {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.facet-piece.revealed {
    opacity: 1;
}

/* Zone 5: The Network */
.zone-network {
    min-height: 120vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.network-graph {
    width: 90%;
    max-width: 800px;
}

.network-svg {
    width: 100%;
    height: auto;
}

.network-node {
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: center;
}

.network-node:hover {
    transform: scale(1.15);
}

.network-edge {
    stroke: var(--foxed-page);
    stroke-width: 0.8;
    filter: url(#hand-ink);
}

.network-label {
    font-family: 'Caveat', cursive;
    font-size: 11px;
    fill: var(--burnt-sienna);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.network-node:hover + .network-label,
.network-node:hover ~ .network-label {
    opacity: 1;
}

/* Zone 6: The Signature */
.zone-signature {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    background: var(--aged-vellum);
}

.honeycomb-sparse .hex-cell {
    --hex-size: clamp(160px, 18vw, 280px);
    width: var(--hex-size);
    height: calc(var(--hex-size) * 1.1547);
}

.sig-text {
    font-family: 'Recursive', monospace;
    font-variation-settings: 'MONO' 1, 'CASL' 0, 'wght' 400, 'slnt' 0, 'CRSV' 0;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: var(--iron-gall);
}

.hex-identity {
    background: var(--aged-vellum);
    border-color: var(--foxed-page);
}

.hex-monogram {
    background: var(--parchment-shadow);
    border-color: var(--burnt-sienna);
}

.monogram-svg {
    width: 70%;
    height: 70%;
}

/* --- Focal Hex Hover Glow --- */
.hex-crystal.revealed:hover {
    box-shadow: 0 0 20px rgba(91, 123, 106, 0.15);
    transition: box-shadow 0.2s ease;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --hex-size: clamp(120px, 35vw, 180px);
    }

    .hex-row-offset {
        transform: translateX(calc(var(--hex-size) / 2));
    }

    .mark-hex-frame {
        width: 90vmin;
        height: 90vmin;
    }

    .hex-nav {
        top: 12px;
        left: 12px;
    }
}
