/* =======================================================================
   ggaji.com — Isometric Paper Workshop
   Hexagonal-honeycomb / isometric / eclectic-hybrid / monochrome
   ======================================================================= */

:root {
    /* Monochrome paper-aging palette */
    --paper-white: #F2EDE4;
    --ink-black: #1A1A1A;
    --graphite: #5C5C5C;
    --foxing-brown: #C4A87C;
    --crease-shadow: #D8D0C4;
    --blueprint-trace: #8B9EAE;
    --burn-edge: #3D3226;

    /* Typography stacks */
    --font-display: "Dela Gothic One", "Inter", system-ui, sans-serif;
    --font-body: "Literata", "Lora", Georgia, serif;
    --font-mono: "IBM Plex Mono", "Space Mono", ui-monospace, monospace;

    /* Hex geometry */
    --hex-size: clamp(180px, 22vw, 320px);
    --hex-height: calc(var(--hex-size) * 0.8660); /* sin(60°) */
    --hex-gap: 6px;

    /* Shake animation */
    --shake-amp: 3px;
    --shake-dur: 120ms;
    --shake-ease: cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    background: var(--paper-white);
    color: var(--ink-black);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    font-variation-settings: "opsz" 14;
}

body {
    position: relative;
    background-color: var(--paper-white);
    background-image:
        /* yellowing gradient */
        radial-gradient(ellipse at 30% 20%, rgba(196, 168, 124, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(196, 168, 124, 0.08) 0%, transparent 50%),
        /* faint ruled horizontal lines */
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 31px,
            rgba(92, 92, 92, 0.035) 31px,
            rgba(92, 92, 92, 0.035) 32px
        ),
        /* SVG grain noise */
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.23  0 0 0 0 0.20  0 0 0 0 0.15  0 0 0 0.12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-attachment: fixed, fixed, fixed, fixed;
    background-size: auto, auto, auto, 160px 160px;
}

/* =============================================================
   Paper texture overlays
   ============================================================= */

.paper-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='g'><feTurbulence type='turbulence' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.24  0 0 0 0 0.20  0 0 0 0 0.15  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
    background-size: 220px 220px;
    mix-blend-mode: multiply;
    opacity: 0.55;
}

.foxing-spots {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.fox-spot {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--s);
    height: var(--s);
    transform: translate(-50%, -50%);
    background: radial-gradient(
        circle at 40% 40%,
        var(--foxing-brown) 0%,
        rgba(196, 168, 124, 0.5) 35%,
        transparent 70%
    );
    opacity: var(--o);
    filter: blur(2px);
    border-radius: 50%;
}

.fold-creases {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.crease {
    position: absolute;
    background: var(--crease-shadow);
    opacity: 0.55;
}

.crease-h {
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(to bottom,
        transparent,
        rgba(216, 208, 196, 0.6) 40%,
        rgba(92, 92, 92, 0.35) 50%,
        rgba(216, 208, 196, 0.6) 60%,
        transparent);
    box-shadow: 0 1px 4px rgba(216, 208, 196, 0.4);
}

.crease-v {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: linear-gradient(to right,
        transparent,
        rgba(216, 208, 196, 0.6) 40%,
        rgba(92, 92, 92, 0.35) 50%,
        rgba(216, 208, 196, 0.6) 60%,
        transparent);
    box-shadow: 1px 0 4px rgba(216, 208, 196, 0.4);
}

.coffee-ring {
    position: fixed;
    right: 8%;
    bottom: 12%;
    width: 200px;
    height: 200px;
    border: 6px solid var(--foxing-brown);
    border-radius: 50%;
    opacity: 0.12;
    pointer-events: none;
    z-index: 2;
    filter: blur(0.6px);
    box-shadow:
        inset 0 0 24px rgba(196, 168, 124, 0.15),
        0 0 30px rgba(196, 168, 124, 0.08);
}

.edge-burn {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    box-shadow: inset 0 0 180px 30px rgba(61, 50, 38, 0.20);
}

/* =============================================================
   Fixed header and coord readout (technical annotations)
   ============================================================= */

.fixed-header {
    position: fixed;
    top: 18px;
    right: 28px;
    z-index: 20;
    display: flex;
    gap: 22px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--graphite);
    text-transform: uppercase;
    pointer-events: none;
}

.header-stamp {
    padding: 4px 10px;
    border: 1px dashed var(--graphite);
    background: rgba(242, 237, 228, 0.6);
    position: relative;
}

.header-stamp::before {
    content: "+";
    position: absolute;
    top: -6px;
    left: -6px;
    color: var(--graphite);
    font-size: 0.8rem;
    opacity: 0.4;
}

