/* ============================================
   riron.net — A Study in Electric Thought
   Aesthetic: light-academia + dark-neon
   Layout: hexagonal-honeycomb
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --midnight-ink: #0a0a12;
    --deep-library: #12111e;
    --parchment-glow: #f0e6d3;
    --weathered-stone: #b8b0a4;
    --warm-ivory: #e0d6c8;
    --electric-cyan: #00f0ff;
    --violet-bloom: #c084fc;
    --amber-signal: #f59e0b;
    --graphite-edge: #2a2938;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    --font-accent: 'Space Grotesk', sans-serif;

    --hex-size: 280px;
    --hex-gap: 6px;
}

html {
    scroll-behavior: smooth;
    background: var(--midnight-ink);
    color: var(--weathered-stone);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.72;
    overflow-x: hidden;
}

body {
    background: var(--midnight-ink);
    min-height: 100vh;
}

/* --- Film Grain Overlay --- */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.07;
    mix-blend-mode: overlay;
}

#grain-svg {
    width: 100%;
    height: 100%;
}

/* --- Hexagonal Bokeh Background --- */
#bokeh-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bokeh-hex {
    position: absolute;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    filter: blur(20px);
    opacity: 0;
    animation: bokeh-float linear infinite;
}

@keyframes bokeh-float {
    0% {
        transform: translateY(0);
        opacity: 0;
    }
    10% {
        opacity: var(--bokeh-opacity, 0.04);
    }
    90% {
        opacity: var(--bokeh-opacity, 0.04);
    }
    100% {
        transform: translateY(-110vh);
        opacity: 0;
    }
}

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

.nav-trigger {
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.nav-trigger:hover {
    transform: scale(1.1);
}

.nav-honeycomb {
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(2, 48px);
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: top left;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#hex-nav.active .nav-trigger {
    opacity: 0;
    pointer-events: none;
}

#hex-nav.active .nav-honeycomb {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.nav-hex {
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--deep-library);
    border: none;
    text-decoration: none;
    transition: background 0.3s ease;
    position: relative;
}

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

.nav-hex:hover::before {
    background: var(--electric-cyan);
}

.nav-hex:hover {
    background: var(--midnight-ink);
}

.nav-hex-label {
    font-family: var(--font-accent);
    font-size: 0.5rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--electric-cyan);
    text-decoration: none;
}

/* --- Amber Punctuation --- */
.amber {
    color: var(--amber-signal);
}

/* --- ATRIUM SECTION --- */
.atrium-section {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--midnight-ink);
    position: relative;
    overflow: hidden;
}

.atrium-hex-frame {
    position: relative;
    width: min(80vw, 700px);
    height: min(80vw, 700px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.atrium-hex-border {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0;
    animation: atrium-border-in 1.2s 0.4s ease-out forwards;
}

.atrium-hex-border::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, var(--electric-cyan), var(--violet-bloom), var(--electric-cyan));
    background-size: 200% 200%;
    animation: gradient-cycle 6s linear infinite;
}

.atrium-hex-border::after {
    content: '';
    position: absolute;
    inset: 2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--midnight-ink);
}

@keyframes gradient-cycle {
    0% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

@keyframes atrium-border-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.atrium-hex-content {
    position: relative;
    z-index: 2;
    text-align: center;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    color: var(--parchment-glow);
    line-height: 1.1;
    position: relative;
    z-index: 3;
}

.hero-title .char {
    display: inline-block;
    will-change: transform, opacity;
}

.hero-subtitle {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--electric-cyan);
    margin-top: 1.5rem;
    position: relative;
    z-index: 3;
    overflow: hidden;
}

.hero-subtitle .char {
    display: inline-block;
    opacity: 0;
}

