/* ============================================
   eyes.plus - Topographic Survey of the Human Eye
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --scleral-ivory: #f2ede3;
    --vitreous-sage: #7a8b6e;
    --retinal-umber: #5c3a21;
    --iris-copper: #b8763e;
    --corneal-blue: #a3c4d4;
    --foveal-black: #1a1612;
    --aqueous-clear: #dce8e0;
    --optic-disc-gold: #c9a23e;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Lora', 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-accent: 'Cormorant Garamond', 'Georgia', serif;

    --thread-offset: 0px;
}

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--scleral-ivory);
    color: var(--retinal-umber);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Defs (hidden) --- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

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

/* --- Section Base --- */
.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    scroll-snap-align: start;
}

/* --- Fade-in Animation --- */
.fade-in-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.fade-in-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   SECTION 1: CORNEAL SURFACE
   ============================================ */
.section-cornea {
    background-color: var(--scleral-ivory);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
}

.cornea-content {
    position: absolute;
    left: 38%;
    top: 45vh;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: var(--retinal-umber);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.1;
}

.site-subtitle {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vitreous-sage);
    margin-top: 0.5rem;
}

.cornea-contour-map {
    position: absolute;
    right: 0;
    top: 15vh;
    width: 55%;
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cornea-svg {
    width: 100%;
    height: 100%;
    max-width: 600px;
}

.cornea-depth-label {
    position: absolute;
    left: 38%;
    bottom: 15vh;
    transform: translateX(-50%);
}

.depth-indicator {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vitreous-sage);
}

.descend-cue {
    position: absolute;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    animation: gentlePulse 3s ease-in-out infinite;
}

.descend-caret {
    font-size: 24px;
    color: var(--vitreous-sage);
    line-height: 1;
}

.descend-text {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vitreous-sage);
}

@keyframes gentlePulse {
    0%, 100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
    50% { opacity: 0.8; transform: translateX(-50%) translateY(4px); }
}

/* --- Contour Ring Animation --- */
.contour-ring {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 800ms ease-out;
}

.contour-ring.drawn {
    stroke-dashoffset: 0;
}

/* --- Contour Labels --- */
.contour-svg .label-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    fill: var(--vitreous-sage);
    letter-spacing: 0.06em;
}

.contour-label .leader-line {
    transition: opacity 300ms ease;
}

.contour-label:hover .leader-line {
    opacity: 0.6;
}

.contour-label:hover .label-text {
    fill: var(--retinal-umber);
}

.contour-label .tooltip {
    display: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    fill: var(--iris-copper);
}

.contour-label:hover .tooltip {
    display: block;
}

/* ============================================
   CROSS-SECTION BANDS
   ============================================ */
.cross-section-band {
    position: relative;
    height: 40px;
    background-color: var(--scleral-ivory);
    overflow: hidden;
    display: flex;
    align-items: center;
}

.cross-section-silhouette {
    position: absolute;
    left: -100%;
    width: 100%;
    height: 100%;
    background-color: var(--foveal-black);
    opacity: 0.08;
    transition: left 400ms ease-out;
}

.cross-section-band.in-view .cross-section-silhouette {
    left: 0;
}

/* Silhouette shapes via clip-path */
.silhouette-cornea {
    clip-path: ellipse(50% 30% at 50% 50%);
}

.silhouette-anterior {
    clip-path: ellipse(48% 35% at 50% 50%);
}

.silhouette-lens {
    clip-path: ellipse(30% 45% at 50% 50%);
}

.silhouette-vitreous {
    clip-path: ellipse(45% 40% at 50% 50%);
}

.depth-label {
    position: absolute;
    right: 3%;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vitreous-sage);
    z-index: 1;
}

/* ============================================
   SECTION 2: ANTERIOR CHAMBER
   ============================================ */
.section-anterior {
    background-color: var(--aqueous-clear);
    position: relative;
    overflow: hidden;
}

.stipple-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Ccircle cx='3' cy='5' r='0.5' fill='%235c3a21' opacity='0.04'/%3E%3Ccircle cx='11' cy='2' r='0.5' fill='%235c3a21' opacity='0.03'/%3E%3Ccircle cx='7' cy='10' r='0.5' fill='%235c3a21' opacity='0.05'/%3E%3Ccircle cx='14' cy='13' r='0.5' fill='%235c3a21' opacity='0.03'/%3E%3Ccircle cx='1' cy='14' r='0.5' fill='%235c3a21' opacity='0.04'/%3E%3Ccircle cx='9' cy='7' r='0.5' fill='%235c3a21' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.anterior-text-column {
    position: absolute;
    left: 20%;
    top: 50%;
    transform: translateY(-50%);
    width: 30%;
    max-width: 400px;
}

