/* ============================================
   eyes.team — Styles
   Surreal Optometrist's Dream
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-deep: #0D0A12;
    --bg-mid: #1A1525;
    --iris-violet: #7B3FA0;
    --corneal-gold: #C4956A;
    --text-primary: #E8E0D4;
    --text-secondary: #6B5B73;
    --text-body: #B8A99A;
    --signal-accent: #3D8B7A;
    --danger-accent: #A0453D;
    --depth: 0;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: var(--bg-deep);
    color: var(--text-body);
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 17px;
    line-height: 1.8;
    perspective: 1200px;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Opening Overlay --- */
#opening-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-deep);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    clip-path: circle(100% at 50% 50%);
    transition: clip-path 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#opening-overlay.revealed {
    clip-path: circle(0% at 50% 50%);
}

#opening-light {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--corneal-gold) 0%, transparent 70%);
    animation: lightExpand 2.5s 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
}

@keyframes lightExpand {
    0% {
        opacity: 1;
        width: 4px;
        height: 4px;
        box-shadow: 0 0 20px 10px rgba(196, 149, 106, 0.3);
    }
    100% {
        opacity: 0;
        width: 300vw;
        height: 300vw;
        box-shadow: 0 0 200px 100px rgba(196, 149, 106, 0.1);
    }
}

/* --- Background Iris Layer (deepest z-plane) --- */
#bg-iris-layer {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 200vw;
    height: 200vw;
    transform: translate(-50%, -50%) translateZ(-200px);
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

#bg-iris-svg {
    width: 100%;
    height: 100%;
    animation: slowRotate 120s linear infinite;
}

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

/* --- Foreground Iris Layer (floating z-plane) --- */
#fg-iris-layer {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 60vw;
    height: 60vw;
    max-width: 700px;
    max-height: 700px;
    transform: translate(-50%, -50%) translateZ(50px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 5;
    animation: slowRotateReverse 90s linear infinite;
}

@keyframes slowRotateReverse {
    from { transform: translate(-50%, -50%) translateZ(50px) rotate(0deg); }
    to { transform: translate(-50%, -50%) translateZ(50px) rotate(-360deg); }
}

.fg-iris {
    width: 100%;
    height: 100%;
}

/* --- Floating Lens Flares --- */
.lens-flare {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 4;
    mix-blend-mode: screen;
}

#flare-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle at center, rgba(196, 149, 106, 0.12) 0%, transparent 60%);
    animation: flareFloat1 45s linear infinite;
}

#flare-2 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle at center, rgba(196, 149, 106, 0.08) 0%, transparent 55%);
    animation: flareFloat2 52s linear infinite;
}

#flare-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle at center, rgba(123, 63, 160, 0.06) 0%, transparent 50%);
    animation: flareFloat3 60s linear infinite;
}

#flare-4 {
    width: 150px;
    height: 150px;
    background: radial-gradient(circle at center, rgba(196, 149, 106, 0.15) 0%, transparent 65%);
    animation: flareFloat4 38s linear infinite;
}

@keyframes flareFloat1 {
    0% { top: -10%; left: 20%; }
    25% { top: 30%; left: 70%; }
    50% { top: 60%; left: 40%; }
    75% { top: 20%; left: 80%; }
    100% { top: -10%; left: 20%; }
}

@keyframes flareFloat2 {
    0% { top: 80%; left: 60%; }
    25% { top: 40%; left: 10%; }
    50% { top: 10%; left: 50%; }
    75% { top: 50%; left: 90%; }
    100% { top: 80%; left: 60%; }
}

@keyframes flareFloat3 {
    0% { top: 30%; left: -10%; }
    25% { top: 70%; left: 50%; }
    50% { top: 20%; left: 80%; }
    75% { top: 60%; left: 20%; }
    100% { top: 30%; left: -10%; }
}

@keyframes flareFloat4 {
    0% { top: 50%; left: 80%; }
    25% { top: 10%; left: 30%; }
    50% { top: 70%; left: 10%; }
    75% { top: 30%; left: 60%; }
    100% { top: 50%; left: 80%; }
}

/* --- Snellen Chart Fragments --- */
.snellen-fragment {
    position: fixed;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--text-primary);
    pointer-events: none;
    user-select: none;
    z-index: 1;
    animation: snellenDrift 60s ease-in-out infinite;
}

#snellen-1 {
    font-size: 600px;
    opacity: 0.04;
    top: -100px;
    right: -80px;
    animation-delay: 0s;
}

#snellen-2 {
    font-size: 400px;
    opacity: 0.03;
    bottom: 10%;
    left: -60px;
    animation-delay: -15s;
}

#snellen-3 {
    font-size: 300px;
    opacity: 0.05;
    top: 40%;
    right: 5%;
    animation-delay: -30s;
}

