/* ============================================
   MMIDDL.com - Cinematic Liminality
   Horizontal Scroll Experience
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --cool-anchor: #4a6670;
    --warm-anchor: #c4956a;
    --deep-bg: #0f0e0d;
    --light-surface: #f2ede6;
    --dividing-line: #c4b5a0;
    --cool-text: #8ba4ae;
    --warm-text: #d4a67a;
    --accent-spark: #e8c44a;
    --dark-text: #2e2a24;
    --body-text-dark: #d4cfc8;

    --scroll-progress: 0;
    --total-panels: 13;

    --font-display: 'DM Serif Display', serif;
    --font-body: 'Anybody', sans-serif;
    --font-mono: 'Azeret Mono', monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--deep-bg);
    color: var(--cool-text);
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.75;
    font-stretch: 85%;
}

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

/* --- Film Grain Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    filter: url(#film-grain);
    opacity: 0.03;
    mix-blend-mode: overlay;
    background: rgba(255, 255, 255, 0.1);
}

body.midpoint-active::after {
    opacity: 0.06;
    transition: opacity 800ms ease;
}

/* --- Horizon Line --- */
.horizon-line {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--dividing-line);
    opacity: 0.3;
    z-index: 100;
    pointer-events: none;
}

/* --- Scroll Container --- */
.scroll-container {
    display: flex;
    height: 100vh;
    width: calc(100vw * var(--total-panels));
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.scroll-container::-webkit-scrollbar {
    display: none;
}

/* --- Panel Base --- */
.panel {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
}

.panel-inner {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* --- Panel Numbers --- */
.panel-number {
    position: absolute;
    bottom: 2.5rem;
    right: 2.5rem;
    z-index: 20;
}

.panel-number span {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.5;
    color: var(--cool-text);
}

/* ============================================
   PANEL 0: THE THRESHOLD
   ============================================ */
.panel-threshold {
    background: var(--deep-bg);
}

.threshold-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: var(--dividing-line);
    z-index: 5;
}

.logotype-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    cursor: default;
}

.logotype-left,
.logotype-right {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    letter-spacing: 0.08em;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.logotype-left {
    color: var(--cool-text);
    transform: translateX(0);
}

.logotype-right {
    color: var(--warm-text);
    transform: translateX(0);
}

.logotype-wrapper:hover .logotype-left {
    transform: translateX(-4px);
}

.logotype-wrapper:hover .logotype-right {
    transform: translateX(4px);
}

.threshold-cue {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.cue-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--dividing-line);
    opacity: 0.5;
}

.cue-arrow {
    font-size: 0.9rem;
    color: var(--dividing-line);
    opacity: 0.5;
    animation: drift-right 2s ease-in-out infinite;
}

@keyframes drift-right {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

/* ============================================
   PANELS 1-5: THE CROSSING
   ============================================ */
.panel-crossing {
    background: var(--deep-bg);
    position: relative;
}

/* Cool zone (top) */
.panel-crossing .panel-cool-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--cool-anchor);
    clip-path: polygon(0 0, 100% 0, 100% var(--diag-end), 0 var(--diag-start));
    opacity: 0.15;
    z-index: 1;
}

/* Warm zone (bottom) */
.panel-crossing .panel-warm-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--warm-anchor);
    clip-path: polygon(0 var(--diag-start), 100% var(--diag-end), 100% 100%, 0 100%);
    opacity: 0.15;
    z-index: 1;
}

/* Oversized Typography */
.oversized-type {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.oversized-type .type-cool,
.oversized-type .type-warm {
    position: absolute;
    font-family: var(--font-display);
    font-size: clamp(15vw, 20vw, 25vw);
    letter-spacing: 0.08em;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}

.oversized-type .type-cool {
    color: var(--cool-anchor);
    clip-path: polygon(0 0, 100% 0, 100% var(--diag-end), 0 var(--diag-start));
    z-index: 3;
}

.oversized-type .type-warm {
    color: var(--warm-anchor);
    clip-path: polygon(0 var(--diag-start), 100% var(--diag-end), 100% 100%, 0 100%);
    z-index: 3;
}

/* Panel Body Text */
.panel-body {
    position: absolute;
    z-index: 15;
    max-width: 28rem;
    padding: 0 2rem;
}

.panel-body.below-horizon {
    top: 55%;
    left: 8%;
}

.panel-body p {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.75;
    font-stretch: 85%;
    color: var(--body-text-dark);
}

.panel-crossing .panel-body p {
    color: var(--body-text-dark);
}

/* Vertical separator line in content panels */
.panel-crossing::after,
.panel-return::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 50%;
    width: 1px;
    height: 70%;
    background: var(--dividing-line);
    opacity: 0.12;
    z-index: 2;
}

/* ============================================
   PANEL 6: THE MIDPOINT
   ============================================ */
.panel-midpoint {
    background: linear-gradient(135deg, var(--cool-anchor) 0%, var(--warm-anchor) 100%);
    scroll-snap-stop: always;
}

.midpoint-vertical-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: var(--accent-spark);
    opacity: 0.6;
    z-index: 5;
}

.midpoint-content {
    text-align: center;
    max-width: 32rem;
    padding: 0 2rem;
    z-index: 10;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 800ms ease 400ms, transform 800ms ease 400ms;
}

.panel-midpoint.is-active .midpoint-content {
    opacity: 1;
    transform: translateY(0);
}