.section-header {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: var(--retinal-umber);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.75;
    color: var(--retinal-umber);
    margin-bottom: 1rem;
}

.anterior-label {
    position: absolute;
}

.annotation-text {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vitreous-sage);
}

.anterior-connectors {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ============================================
   SECTION 3: CRYSTALLINE LENS
   ============================================ */
.section-lens {
    background-color: var(--scleral-ivory);
    display: flex;
    align-items: center;
    padding: 5vh 5%;
}

.lens-text-block {
    width: 40%;
    padding-right: 4%;
}

.lens-body {
    font-size: 14px;
    line-height: 1.7;
}

.lens-contour-map {
    width: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lens-svg {
    width: 100%;
    max-width: 500px;
}

/* Refractive distortion zone - subtle weight/spacing shift near center */
.section-lens .lens-body {
    font-variation-settings: normal;
}

/* ============================================
   SECTION 4: VITREOUS BODY
   ============================================ */
.section-vitreous {
    background-color: var(--aqueous-clear);
    min-height: 150vh;
    position: relative;
    overflow: hidden;
}

.vitreous-fragment {
    position: absolute;
    max-width: 35%;
}

.fragment-1 {
    max-width: 30%;
}

.fragment-2 {
    max-width: 32%;
}

.fragment-3 {
    max-width: 30%;
}

.accent-text {
    font-family: var(--font-accent);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(20px, 2.5vw, 28px);
    line-height: 1.5;
    color: var(--retinal-umber);
}

.vitreous-threads {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.vitreous-thread {
    transition: d 100ms ease-out;
}

/* ============================================
   SECTION 5: RETINA
   ============================================ */
.section-retina {
    background-color: var(--scleral-ivory);
    padding: 6vh 4%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.retina-columns {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 0.8fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.retina-col {
    padding: 0 0.5rem;
}

.retina-subheader {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--retinal-umber);
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.retina-body {
    font-size: 14px;
    line-height: 1.65;
}

.retina-data {
    margin-top: 1.5rem;
    border-top: 1px solid rgba(122, 139, 110, 0.2);
    padding-top: 1rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(122, 139, 110, 0.1);
}

.data-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vitreous-sage);
}

.data-value {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--foveal-black);
    font-weight: 400;
}

.retina-contour-map {
    margin-top: 1.5rem;
}

.retina-svg {
    width: 100%;
    max-width: 300px;
}

/* Retinal layer index */
.retina-layers {
    margin-top: 0.5rem;
}

.layer-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(122, 139, 110, 0.08);
    align-items: baseline;
}

.layer-num {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--corneal-blue);
    letter-spacing: 0.04em;
    flex-shrink: 0;
    width: 1.5rem;
}

.layer-name {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--retinal-umber);
    line-height: 1.4;
}

.retina-footer {
    border-top: 1px solid rgba(122, 139, 110, 0.15);
    padding-top: 2rem;
    margin-top: 2rem;
    max-width: 70%;
}

.retina-footer .annotation-text {
    font-size: 12px;
    line-height: 1.8;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .cornea-content {
        left: 50%;
        top: 35vh;
    }

    .cornea-contour-map {
        width: 80%;
        right: 10%;
        top: 40vh;
        opacity: 0.3;
    }

    .anterior-text-column {
        left: 10%;
        width: 50%;
    }

    .section-lens {
        flex-direction: column;
    }

    .lens-text-block {
        width: 90%;
        padding-right: 0;
        margin-bottom: 2rem;
    }

    .lens-contour-map {
        width: 90%;
    }

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

    .vitreous-fragment {
        max-width: 50%;
    }
}

@media (max-width: 600px) {
    .cornea-content {
        left: 50%;
        top: 30vh;
    }

    .anterior-text-column {
        left: 5%;
        width: 70%;
    }

    .anterior-label {
        display: none;
    }

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

    .vitreous-fragment {
        max-width: 80%;
        position: relative;
        left: 10% !important;
        top: auto !important;
        margin-bottom: 3rem;
    }

    .section-vitreous {
        min-height: auto;
        padding: 10vh 0;
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    .vitreous-threads {
        display: none;
    }

    .retina-footer {
        max-width: 100%;
    }
}