#snellen-4 {
    font-size: 200px;
    opacity: 0.06;
    bottom: 20%;
    left: 15%;
    animation-delay: -45s;
}

@keyframes snellenDrift {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(10px, -8px); }
    50% { transform: translate(-5px, 12px); }
    75% { transform: translate(8px, 5px); }
}

/* --- Narrative Sections --- */
.narrative-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 80px 40px;
    overflow: hidden;
}

.section-content {
    position: relative;
    max-width: 1100px;
    width: 100%;
    z-index: 3;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section-content.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Iris Shutter Overlay --- */
.section-iris-shutter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    background: var(--bg-deep);
    clip-path: polygon(
        50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.section-iris-shutter.closing {
    opacity: 1;
    animation: irisClose 400ms ease-in forwards;
}

.section-iris-shutter.opening {
    opacity: 1;
    animation: irisOpen 400ms 400ms ease-out forwards;
}

@keyframes irisClose {
    0% {
        clip-path: polygon(
            50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%
        );
    }
    100% {
        clip-path: polygon(
            50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%
        );
    }
}

@keyframes irisOpen {
    0% {
        clip-path: polygon(
            50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%
        );
    }
    100% {
        clip-path: polygon(
            50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%
        );
        opacity: 0;
    }
}

/* --- Section 1: Surface --- */
#section-surface {
    padding-top: 120px;
}

/* Title with staggered letter animation */
#site-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 72px;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 24px;
}

#site-title .letter {
    display: inline-block;
    opacity: 0;
    animation: letterFadeIn 0.4s ease forwards;
}

#site-title .letter:nth-child(1) { animation-delay: 3.2s; }
#site-title .letter:nth-child(2) { animation-delay: 3.35s; }
#site-title .letter:nth-child(3) { animation-delay: 3.5s; }
#site-title .letter:nth-child(4) { animation-delay: 3.65s; }
#site-title .letter:nth-child(5) { animation-delay: 3.8s; }
#site-title .letter:nth-child(6) { animation-delay: 3.95s; }
#site-title .letter:nth-child(7) { animation-delay: 4.1s; }
#site-title .letter:nth-child(8) { animation-delay: 4.25s; }
#site-title .letter:nth-child(9) { animation-delay: 4.4s; }

@keyframes letterFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tagline {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 18px;
    color: var(--text-body);
    text-align: center;
    max-width: 600px;
    margin: 0 auto 80px;
    opacity: 0;
    animation: fadeIn 1s 4.8s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Honeycomb Grid --- */
.honeycomb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 960px;
    margin: 0 auto;
}

.honeycomb-grid > .hex-cell:nth-child(even) {
    margin-top: 40px;
}

.hex-cell {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--bg-mid);
    aspect-ratio: 1 / 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.3s ease, transform 0.3s ease;
    cursor: default;
}

.hex-cell:hover {
    filter: brightness(1.15);
}

.hex-inner {
    padding: 50px 30px;
    text-align: center;
}

.hex-inner h3 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.hex-inner p {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-body);
}

/* --- Diagnostic Readout Strips --- */
.diagnostic-strip {
    position: relative;
    height: 32px;
    overflow: hidden;
    z-index: 3;
    background: rgba(13, 10, 18, 0.8);
    border-top: 1px solid rgba(123, 63, 160, 0.15);
    border-bottom: 1px solid rgba(123, 63, 160, 0.15);
}

.diagnostic-text {
    display: inline-block;
    white-space: nowrap;
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 12px;
    color: var(--corneal-gold);
    opacity: 0.6;
    line-height: 32px;
    padding-left: 100%;
    animation: scrollLeft 30s linear infinite;
}

@keyframes scrollLeft {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 56px;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    text-align: center;
    margin-bottom: 8px;
}

.section-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 60px;
}

/* --- Section 2: Lens --- */
.lens-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 60px;
    align-items: center;
}

.lens-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lens-svg {
    width: 100%;
    max-width: 350px;
    animation: lensPulse 6s ease-in-out infinite;
}

@keyframes lensPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.03); opacity: 1; }
}

.lens-text p {
    margin-bottom: 20px;
    color: var(--text-body);
}

.lens-quote {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: 24px;
    font-style: italic;
    color: var(--iris-violet);
    padding-left: 20px;
    border-left: 2px solid var(--iris-violet);
    margin-top: 30px;
}

/* --- Section 3: Retina --- */
.retinal-vessels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 1.5s ease;
}

.retinal-vessels.revealed {
    clip-path: circle(80% at 50% 50%);
}

.vessel-svg {
    width: 100%;
    height: 100%;
}

.retina-content {
    position: relative;
    z-index: 2;
}

.retina-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    margin-bottom: 50px;
}