.midpoint-headline {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    letter-spacing: 0.08em;
    color: var(--light-surface);
    margin-bottom: 1.5rem;
}

.midpoint-text {
    font-family: var(--font-body);
    font-size: 1.15rem;
    line-height: 1.85;
    font-stretch: 85%;
    color: var(--light-surface);
    opacity: 0.85;
}

/* ============================================
   PANELS 7-11: THE RETURN
   ============================================ */
.panel-return {
    background: var(--deep-bg);
    position: relative;
}

/* Warm zone (top - inverted from crossing) */
.panel-return .panel-warm-zone-return {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--warm-anchor);
    clip-path: polygon(0 0, 100% 0, 100% var(--diag-end), 0 var(--diag-start));
    opacity: 0.15;
    z-index: 1;
}

/* Cool zone (bottom - inverted from crossing) */
.panel-return .panel-cool-zone-return {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--cool-anchor);
    clip-path: polygon(0 var(--diag-start), 100% var(--diag-end), 100% 100%, 0 100%);
    opacity: 0.15;
    z-index: 1;
}

/* Return panels: oversized type with swapped colors */
.oversized-type .type-warm-return,
.oversized-type .type-cool-return {
    position: absolute;
    font-family: var(--font-display);
    font-size: clamp(15vw, 20vw, 25vw);
    letter-spacing: 0.08em;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}

.oversized-type .type-warm-return {
    color: var(--warm-anchor);
    clip-path: polygon(0 0, 100% 0, 100% var(--diag-end), 0 var(--diag-start));
    z-index: 3;
}

.oversized-type .type-cool-return {
    color: var(--cool-anchor);
    clip-path: polygon(0 var(--diag-start), 100% var(--diag-end), 100% 100%, 0 100%);
    z-index: 3;
}

.panel-return .panel-body p {
    color: var(--warm-text);
}

.panel-return .panel-number span {
    color: var(--warm-text);
}

/* ============================================
   PANEL 12: THE OTHER SIDE
   ============================================ */
.panel-otherside {
    background: var(--light-surface);
}

.otherside-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: var(--cool-anchor);
    z-index: 5;
}

.logotype-inverted {
    cursor: default;
}

.logotype-left-inv,
.logotype-right-inv {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    letter-spacing: 0.08em;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.logotype-left-inv {
    color: var(--warm-anchor);
    transform: translateX(-4px);
}

.logotype-right-inv {
    color: var(--cool-anchor);
    transform: translateX(4px);
}

.logotype-inverted:hover .logotype-left-inv {
    transform: translateX(0);
}

.logotype-inverted:hover .logotype-right-inv {
    transform: translateX(0);
}

.otherside-cue .cue-text {
    color: var(--dark-text);
    opacity: 0.4;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 1000;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--cool-anchor), var(--accent-spark), var(--warm-anchor));
    transition: width 100ms ease-out;
}

.progress-ticks {
    position: absolute;
    top: -4px;
    left: 0;
    width: 100%;
    height: 10px;
    pointer-events: none;
}

.progress-tick {
    position: absolute;
    top: 0;
    width: 1px;
    height: 10px;
    background: var(--dividing-line);
    opacity: 0.3;
    cursor: pointer;
    pointer-events: all;
    transition: opacity 0.3s ease;
}

.progress-tick:hover {
    opacity: 0.8;
}

.progress-tick-label {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--dividing-line);
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.progress-tick:hover .progress-tick-label {
    opacity: 0.6;
}

/* ============================================
   SCROLL CURSOR (Vertical pulse)
   ============================================ */
.scroll-cursor {
    position: fixed;
    top: 20%;
    left: 50%;
    width: 1px;
    height: 60%;
    background: var(--dividing-line);
    opacity: 0;
    z-index: 90;
    pointer-events: none;
    transition: opacity 0.5s ease;
    animation: cursor-pulse 3s ease-in-out infinite;
}

.scroll-cursor.visible {
    opacity: 0.08;
}

@keyframes cursor-pulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.12; }
}

.scroll-cursor.visible {
    animation: cursor-pulse-visible 3s ease-in-out infinite;
}

@keyframes cursor-pulse-visible {
    0%, 100% { opacity: 0.04; }
    50% { opacity: 0.12; }
}

/* ============================================
   AMBIENT DUOTONE BACKGROUND SHIFT
   ============================================ */
body {
    background: color-mix(in oklch, var(--cool-anchor) calc((1 - var(--scroll-progress)) * 100%), var(--warm-anchor));
    transition: background 200ms ease;
}

/* Panels sit on deep-bg so ambient shift is visible in gaps/edges */
.panel-threshold,
.panel-crossing,
.panel-return {
    background: var(--deep-bg);
}

/* ============================================
   RESPONSIVE / TOUCH
   ============================================ */
@media (max-width: 768px) {
    .panel-body {
        max-width: 90%;
        left: 5% !important;
    }

    .oversized-type .type-cool,
    .oversized-type .type-warm,
    .oversized-type .type-warm-return,
    .oversized-type .type-cool-return {
        font-size: clamp(12vw, 18vw, 22vw);
    }

    .logotype-left,
    .logotype-right,
    .logotype-left-inv,
    .logotype-right-inv {
        font-size: clamp(2rem, 8vw, 4rem);
    }

    .midpoint-headline {
        font-size: clamp(2rem, 8vw, 4rem);
    }
}
