/* ====================================================================
   aiice.io — vaporwave pastoral diorama
   eight stacked translucent depth-planes, typewritten eclogue
   ==================================================================== */

:root {
    --dawn-peach:        #FFE9E3;
    --cotton-candy:      #F8C8DC;
    --lavender-haze:     #C9B8E0;
    --periwinkle-pool:   #A7D8E8;
    --peach-cadillac:    #FFD5A5;
    --meadow-mint:       #B8E0C8;
    --dusk-violet:       #5A4A6E;
    --leather-tan:       #8C6E5A;

    --link-deep:         #3E3052;

    --col-width:         min(560px, 88vw);
    --floor-vanish:      38%;

    --type-jitter:       0.4px;
}

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

html, body {
    width: 100%;
    background: var(--dawn-peach);
    color: var(--dusk-violet);
    overflow-x: hidden;
}

body {
    font-family: 'Special Elite', 'Courier New', monospace;
    line-height: 1.7;
    cursor: none;
    perspective: 1200px;
    perspective-origin: 50% 30%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Custom scrollbar (leather-tan thumb) === */
body::-webkit-scrollbar { width: 10px; }
body::-webkit-scrollbar-track { background: var(--dawn-peach); }
body::-webkit-scrollbar-thumb {
    background: var(--leather-tan);
    background-image: linear-gradient(180deg, var(--leather-tan) 0%, #6f5644 100%);
    border-radius: 4px;
    opacity: 0.7;
}

/* ====================================================================
   Diorama box — 3D perspective container
   ==================================================================== */

.diorama {
    position: relative;
    width: 100%;
    transform-style: preserve-3d;
}

.plane {
    position: absolute;
    left: 0;
    width: 100%;
    pointer-events: none;
    will-change: transform, opacity;
    opacity: 0;
    transition: opacity 2.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.plane.plane-page { pointer-events: auto; }

/* === Plane -800 : gradient sky === */
.plane-sky {
    top: 0;
    height: 100%;
    z-index: 1;
}
.gradient-sky {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(120% 80% at 50% 110%, var(--peach-cadillac) 0%, transparent 60%),
        linear-gradient(180deg,
            var(--periwinkle-pool) 0%,
            #d6c9e8 28%,
            var(--cotton-candy) 58%,
            var(--peach-cadillac) 84%,
            var(--dawn-peach) 100%);
}

/* === Plane -600 : distant Doric === */
.plane-doric {
    top: 0;
    height: 100vh;
    z-index: 2;
}
.doric-svg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    opacity: 0.42;
}
.doric-svg .col {
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Plane -400 : organic blobs === */
.plane-blobs {
    top: 0;
    height: 100vh;
    z-index: 3;
}
.blobs-svg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    opacity: 0.75;
}
.blob {
    transform-box: fill-box;
    transform-origin: center;
    will-change: transform;
}

/* === Plane -200 : magenta wireframe floor === */
.plane-floor {
    top: 0;
    height: 100vh;
    z-index: 4;
}
.grid-floor {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--floor-vanish);
    bottom: 0;
    background-image:
        linear-gradient(to right,  rgba(248,200,220,0.65) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(248,200,220,0.65) 1px, transparent 1px);
    background-size: 80px 60px;
    transform-origin: center top;
    transform: perspective(420px) rotateX(58deg);
    opacity: 0.25;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.4) 18%, rgba(0,0,0,1) 60%, rgba(0,0,0,0.8) 100%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.4) 18%, rgba(0,0,0,1) 60%, rgba(0,0,0,0.8) 100%);
}
.grid-floor::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, var(--peach-cadillac) 0%, transparent 40%);
    opacity: 0.55;
    mix-blend-mode: screen;
}

/* === Plane -80 : pastoral frieze === */
.plane-frieze {
    top: 0;
    height: 100vh;
    z-index: 5;
}
.frieze-svg {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 22%;
    width: 100%;
    height: 90px;
    opacity: 0.55;
    will-change: transform;
}

/* ====================================================================
   Plane 0 — typewriter page (central reading column)
   ==================================================================== */

.plane-page {
    position: relative;
    z-index: 10;
    padding: 12vh 0 18vh;
}

.typewriter-page {
    width: var(--col-width);
    margin: 0 auto;
    padding: 64px 36px 96px;
    background: var(--dawn-peach);
    background-image:
        linear-gradient(180deg,
            var(--dawn-peach) 0%,
            #fff1ec 50%,
            var(--dawn-peach) 100%);
    box-shadow:
        inset 8px 0 18px -10px rgba(140,110,90,0.36),
        inset -2px 0 8px -6px rgba(140,110,90,0.18),
        0 24px 60px -28px rgba(90,74,110,0.28);
    border-radius: 2px;
    position: relative;
}

