/* ========================================
   riron.net — Memphis Honeycomb Design
   Colors: #faf6f0, #1a1a2e, #e85d3a, #2ec4b6, #f0b429, #9b8ec4, #d4c8b8, #2d2d3f, #8a8a9e, #f0e6d8
   Fonts: Rubik, Nunito Sans, Space Mono
======================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #faf6f0;
    color: #2d2d3f;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw + 0.5rem, 1.15rem);
    line-height: 1.65;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ========================================
   Layer 1: Background hex wallpaper
======================================== */
.layer-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    animation: fadeInBg 800ms 200ms ease-out forwards;
}

@keyframes fadeInBg {
    to { opacity: 1; }
}

.layer-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='346'%3E%3Cpolygon points='200,0 400,100 400,246 200,346 0,246 0,100' fill='none' stroke='%23f0e6d8' stroke-width='1' opacity='0.2'/%3E%3C/svg%3E");
    background-size: 400px 346px;
    animation: driftBg 60s linear infinite;
}

@keyframes driftBg {
    from { transform: translateX(0); }
    to { transform: translateX(-400px); }
}

/* ========================================
   Layer 3: Memphis overlay
======================================== */
.layer-memphis {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    animation: popInMemphis 400ms 800ms ease-out forwards;
}

@keyframes popInMemphis {
    0% { opacity: 0; transform: scale(0); }
    70% { transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

/* Squiggly lines */
.memphis-squiggle {
    position: absolute;
    width: clamp(150px, 25vw, 300px);
    height: 40px;
    opacity: 0.4;
}

.sq-1 { top: 8%; left: 5%; transform: rotate(-5deg); }
.sq-2 { top: 35%; right: 3%; transform: rotate(8deg); }
.sq-3 { top: 62%; left: 2%; transform: rotate(-3deg); }
.sq-4 { top: 88%; right: 8%; transform: rotate(12deg); }

/* Floating triangles */
.memphis-triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-left: clamp(10px, 2vw, 20px) solid transparent;
    border-right: clamp(10px, 2vw, 20px) solid transparent;
    border-bottom: clamp(17px, 3.5vw, 35px) solid #2ec4b6;
    opacity: 0.5;
    animation: rotateTri 20s linear infinite;
}

@keyframes rotateTri {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tri-1 { top: 5%; left: 70%; animation-duration: 18s; }
.tri-2 { top: 22%; left: 15%; animation-duration: 24s; animation-direction: reverse; }
.tri-3 { top: 45%; right: 10%; animation-duration: 22s; }
.tri-4 { top: 60%; left: 8%; animation-duration: 26s; animation-direction: reverse; }
.tri-5 { top: 78%; right: 20%; animation-duration: 20s; }
.tri-6 { top: 92%; left: 40%; animation-duration: 28s; animation-direction: reverse; }

/* Zigzag borders */
.memphis-zigzag {
    position: absolute;
    width: clamp(80px, 12vw, 140px);
    height: 20px;
    opacity: 0.5;
}

.zz-1 { top: 18%; right: 15%; }
.zz-2 { top: 50%; left: 10%; transform: rotate(90deg); }
.zz-3 { top: 75%; right: 5%; transform: rotate(-15deg); }

/* Dot grids */
.memphis-dots {
    position: absolute;
    width: 60px;
    height: 60px;
    background-image: radial-gradient(circle, #f0b429 3px, transparent 3px);
    background-size: 12px 12px;
    opacity: 0.4;
}

.dots-1 { top: 12%; left: 45%; }
.dots-2 { top: 55%; right: 25%; }
.dots-3 { top: 82%; left: 30%; }

/* ========================================
   Layer 2: Content honeycomb
======================================== */
.layer-content {
    position: relative;
    z-index: 10;
    padding: clamp(40px, 8vh, 100px) clamp(16px, 4vw, 60px);
}

.honeycomb {
    max-width: 1200px;
    margin: 0 auto;
}

/* Hex rows */
.hex-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: -30px;
}

.hex-row-offset {
    margin-left: calc(clamp(180px, 22vw, 320px) / 2 + 6px);
}

/* Hex cells */
.hex-cell {
    width: clamp(180px, 22vw, 320px);
    height: calc(clamp(180px, 22vw, 320px) * 1.1547);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    flex-shrink: 0;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hex-cell.hex-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Decorative hex fills */
.hex-fill-coral { background: #e85d3a; }
.hex-fill-teal { background: #2ec4b6; }
.hex-fill-mustard { background: #f0b429; }
.hex-fill-lavender { background: #9b8ec4; }
.hex-fill-ink { background: #1a1a2e; }

.hex-decorative {
    opacity: 0;
    transform: translateY(40px);
}
.hex-decorative.hex-visible {
    opacity: 0.6;
    transform: translateY(0);
}

/* Content hex cells */
.hex-content {
    background: #faf6f0;
    border: 2px solid #d4c8b8;
    cursor: pointer;
    box-shadow: inset 0 2px 8px rgba(26, 26, 46, 0.08);
    overflow: hidden;
}

.hex-content::before {
    content: '';
    position: absolute;
    inset: -4px;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: transparent;
    transition: background 0.3s ease;
    z-index: -1;
}

.hex-content:hover {
    transform: scale(0.97);
    box-shadow: inset 0 4px 12px rgba(26, 26, 46, 0.15);
}

.hex-content:hover::before {
    background: #e85d3a;
}

.hex-content:hover .iso-icon {
    transform: perspective(400px) rotateY(15deg);
}

/* Hex inner content */
.hex-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 15%;
    text-align: center;
    transition: opacity 0.3s ease;
}

.hex-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 0.9vw + 0.3rem, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #8a8a9e;
    margin-bottom: 4px;
    display: block;
}

.hex-icon {
    width: clamp(64px, 10vw, 120px);
    height: clamp(64px, 10vw, 120px);
    margin: 8px 0;
}

.iso-icon {
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
}

.hex-title {
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2vw + 0.3rem, 1.6rem);
    color: #1a1a2e;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 4px;
}

.hex-body {
    font-family: 'Nunito Sans', sans-serif;
    font-size: clamp(0.7rem, 0.8vw + 0.3rem, 0.9rem);
    color: #2d2d3f;
    line-height: 1.5;
}

/* Expanded content (hidden by default) */
.hex-expanded-content {
    display: none;
    padding: 15%;
    text-align: center;
}

.hex-expanded-content .hex-title {
    font-weight: 900;
    font-size: clamp(1.4rem, 3vw + 0.5rem, 2.4rem);
    margin-bottom: 12px;
}

.hex-expanded-content .hex-body {
    font-size: clamp(0.85rem, 1vw + 0.4rem, 1.05rem);
    line-height: 1.65;
    margin-bottom: 16px;
}

.hex-explore {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 0.9vw + 0.3rem, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #e85d3a;
}

/* Expanded state */
.hex-cell.hex-expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    width: clamp(320px, 60vw, 700px);
    height: clamp(370px, 60vw, 810px);
    z-index: 100;
    background: #faf6f0;
    box-shadow: 0 20px 60px rgba(26, 26, 46, 0.25);
    opacity: 1 !important;
    transition: all 0.5s ease-in-out;
    cursor: default;
}

.hex-cell.hex-expanded .hex-inner {
    display: none;
}

.hex-cell.hex-expanded .hex-expanded-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.hex-cell.hex-expanded .hex-close {
    display: block;
}

/* Close button */
.hex-close {
    display: none;
    position: absolute;
    top: 12%;
    right: 18%;
    width: 36px;
    height: 36px;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: #e85d3a;
    color: #faf6f0;
    border: none;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 36px;
    text-align: center;
    z-index: 110;
}

/* Dimmed siblings */
.honeycomb.has-expanded .hex-cell:not(.hex-expanded) {
    opacity: 0.3 !important;
    transform: scale(0.95);
    pointer-events: none;
    transition: all 0.5s ease-in-out;
}

/* ========================================
   Hex navigation cluster
======================================== */
.hex-nav {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, 32px);
    grid-template-rows: repeat(2, 32px);
    gap: 4px;
}

.hex-nav-btn {
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.hex-nav-btn:hover {
    transform: scale(1.15);
}

.hex-nav-btn svg polygon {
    transition: stroke 0.3s ease;
}

/* Nav pulse animation */
@keyframes navPulse {
    0% { stroke: #e85d3a; }
    25% { stroke: #2ec4b6; }
    50% { stroke: #f0b429; }
    75% { stroke: #9b8ec4; }
    100% { stroke: #e85d3a; }
}

.hex-nav-btn:nth-child(1) svg polygon { animation: navPulse 8s linear infinite; }
.hex-nav-btn:nth-child(2) svg polygon { animation: navPulse 8s 1.3s linear infinite; }
.hex-nav-btn:nth-child(3) svg polygon { animation: navPulse 8s 2.6s linear infinite; }
.hex-nav-btn:nth-child(4) svg polygon { animation: navPulse 8s 3.9s linear infinite; }
.hex-nav-btn:nth-child(5) svg polygon { animation: navPulse 8s 5.2s linear infinite; }
.hex-nav-btn:nth-child(6) svg polygon { animation: navPulse 8s 6.5s linear infinite; }

/* ========================================
   Glitch overlay
======================================== */
.glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
}

.glitch-overlay.glitch-active {
    animation: glitchShutter 80ms ease-out forwards;
}

@keyframes glitchShutter {
    0% { opacity: 1; transform: translateX(3px); background: rgba(232, 93, 58, 0.03); }
    50% { transform: translateX(-3px); background: rgba(46, 196, 182, 0.03); }
    100% { opacity: 0; transform: translateX(0); background: transparent; }
}

/* ========================================
   Typewriter effect
======================================== */
.typewriter-char {
    opacity: 0;
    transition: opacity 0.05s ease;
}

.typewriter-char.visible {
    opacity: 1;
}

/* ========================================
   Responsive: Tablet
======================================== */
@media (max-width: 1024px) {
    .hex-row {
        gap: 8px;
    }
    .hex-row-offset {
        margin-left: calc(clamp(180px, 22vw, 320px) / 2 + 4px);
    }
}

/* ========================================
   Responsive: Mobile
======================================== */
@media (max-width: 768px) {
    .hex-row {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: -20px;
        justify-content: center;
    }

    .hex-row-offset {
        margin-left: calc(clamp(140px, 40vw, 200px) / 2);
    }

    .hex-cell {
        width: clamp(140px, 40vw, 200px);
        height: calc(clamp(140px, 40vw, 200px) * 1.1547);
    }

    .memphis-triangle { transform: scale(1.5); }
    .memphis-squiggle { display: none; }
    .memphis-zigzag:nth-child(n+3) { display: none; }
    .memphis-dots:nth-child(n+3) { display: none; }

    .hex-cell.hex-expanded {
        width: 90vw;
        height: calc(90vw * 1.1547);
    }

    .hex-nav {
        bottom: 16px;
        right: 16px;
        grid-template-columns: repeat(3, 28px);
        grid-template-rows: repeat(2, 28px);
        gap: 3px;
    }

    .hex-nav-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .hex-row {
        flex-direction: column;
        align-items: center;
        gap: 6px;
        margin-bottom: -15px;
    }

    .hex-row-offset {
        margin-left: 0;
    }

    .hex-cell {
        width: clamp(200px, 70vw, 280px);
        height: calc(clamp(200px, 70vw, 280px) * 1.1547);
    }

    .hex-decorative:nth-child(even) {
        display: none;
    }
}