.retina-cell {
    background: rgba(26, 21, 37, 0.7);
    border: 1px solid rgba(123, 63, 160, 0.2);
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.retina-cell:hover {
    transform: translateY(-4px);
    border-color: var(--iris-violet);
}

.cell-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
}

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

.retina-cell h4 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.retina-cell p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-body);
}

.retina-prose {
    font-size: 17px;
    line-height: 1.8;
    color: var(--text-body);
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

/* --- Section 4: Nerve --- */
.nerve-content {
    display: flex;
    flex-direction: column;
    gap: 50px;
    align-items: center;
}

.nerve-pathways {
    width: 100%;
    max-width: 700px;
}

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

.nerve-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease;
}

.nerve-pathways.animated .nerve-path {
    stroke-dashoffset: 0;
}

.nerve-text {
    max-width: 750px;
}

.nerve-text p {
    margin-bottom: 20px;
    color: var(--text-body);
    text-align: center;
}

/* --- Section 5: Cortex --- */
.cortex-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 60px;
    align-items: start;
}

.cortex-layers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cortex-layer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(26, 21, 37, 0.6);
    border-left: 3px solid var(--iris-violet);
    border-radius: 0 8px 8px 0;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    cursor: default;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s ease, transform 0.5s ease, background 0.3s ease, border-color 0.3s ease;
}

.cortex-layer.visible {
    opacity: 1;
    transform: translateX(0);
}

.cortex-layer:hover {
    background: rgba(26, 21, 37, 0.9);
    border-color: var(--corneal-gold);
    transform: translateX(4px);
}

.cortex-layer.visible:hover {
    transform: translateX(4px);
}

.layer-label {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 14px;
    color: var(--corneal-gold);
    min-width: 48px;
    text-align: center;
}

.layer-desc {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 14px;
    color: var(--text-body);
    line-height: 1.5;
}

.cortex-text p {
    margin-bottom: 20px;
    color: var(--text-body);
}

.cortex-closing {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: 22px;
    font-style: italic;
    color: var(--iris-violet);
    padding: 30px;
    border: 1px solid rgba(123, 63, 160, 0.3);
    border-radius: 12px;
    text-align: center;
    margin-top: 40px;
}

/* --- Navigation Eye Icon --- */
#nav-eye {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 100;
    cursor: pointer;
}

#nav-eye-icon {
    width: 48px;
    height: 48px;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#nav-eye-icon:hover {
    transform: scale(1.1) rotate(2deg);
}

#nav-eye-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 10px rgba(123, 63, 160, 0.4));
}

#nav-pupil {
    transition: r 0.3s ease;
}

#nav-eye:hover #nav-pupil {
    r: 6;
}

/* Radial navigation menu */
#nav-radial {
    position: absolute;
    bottom: 60px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

#nav-radial.nav-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.nav-link {
    display: block;
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 12px;
    color: var(--corneal-gold);
    text-decoration: none;
    padding: 6px 14px;
    background: rgba(26, 21, 37, 0.9);
    border: 1px solid rgba(123, 63, 160, 0.3);
    border-radius: 20px;
    text-align: right;
    white-space: nowrap;
    transition: border-color 0.3s ease, color 0.3s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-link:hover {
    border-color: var(--iris-violet);
    color: var(--text-primary);
    transform: translateX(-4px);
}

.nav-link.active {
    border-color: var(--signal-accent);
    color: var(--signal-accent);
}

/* --- Pupil-Reactive Background --- */
body {
    background: color-mix(in oklch, var(--bg-mid) calc(100% - var(--depth) * 100%), var(--bg-deep));
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #site-title {
        font-size: 42px;
    }

    .section-heading {
        font-size: 36px;
    }

    .tagline {
        font-size: 16px;
    }

    .honeycomb-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .honeycomb-grid > .hex-cell:nth-child(even) {
        margin-top: 0;
    }

    .hex-cell {
        clip-path: none;
        border-radius: 16px;
        aspect-ratio: auto;
    }

    .hex-inner {
        padding: 30px 24px;
    }

    .lens-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .retina-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .cortex-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .narrative-section {
        padding: 60px 20px;
    }

    .lens-quote {
        font-size: 20px;
    }

    .cortex-closing {
        font-size: 18px;
    }

    #snellen-1 { font-size: 300px; }
    #snellen-2 { font-size: 200px; }
    #snellen-3 { font-size: 150px; }
    #snellen-4 { font-size: 120px; }

    #fg-iris-layer {
        width: 100vw;
        height: 100vw;
    }
}

@media (max-width: 480px) {
    #site-title {
        font-size: 36px;
    }

    .section-heading {
        font-size: 28px;
    }

    .hex-inner h3 {
        font-size: 20px;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(123, 63, 160, 0.4);
    color: var(--text-primary);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: rgba(123, 63, 160, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(123, 63, 160, 0.5);
}