.typewriter-page::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 12px;
    background:
        repeating-linear-gradient(180deg,
            rgba(140,110,90,0.18) 0,
            rgba(140,110,90,0.18) 2px,
            transparent 2px,
            transparent 22px);
    opacity: 0.5;
}

/* === Wordmark === */
.wordmark {
    position: relative;
    text-align: center;
    margin-bottom: 8vh;
}
.wordmark-text {
    font-family: 'Monoton', 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(64px, 12vw, 148px);
    letter-spacing: 0.02em;
    line-height: 0.9;
    background: linear-gradient(180deg,
        var(--dawn-peach) 0%,
        var(--cotton-candy) 32%,
        var(--lavender-haze) 58%,
        var(--periwinkle-pool) 82%,
        var(--dusk-violet) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 0 rgba(248,200,220,0.6)) drop-shadow(0 6px 18px rgba(167,216,232,0.5));
}
.wm-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 220ms ease-out, transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.wm-letter.is-set {
    opacity: 1;
    transform: translateY(0);
}
.wm-letter::after {
    /* pink ribbon-stain that blossoms under each letter */
    content: '';
    position: absolute;
    left: 8%; right: 8%; bottom: -2%;
    height: 18%;
    background: radial-gradient(50% 100% at 50% 50%, rgba(248,200,220,0.7) 0%, transparent 70%);
    opacity: 0;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(4px);
    transition: opacity 1.1s ease-out 80ms;
}
.wm-letter.is-set::after { opacity: 1; }

.cabochon {
    position: absolute;
    /* placed near dot of the 'i' in '.io' — approximate inline */
    width: clamp(14px, 1.6vw, 22px);
    height: clamp(14px, 1.6vw, 22px);
    right: clamp(18px, 6vw, 88px);
    top: 6%;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 380ms ease-out, transform 480ms cubic-bezier(0.18, 0.89, 0.32, 1.4);
    filter: drop-shadow(0 1px 2px rgba(140,110,90,0.5));
    animation: cabochon-pulse 4s ease-in-out infinite;
    animation-play-state: paused;
}
.cabochon.is-set {
    opacity: 1;
    transform: scale(1);
    animation-play-state: running;
}
@keyframes cabochon-pulse {
    0%, 100% { filter: drop-shadow(0 1px 2px rgba(140,110,90,0.5)) brightness(1); }
    50%      { filter: drop-shadow(0 1px 3px rgba(140,110,90,0.6)) brightness(1.04); }
}

/* === Eclogue === */
.eclogue {
    position: relative;
    margin: 6vh 0;
    padding: 6px 0;
    min-height: 120px;
}

.eclogue-title {
    font-family: 'Cormorant Garamond', 'Lora', serif;
    font-style: italic;
    font-weight: 500;
    font-size: clamp(26px, 3.4vw, 42px);
    letter-spacing: 0.01em;
    line-height: 1.15;
    color: var(--dusk-violet);
    margin-bottom: 22px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 900ms ease-out, transform 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.eclogue-title.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.eclogue-body {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: clamp(16px, 1.3vw, 19px);
    line-height: 1.8;
    color: var(--dusk-violet);
    letter-spacing: 0.012em;
    white-space: pre-wrap;
}

/* per-glyph spans inserted by JS */
.glyph {
    display: inline;
    opacity: 0;
    color: var(--dusk-violet);
    transition: opacity 220ms ease-out;
}
.glyph.is-typed { opacity: 1; }

/* a fresh-typed glyph blooms with a ribbon-stain underneath */
.glyph.is-fresh {
    text-shadow: 0 0 6px rgba(248,200,220,0.55);
}

/* Eclogue VI — per-glyph wobble (ink density flickering) */
.eclogue-wobble .glyph.is-typed {
    animation: ribbon-wobble 6s infinite alternate ease-in-out;
}
@keyframes ribbon-wobble {
    0%   { opacity: 1; }
    50%  { opacity: 0.94; }
    100% { opacity: 1; }
}

/* === Margin notes (Caveat handwriting) === */
.margin-note {
    position: absolute;
    font-family: 'Caveat', 'Cormorant Garamond', cursive;
    font-size: clamp(15px, 1.2vw, 18px);
    color: var(--cotton-candy);
    width: clamp(120px, 14vw, 200px);
    line-height: 1.25;
    transform: rotate(var(--rot, 0));
    opacity: 0;
    transition: opacity 1.4s ease-out;
    pointer-events: none;
    text-shadow: 0 1px 0 rgba(255,233,227,0.6);
}
.margin-note.is-visible { opacity: 0.95; }

.margin-left {
    left: calc(-1 * (clamp(140px, 16vw, 220px)));
    top: 30%;
}
.margin-right {
    right: calc(-1 * (clamp(140px, 16vw, 220px)));
    top: 60%;
}
.margin-note.greek {
    color: var(--dusk-violet);
    font-style: italic;
}
.margin-note.greek::after {
    content: '';
}

/* === Separator === */
.separator {
    display: flex;
    justify-content: center;
    margin: 4vh 0;
    transform: translateY(-12px);
    opacity: 0;
    transition: opacity 600ms ease-out, transform 700ms cubic-bezier(0.4, 0, 0.2, 1);
}
.separator.is-visible {
    transform: translateY(0);
    opacity: 1;
}

/* === Final lamb walking stage === */
.lamb-stage {
    position: relative;
    width: 100%;
    height: 60px;
    margin-top: 6vh;
    overflow: hidden;
    opacity: 0;
    transition: opacity 600ms ease-out;
}
.lamb-stage.is-active { opacity: 1; }

#lamb-group {
    transform: translate(-40px, 28px);
}