.coord-readout {
    position: fixed;
    bottom: 20px;
    left: 22px;
    z-index: 20;
    display: flex;
    gap: 18px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--graphite);
    text-transform: uppercase;
    pointer-events: none;
    background: rgba(242, 237, 228, 0.7);
    border: 1px solid var(--crease-shadow);
    padding: 6px 12px;
}

.coord-axis em {
    font-style: normal;
    color: var(--ink-black);
    margin-left: 4px;
    font-weight: 500;
}

/* =============================================================
   Workshop desk and isometric plane
   ============================================================= */

.workshop-desk {
    position: relative;
    z-index: 5;
    width: 100%;
    min-height: 100vh;
    padding: 140px 4vw 160px;
    perspective: 1600px;
    perspective-origin: 50% 40%;
    scroll-snap-type: y mandatory;
    overflow-y: auto;
}

.desk-plane {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--hex-gap));
    transform-style: preserve-3d;
    transform:
        rotateX(48deg)
        rotateZ(-30deg)
        translateZ(-40px);
    transform-origin: 50% 30%;
    transition: transform 600ms ease;
}

/* =============================================================
   Hexagonal grid rows
   ============================================================= */

.hex-row {
    display: flex;
    gap: var(--hex-gap);
    scroll-snap-align: start;
    margin: calc(var(--hex-size) * -0.25) 0;
    position: relative;
}

.hex-row.row-odd {
    transform: translateX(calc(var(--hex-size) * 0.5 + var(--hex-gap) * 0.5));
}

/* =============================================================
   Hexagonal cells (honeycomb tiles)
   ============================================================= */

.hex-cell {
    position: relative;
    width: var(--hex-size);
    height: var(--hex-height);
    clip-path: polygon(
        25% 0%,
        75% 0%,
        100% 50%,
        75% 100%,
        25% 100%,
        0% 50%
    );
    background: var(--paper-white);
    background-image:
        radial-gradient(ellipse at 30% 30%, rgba(196, 168, 124, 0.08) 0%, transparent 60%),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='1' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.23  0 0 0 0 0.20  0 0 0 0 0.15  0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
    cursor: default;
    transform-style: preserve-3d;
    opacity: 0;
    animation: stamp-in 600ms var(--shake-ease) forwards;
    transition: transform 200ms ease-out, filter 200ms ease-out;
    will-change: transform, opacity;
}

/* Dashed hex outline via SVG pseudo */
.hex-cell::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--crease-shadow), var(--crease-shadow));
    background-size: 100% 100%;
    -webkit-mask:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 86.6' preserveAspectRatio='none'><polygon points='25,0 75,0 100,43.3 75,86.6 25,86.6 0,43.3' fill='none' stroke='black' stroke-width='2' stroke-dasharray='4,8'/></svg>") center / 100% 100% no-repeat;
            mask:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 86.6' preserveAspectRatio='none'><polygon points='25,0 75,0 100,43.3 75,86.6 25,86.6 0,43.3' fill='none' stroke='black' stroke-width='2' stroke-dasharray='4,8'/></svg>") center / 100% 100% no-repeat;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 200ms ease, background-image 200ms ease;
}

/* Cross-hair registration marks at "vertices" */
.hex-cell::after {
    content: "+ + + + + +";
    position: absolute;
    inset: 0;
    font-family: var(--font-mono);
    color: var(--graphite);
    font-size: 0.75rem;
    opacity: 0.3;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px;
}

.hex-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 18% 22%;
    /* counter-rotate for readability */
    transform: rotateZ(30deg) rotateX(-48deg);
    transform-origin: center;
    transform-style: preserve-3d;
}

/* Empty (rest) cells - keep dashed outline, softer bg */
.hex-cell.hex-empty {
    background: transparent;
    background-image:
        radial-gradient(ellipse at 40% 30%, rgba(216, 208, 196, 0.2) 0%, transparent 70%);
}

.hex-cell.hex-empty::after {
    content: "·";
    font-size: 2rem;
    opacity: 0.35;
    display: block;
    justify-content: center;
    padding: 0;
    line-height: var(--hex-height);
    text-align: center;
}