/* --- City Skyline --- */
.city-skyline {
    position: absolute;
    bottom: 15%;
    left: 10%;
    right: 10%;
    height: 60%;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.city-skyline-back {
    opacity: 0.3;
    transform: scale(0.6);
    transform-origin: bottom center;
    bottom: 18%;
    z-index: 0;
}

.city-skyline-front {
    z-index: 1;
    transform: translateY(100%);
    animation: skyline-rise 0.8s 1.6s ease-out forwards;
}

.city-skyline-back {
    transform: scale(0.6) translateY(100%);
    animation: skyline-rise-back 0.8s 1.8s ease-out forwards;
}

@keyframes skyline-rise {
    to { transform: translateY(0); }
}

@keyframes skyline-rise-back {
    to { transform: scale(0.6) translateY(0); }
}

.building {
    background: var(--deep-library);
    position: relative;
    flex-shrink: 0;
}

.building-window {
    position: absolute;
    width: 4px;
    height: 6px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.building-window.lit {
    opacity: 1;
}

/* --- STACKS SECTION (Honeycomb Grid) --- */
.stacks-section {
    position: relative;
    z-index: 1;
    padding: 80px 0 120px;
    min-height: 100vh;
}

.honeycomb-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.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%);
    margin: calc(var(--hex-gap) * -2) var(--hex-gap);
    position: relative;
    transform: scale(0);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.hex-cell.revealed {
    transform: scale(1);
}

.hex-cell:nth-child(even) {
    margin-top: calc(var(--hex-size) * 0.5774 * -1 + var(--hex-gap));
}

.hex-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--graphite-edge);
    transition: background 0.3s ease;
}

.hex-cell:hover::before {
    background: var(--electric-cyan);
}

.hex-cell-inner {
    position: absolute;
    inset: 2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    text-align: center;
    transition: transform 0.3s ease;
}

.hex-cell--primary .hex-cell-inner {
    background: var(--midnight-ink);
}

.hex-cell--secondary .hex-cell-inner {
    background: var(--deep-library);
}

.hex-cell--accent .hex-cell-inner {
    background: var(--midnight-ink);
    border: none;
}

.hex-cell--marginalia .hex-cell-inner {
    background: var(--deep-library);
    padding: 45px 35px;
}

.hex-cell--wide {
    width: calc(var(--hex-size) * 1.4);
    height: calc(var(--hex-size) * 1.1547 * 1.2);
}

/* Hex cell magnetic hover effect */
.hex-cell {
    --mx: 0;
    --my: 0;
}

.hex-cell:hover .hex-cell-inner {
    transform: translate(calc(var(--mx) * 2px), calc(var(--my) * 2px));
}

/* --- Hex Cell Typography --- */
.hex-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.75rem);
    letter-spacing: -0.02em;
    color: var(--parchment-glow);
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.hex-heading .char {
    display: inline-block;
    will-change: transform, opacity;
    opacity: 0;
    transform: translateY(30px);
}

.hex-heading .char.animated {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.hex-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.72;
    color: var(--weathered-stone);
}

.hex-label {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.6rem, 0.8vw, 0.7rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--electric-cyan);
    margin-bottom: 0.75rem;
    display: block;
}

.hex-quote {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    line-height: 1.5;
    color: var(--warm-ivory);
    margin-bottom: 0.5rem;
}

.hex-quote .char {
    display: inline-block;
    will-change: transform, opacity;
    opacity: 0;
    transform: scale(0.5);
}

.hex-quote .char.animated {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hex-attribution {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--violet-bloom);
}

/* --- Marginalia --- */
.marginalia-note {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--weathered-stone);
    opacity: 0.6;
    line-height: 1.5;
}

.annotation-line {
    width: 80px;
    height: 40px;
    margin-top: 8px;
}

.annotation-line path {
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease;
}

.hex-cell.revealed .annotation-line path {
    stroke-dashoffset: 0;
}

/* --- OBSERVATORY SECTION --- */
.observatory-section {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.observatory-shatter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.shatter-hex {
    position: absolute;
    width: 180px;
    height: 208px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--midnight-ink);
    border: 1px solid var(--graphite-edge);
    opacity: 0.8;
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 1.2s ease;
}