/* ====================================================================
   Plane +60 — ribbon cursor + ink-trail (top layer except scanlines)
   ==================================================================== */

.plane-cursor {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    z-index: 9000;
    opacity: 1;
    pointer-events: none;
}

.ribbon-cursor {
    position: fixed;
    top: 0; left: 0;
    width: 28px;
    height: 6px;
    background: var(--cotton-candy);
    border-radius: 3px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 8px rgba(248,200,220,0.6), 0 0 22px rgba(248,200,220,0.32);
    transition: background 200ms ease, box-shadow 200ms ease;
    will-change: left, top;
    z-index: 9001;
}
.ribbon-cursor.over-clickable {
    background: var(--dusk-violet);
    box-shadow: 0 0 6px rgba(90,74,110,0.45);
    opacity: 0.85;
}

.ink-trail-svg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 8999;
}
.ink-trail-svg line {
    stroke: var(--cotton-candy);
    stroke-linecap: round;
    will-change: opacity;
}

/* ====================================================================
   CRT scanlines + flicker (above everything)
   ==================================================================== */

.crt-scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9500;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(90,74,110,0.06) 0,
        rgba(90,74,110,0.06) 1px,
        transparent 1px,
        transparent 3px
    );
    mix-blend-mode: multiply;
    opacity: 0.55;
    animation: scanlines-roll 12s linear infinite;
}
@keyframes scanlines-roll {
    from { background-position: 0 0; }
    to   { background-position: 0 60px; }
}

.crt-flicker {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9501;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(90,74,110,0.18) 100%);
    mix-blend-mode: multiply;
    opacity: 0.4;
    animation: crt-flicker 7s ease-in-out infinite;
}
@keyframes crt-flicker {
    0%, 100% { opacity: 0.38; }
    47%      { opacity: 0.42; }
    50%      { opacity: 0.55; }
    53%      { opacity: 0.40; }
    78%      { opacity: 0.36; }
}

/* ====================================================================
   Telemetry (lower-left, VT323)
   ==================================================================== */

.telemetry {
    position: fixed;
    left: 24px;
    bottom: 18px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--dusk-violet);
    opacity: 0.62;
    pointer-events: none;
    z-index: 9300;
    text-shadow: 0 0 6px rgba(167,216,232,0.55);
}
.telemetry-clock,
.telemetry-eclogue {
    line-height: 1.35;
}
.telemetry-eclogue {
    color: var(--cotton-candy);
    opacity: 0.9;
}

/* ====================================================================
   Reveal classes (set by JS as planes/eclogues come in)
   ==================================================================== */

.plane.is-revealed { opacity: 1; }
.plane-cursor.is-revealed { opacity: 1; }

/* ====================================================================
   Responsive: smaller viewports
   ==================================================================== */

@media (max-width: 720px) {
    .typewriter-page {
        padding: 48px 22px 64px;
    }
    .margin-note {
        position: static;
        display: block;
        width: auto;
        margin: 18px auto;
        text-align: center;
        transform: rotate(0) !important;
    }
    .telemetry {
        font-size: 11px;
        left: 12px;
        bottom: 10px;
    }
    .frieze-svg {
        bottom: 8%;
        height: 60px;
    }
}

@media (max-width: 480px) {
    body { cursor: auto; }
    .ribbon-cursor, .ink-trail-svg { display: none; }
}