/* Solid border for content hexes */
.hex-cell.hex-text::before,
.hex-cell.hex-illustration::before,
.hex-cell.hex-annotation::before,
.hex-cell.hex-title::before,
.hex-cell.hex-compass::before {
    background-image: linear-gradient(var(--ink-black), var(--ink-black));
    -webkit-mask:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 86.6' preserveAspectRatio='none'><polygon points='25,0 75,0 100,43.3 75,86.6 25,86.6 0,43.3' fill='none' stroke='black' stroke-width='1.5'/></svg>") center / 100% 100% no-repeat;
            mask:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 86.6' preserveAspectRatio='none'><polygon points='25,0 75,0 100,43.3 75,86.6 25,86.6 0,43.3' fill='none' stroke='black' stroke-width='1.5'/></svg>") center / 100% 100% no-repeat;
    opacity: 0.85;
}

/* Hover lift + blueprint accent */
.hex-cell:not(.hex-empty):hover {
    transform: translateZ(24px) scale(1.03);
    z-index: 10;
    filter: drop-shadow(4px 8px 12px rgba(61, 50, 38, 0.25));
    animation: hover-jitter 80ms var(--shake-ease) 1;
}

.hex-cell:not(.hex-empty):hover::before {
    background-image: linear-gradient(var(--blueprint-trace), var(--blueprint-trace));
    opacity: 1;
}

/* =============================================================
   Cell content typography
   ============================================================= */

.hex-heading,
.hex-heading-sm,
.site-title {
    font-family: var(--font-display);
    color: var(--ink-black);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: 1;
}

.site-title {
    font-size: clamp(1.8rem, 4vw, 3.6rem);
    margin-bottom: 0.3em;
}

.site-subtitle {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 1.5vw, 1.3rem);
    letter-spacing: 0.3em;
    color: var(--graphite);
}

.hex-heading {
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    margin-bottom: 0.4em;
}

.hex-heading-sm {
    font-size: clamp(0.95rem, 1.7vw, 1.3rem);
    margin-bottom: 0.5em;
}

.hex-annot {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--graphite);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 0.8em;
    border-bottom: 1px dashed var(--graphite);
    padding-bottom: 3px;
    display: inline-block;
}

.hex-body {
    font-family: var(--font-body);
    font-size: clamp(0.7rem, 0.95vw, 0.85rem);
    line-height: 1.5;
    color: var(--ink-black);
    font-variation-settings: "opsz" 14;
    max-width: 90%;
}

.hex-footer {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--graphite);
    letter-spacing: 0.18em;
    margin-top: 0.6em;
    text-transform: uppercase;
}

/* Annotation cells */
.hex-annotation .hex-inner {
    padding: 22% 24%;
    gap: 0.1em;
}

.annot-line {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--graphite);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-top: 0.3em;
}

.annot-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-black);
    letter-spacing: 0.08em;
    font-weight: 500;
}

/* =============================================================
   Compass cell + nav
   ============================================================= */

.hex-compass {
    cursor: pointer;
}

.compass-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
}

.compass-glyph {
    font-size: clamp(2rem, 4vw, 3.2rem);
    color: var(--blueprint-trace);
    line-height: 1;
    transition: transform 400ms ease, color 200ms ease;
}

.hex-compass.is-active .compass-glyph {
    transform: rotate(225deg);
    color: var(--ink-black);
}

.compass-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--graphite);
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.compass-nav {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform: translate(-50%, -50%);
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

.compass-nav.is-open {
    opacity: 1;
    pointer-events: auto;
}

.nav-hex {
    position: absolute;
    width: calc(var(--hex-size) * 0.85);
    height: calc(var(--hex-height) * 0.85);
    top: 50%;
    left: 50%;
    transform:
        translate(-50%, -50%)
        rotate(var(--angle))
        translate(calc(var(--hex-size) * 1.0), 0)
        rotate(calc(var(--angle) * -1))
        rotateY(180deg);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: var(--paper-white);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--ink-black);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    transition: transform 400ms ease-out, background 200ms ease;
    border: 1px solid var(--ink-black);
}

.compass-nav.is-open .nav-hex {
    transform:
        translate(-50%, -50%)
        rotate(var(--angle))
        translate(calc(var(--hex-size) * 1.0), 0)
        rotate(calc(var(--angle) * -1))
        rotateY(0deg);
    animation: nav-pulse 300ms ease-out 400ms 1;
}

.nav-hex:hover {
    background: var(--blueprint-trace);
    color: var(--paper-white);
}

.nav-hex span {
    display: block;
}

/* =============================================================
   Isometric SVG illustrations
   ============================================================= */

.iso-svg {
    width: 100%;
    height: auto;
    max-width: 180px;
    display: block;
}

/* =============================================================
   Animations
   ============================================================= */