.observatory-section.in-view .shatter-hex {
    opacity: 0;
}

.sh-1 { top: -5%; left: 5%; }
.sh-2 { top: -5%; right: 15%; }
.sh-3 { top: 20%; left: -5%; }
.sh-4 { top: 20%; right: -5%; }
.sh-5 { top: 50%; left: 10%; }
.sh-6 { top: 50%; right: 10%; }
.sh-7 { bottom: 10%; left: 20%; }
.sh-8 { bottom: 10%; right: 20%; }

.observatory-section.in-view .sh-1 { transform: translate(-120px, -100px) rotate(-15deg); }
.observatory-section.in-view .sh-2 { transform: translate(120px, -100px) rotate(20deg); }
.observatory-section.in-view .sh-3 { transform: translate(-150px, -30px) rotate(-10deg); }
.observatory-section.in-view .sh-4 { transform: translate(150px, -30px) rotate(12deg); }
.observatory-section.in-view .sh-5 { transform: translate(-130px, 60px) rotate(-18deg); }
.observatory-section.in-view .sh-6 { transform: translate(130px, 60px) rotate(15deg); }
.observatory-section.in-view .sh-7 { transform: translate(-100px, 120px) rotate(-8deg); }
.observatory-section.in-view .sh-8 { transform: translate(100px, 120px) rotate(10deg); }

.observatory-cityscape {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 0;
}

.obs-city-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 0 20px;
}

.obs-city-back {
    transform: scale(0.6);
    transform-origin: bottom center;
    opacity: 0.3;
    bottom: 10%;
}

.obs-city-front {
    z-index: 1;
}

.observatory-annotations {
    position: relative;
    z-index: 3;
    width: 100%;
    height: 100vh;
}

.obs-annotation {
    position: absolute;
    max-width: 280px;
    padding: 16px;
    background: rgba(10, 10, 18, 0.7);
    border-left: 2px solid var(--violet-bloom);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.observatory-section.in-view .obs-annotation {
    opacity: 1;
    transform: translateY(0);
}

.observatory-section.in-view .obs-annotation:nth-child(2) { transition-delay: 0.2s; }
.observatory-section.in-view .obs-annotation:nth-child(3) { transition-delay: 0.4s; }
.observatory-section.in-view .obs-annotation:nth-child(4) { transition-delay: 0.6s; }

.obs-label {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--electric-cyan);
    display: block;
    margin-bottom: 0.5rem;
}

.obs-note {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--warm-ivory);
}

.observatory-footer {
    position: absolute;
    bottom: 30px;
    width: 100%;
    text-align: center;
    z-index: 5;
}

.footer-text {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--weathered-stone);
    opacity: 0.5;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --hex-size: 160px;
    }

    .honeycomb-grid {
        max-width: 400px;
    }

    .hex-cell--wide {
        width: calc(var(--hex-size) * 1.2);
        height: calc(var(--hex-size) * 1.1547 * 1.1);
    }

    .hex-cell-inner {
        padding: 30px 20px;
    }

    .atrium-hex-frame {
        width: min(90vw, 400px);
        height: min(90vw, 400px);
    }

    .obs-annotation {
        max-width: 200px;
        padding: 12px;
    }

    .shatter-hex {
        width: 100px;
        height: 116px;
    }

    #hex-nav {
        top: 16px;
        left: 16px;
    }
}

@media (max-width: 480px) {
    :root {
        --hex-size: 140px;
    }

    .honeycomb-grid {
        max-width: 320px;
    }

    .hex-cell-inner {
        padding: 25px 18px;
    }

    .hex-body {
        font-size: 0.8rem;
    }
}

/* --- Selection --- */
::selection {
    background: var(--violet-bloom);
    color: var(--midnight-ink);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--midnight-ink);
}

::-webkit-scrollbar-thumb {
    background: var(--graphite-edge);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--violet-bloom);
}