@keyframes stamp-in {
    0% {
        opacity: 0;
        transform: translateY(80px) scale(0.9);
    }
    70% {
        opacity: 1;
        transform: translateY(-6px) translateX(var(--shake-amp)) scale(1.01);
    }
    80% {
        transform: translateY(0) translateX(calc(var(--shake-amp) * -1)) scale(1);
    }
    90% {
        transform: translateY(0) translateX(calc(var(--shake-amp) * 0.5));
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateX(0) scale(1);
    }
}

@keyframes hover-jitter {
    0%   { margin-left: 0; }
    25%  { margin-left: calc(var(--shake-amp) * -0.5); }
    50%  { margin-left: calc(var(--shake-amp) * 0.5); }
    75%  { margin-left: calc(var(--shake-amp) * -0.25); }
    100% { margin-left: 0; }
}

@keyframes shake-error {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(var(--shake-amp)); }
    40% { transform: translateX(calc(var(--shake-amp) * -1)); }
    60% { transform: translateX(calc(var(--shake-amp) * 0.6)); }
    80% { transform: translateX(calc(var(--shake-amp) * -0.3)); }
}

@keyframes nav-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stagger the stamp-in animation (radial from center) */
.hex-row[data-row="1"] .hex-cell { animation-delay: calc(var(--delay, 0) * 80ms); }
.hex-row[data-row="2"] .hex-cell:nth-child(1) { animation-delay: 0ms; }
.hex-row[data-row="2"] .hex-cell:nth-child(2) { animation-delay: 80ms; }
.hex-row[data-row="2"] .hex-cell:nth-child(3) { animation-delay: 160ms; }
.hex-row[data-row="2"] .hex-cell:nth-child(4) { animation-delay: 240ms; }
.hex-row[data-row="2"] .hex-cell:nth-child(5) { animation-delay: 320ms; }
.hex-row[data-row="2"] .hex-cell:nth-child(6) { animation-delay: 400ms; }

.hex-row[data-row="1"] .hex-cell:nth-child(1) { animation-delay: 40ms; }
.hex-row[data-row="1"] .hex-cell:nth-child(2) { animation-delay: 120ms; }
.hex-row[data-row="1"] .hex-cell:nth-child(3) { animation-delay: 200ms; }
.hex-row[data-row="1"] .hex-cell:nth-child(4) { animation-delay: 280ms; }
.hex-row[data-row="1"] .hex-cell:nth-child(5) { animation-delay: 360ms; }

.hex-row[data-row="3"] .hex-cell { animation-delay: calc((1 + var(--nth, 0)) * 80ms + 400ms); }
.hex-row[data-row="4"] .hex-cell { animation-delay: calc((1 + var(--nth, 0)) * 80ms + 600ms); }
.hex-row[data-row="5"] .hex-cell { animation-delay: calc((1 + var(--nth, 0)) * 80ms + 800ms); }
.hex-row[data-row="6"] .hex-cell { animation-delay: calc((1 + var(--nth, 0)) * 80ms + 1000ms); }

/* Rows that scroll into view get a shake-snap */
.hex-row.is-in-view .hex-cell {
    animation: stamp-in 500ms var(--shake-ease) forwards;
}

.hex-row.is-shake-settle {
    animation: shake-error 200ms var(--shake-ease) 1;
}

/* =============================================================
   Responsive: collapse to stacked single-column honeycomb
   ============================================================= */

@media (max-width: 900px) {
    :root {
        --hex-size: clamp(160px, 60vw, 260px);
    }

    .desk-plane {
        transform: rotateX(25deg) rotateZ(-10deg);
        transform-origin: 50% 20%;
    }

    .hex-row {
        flex-direction: column;
        align-items: center;
        gap: calc(var(--hex-gap) * 4);
        margin: calc(var(--hex-gap) * 2) 0;
    }

    .hex-row.row-odd {
        transform: translateX(calc(var(--hex-size) * 0.18));
    }

    .hex-row.row-even {
        transform: translateX(calc(var(--hex-size) * -0.18));
    }

    .fixed-header {
        top: 12px;
        right: 12px;
        gap: 8px;
        font-size: 0.6rem;
    }

    .coord-readout {
        bottom: 12px;
        left: 12px;
        font-size: 0.6rem;
        gap: 10px;
    }

    .workshop-desk {
        padding: 100px 2vw 120px;
    }
}

@media (max-width: 520px) {
    .fixed-header .header-stamp:nth-child(2) {
        display: none;
    }
}

/* =============================================================
   Print / reduced motion
   ============================================================= */

@media (prefers-reduced-motion: reduce) {
    .hex-cell {
        animation: none !important;
        opacity: 1 !important;
    }
    .hex-row.is-shake-settle {
        animation: none;
    }
}
