/* ============================================
   dilemma.quest - Styles
   Bauhaus rationalism dissolving into doubt
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --carrara-white: #F0EDE8;
    --frost-glass: #E2E8F0;
    --obsidian-marble: #1C1F26;
    --veined-gold: #C9A96E;
    --slate-vein: #7B8FA1;
    --ice-membrane: rgba(226, 232, 240, 0.65);
    --ink-black: #2D2D34;
    --marble-gray: #6B7280;
    --rose-quartz: #D4A5A5;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-accent: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;

    --chamber-inset: 48px;
    --frost-width: 4vw;
    --gutter: 24px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    background: var(--carrara-white);
    color: var(--ink-black);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.7;
    letter-spacing: 0.01em;
    overflow: hidden;
    height: 100vh;
}

/* --- Scroll Container --- */
.scroll-container {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    position: relative;
}

/* --- Marble Background Texture (CSS-generated) --- */
.marble-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(212, 165, 165, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(123, 143, 161, 0.06) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 80%, rgba(212, 165, 165, 0.05) 0%, transparent 45%),
        radial-gradient(ellipse at 40% 30%, rgba(201, 169, 110, 0.04) 0%, transparent 50%),
        conic-gradient(from 45deg at 50% 50%, rgba(240, 237, 232, 0.5), rgba(226, 232, 240, 0.3), rgba(240, 237, 232, 0.5), rgba(212, 165, 165, 0.1), rgba(240, 237, 232, 0.5));
    background-size: 200% 200%;
    animation: marbleDrift 60s linear infinite;
    pointer-events: none;
}

.marble-warm {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(212, 165, 165, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(212, 165, 165, 0.12) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 50%, rgba(201, 169, 110, 0.08) 0%, transparent 55%),
        conic-gradient(from 120deg at 50% 50%, rgba(240, 237, 232, 0.5), rgba(212, 165, 165, 0.2), rgba(240, 237, 232, 0.5), rgba(201, 169, 110, 0.1), rgba(240, 237, 232, 0.5));
    background-size: 200% 200%;
    animation: marbleDrift 60s linear infinite;
}

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

/* --- Organic Blobs --- */
.blob {
    position: fixed;
    z-index: 1;
    pointer-events: none;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    will-change: transform, border-radius;
}

.blob-warm {
    width: 50vw;
    height: 50vw;
    background: rgba(201, 169, 110, 0.08);
    top: -10vh;
    left: -10vw;
    animation: blobMorphWarm 20s ease-in-out infinite;
}

.blob-cool {
    width: 45vw;
    height: 45vw;
    background: rgba(123, 143, 161, 0.06);
    bottom: -10vh;
    right: -10vw;
    animation: blobMorphCool 25s ease-in-out infinite;
}

.blob-merge {
    width: 55vw;
    height: 55vw;
    background: rgba(201, 169, 110, 0.04);
    top: 30vh;
    left: 20vw;
    opacity: 0;
    animation: blobMorphMerge 22s ease-in-out infinite;
    transition: opacity 1.2s ease;
}

@keyframes blobMorphWarm {
    0%   { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; transform: translate(0, 0) rotate(0deg); }
    25%  { border-radius: 58% 42% 55% 45% / 45% 60% 40% 55%; transform: translate(5vw, 3vh) rotate(5deg); }
    50%  { border-radius: 40% 60% 35% 65% / 60% 40% 60% 40%; transform: translate(2vw, 8vh) rotate(-3deg); }
    75%  { border-radius: 65% 35% 50% 50% / 35% 55% 45% 65%; transform: translate(-3vw, 5vh) rotate(7deg); }
    100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; transform: translate(0, 0) rotate(0deg); }
}

@keyframes blobMorphCool {
    0%   { border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%; transform: translate(0, 0) rotate(0deg); }
    25%  { border-radius: 45% 55% 60% 40% / 55% 35% 65% 45%; transform: translate(-4vw, -5vh) rotate(-4deg); }
    50%  { border-radius: 55% 45% 40% 60% / 40% 65% 35% 55%; transform: translate(-7vw, -2vh) rotate(6deg); }
    75%  { border-radius: 35% 65% 55% 45% / 65% 45% 55% 35%; transform: translate(-2vw, -7vh) rotate(-2deg); }
    100% { border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%; transform: translate(0, 0) rotate(0deg); }
}

@keyframes blobMorphMerge {
    0%   { border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%; transform: translate(0, 0) scale(1); }
    33%  { border-radius: 40% 60% 55% 45% / 55% 40% 60% 45%; transform: translate(3vw, -2vh) scale(1.05); }
    66%  { border-radius: 60% 40% 45% 55% / 45% 60% 40% 55%; transform: translate(-2vw, 3vh) scale(0.95); }
    100% { border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%; transform: translate(0, 0) scale(1); }
}

/* Slow blobs for silence chamber */
body.in-silence .blob-warm {
    animation-duration: 120s;
}

body.in-silence .blob-cool {
    animation-duration: 120s;
}

/* --- Chamber Base --- */
.chamber {
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chamber-inner {
    position: relative;
    z-index: 2;
    width: calc(100% - var(--chamber-inset) * 2);
    height: calc(100% - var(--chamber-inset) * 2);
    margin: var(--chamber-inset);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- Chamber Numbers --- */
.chamber-number {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

.chamber-number .label {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--marble-gray);
}

/* --- Frost Channel --- */
.frost-channel {
    width: var(--frost-width);
    height: 100%;
    position: relative;
    background: var(--ice-membrane);
    -webkit-backdrop-filter: blur(20px) saturate(1.1);
    backdrop-filter: blur(20px) saturate(1.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.frost-fragment {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--marble-gray);
    opacity: 0.3;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.2em;
}

/* --- Skeleton Loading --- */
.skeleton {
    position: absolute;
    inset: 0;
    background: rgba(226, 232, 240, 0.8);
    border-radius: 4px;
    overflow: hidden;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    background-size: 200% 100%;
    animation: skeletonShimmer 2s linear infinite;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton.resolved {
    opacity: 0;
    pointer-events: none;
}

.skeleton-title {
    width: 70%;
    height: 60%;
    margin: auto;
    position: relative;
    border-radius: 50%;
}

.skeleton-block {
    position: relative;
    width: 100%;
    height: 100%;
}

.skeleton-card {
    position: relative;
    width: 100%;
    height: 100%;
}

.skeleton-quote {
    position: relative;
    width: 100%;
    height: 100%;
}

.skeleton-label {
    position: relative;
    width: 100%;
    height: 100%;
}

.skeleton-final {
    position: relative;
    width: 80%;
    height: 40%;
    margin: auto;
}

/* --- Revealed Content --- */
[data-reveal] {
    opacity: 0;
    transition: opacity 0.6s ease 0.1s;
}

[data-reveal].revealed {
    opacity: 1;
}

/* --- CHAMBER 1: THE QUESTION --- */
.chamber-question {
    background: var(--carrara-white);
}

.bauhaus-circle {
    width: min(500px, 60vw);
    height: min(500px, 60vw);
    border: 1px solid var(--veined-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: circleRotate 120s linear infinite;
}

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

.question-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    color: var(--ink-black);
    text-align: center;
    line-height: 1.1;
    letter-spacing: 0.04em;
    padding: 10%;
    animation: circleRotateReverse 120s linear infinite;
}

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

.triangle-down {
    width: 0;
    height: 0;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    border-top: 104px solid rgba(226, 232, 240, 0.4);
    margin-top: 40px;
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
}

.triangle-gold {
    border-top-color: rgba(226, 232, 240, 0.4);
}

/* --- Chamber Grid (bilateral split) --- */
.chamber-grid {
    display: grid;
    grid-template-columns: 1fr var(--frost-width) 1fr;
    width: 100%;
    height: 100%;
    gap: 0;
    margin: 0;
    align-items: stretch;
}

/* --- Panels --- */
.panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--gutter);
    position: relative;
    overflow: hidden;
}

.panel-left {
    align-items: flex-end;
    text-align: right;
}

.panel-right {
    align-items: flex-start;
    text-align: left;
}

.panel-content {
    position: relative;
}

/* Slide animations */
.panel[data-slide="left"] .panel-content {
    transform: translateX(-100vw);
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.panel[data-slide="right"] .panel-content {
    transform: translateX(100vw);
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s;
}

.panel[data-slide="left"] .panel-content.revealed {
    transform: translateX(0);
}

.panel[data-slide="right"] .panel-content.revealed {
    transform: translateX(0);
}

.panel-heading {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--ink-black);
    line-height: 1.1;
    letter-spacing: 0.04em;
    margin-bottom: 1.5rem;
}

.panel-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    color: var(--ink-black);
    line-height: 1.7;
    max-width: 480px;
}

.panel-left .panel-body {
    margin-left: auto;
}

/* Inward-pointing triangles */
.triangle-inward {
    width: 0;
    height: 0;
    margin-top: 2rem;
}

.triangle-inward.triangle-right {
    border-top: 30px solid transparent;
    border-bottom: 30px solid transparent;
    border-left: 52px solid rgba(226, 232, 240, 0.4);
    margin-left: auto;
}

.triangle-inward.triangle-left {
    border-top: 30px solid transparent;
    border-bottom: 30px solid transparent;
    border-right: 52px solid rgba(226, 232, 240, 0.4);
}

/* --- CHAMBER 3: THE WEIGHT --- */
.weight-card {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(212, 165, 165, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(123, 143, 161, 0.04) 0%, transparent 45%),
        var(--carrara-white);
    border: 1px solid rgba(226, 232, 240, 0.5);
    box-shadow: 0 8px 32px rgba(28, 31, 38, 0.12);
    padding: 2rem;
    margin: 1rem 0;
    position: relative;
    max-width: 420px;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-left {
    transform: rotate(-2deg);
    margin-left: auto;
}

.card-right {
    transform: rotate(2deg);
}

.card-left.snapped {
    transform: rotate(0deg);
}

.card-right.snapped {
    transform: rotate(0deg);
}

.weight-card h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--ink-black);
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin-bottom: 0.8rem;
}

.weight-card p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    color: var(--ink-black);
    line-height: 1.7;
}

.diamond {
    width: 12px;
    height: 12px;
    border: 1px solid var(--obsidian-marble);
    transform: rotate(45deg);
    margin-bottom: 1rem;
}

.panel-left .diamond {
    margin-left: auto;
}

.card-content {
    position: relative;
}

/* --- CHAMBER 4: THE VOICES --- */
.voice {
    position: relative;
    padding: 1.5rem 2rem;
    margin: 1rem 0;
    max-width: 440px;
    border-left: none;
    border-right: none;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.voice.revealed {
    opacity: 1;
    transform: translateY(0);
}

.voice-left {
    border-left: 3px solid var(--veined-gold);
    margin-left: auto;
    text-align: right;
    padding-left: 2rem;
    padding-right: 0;
    border-right: none;
}

.voice-right {
    border-left: 3px solid var(--slate-vein);
    text-align: left;
    padding-left: 2rem;
}

.voice p {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--ink-black);
}

.voice cite {
    display: block;
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--marble-gray);
    margin-top: 0.75rem;
    font-style: normal;
}

/* --- CHAMBER 5: THE SCALES --- */
.chamber-scales .chamber-inner {
    position: relative;
}

.scales-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.scales-above,
.scales-below {
    display: flex;
    justify-content: space-between;
    width: 80%;
    padding: 2rem 0;
}

.scale-argument {
    position: relative;
    padding: 1rem;
}

.scale-label {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-black);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.scale-label.revealed {
    opacity: 1;
}

.scales-beam {
    position: relative;
    width: 80%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.6s ease;
}

.beam-line {
    position: absolute;
    width: 100%;
    height: 1px;
    background: var(--veined-gold);
    top: 50%;
}

.beam-fulcrum {
    width: 60px;
    height: 60px;
    border: 1px solid var(--veined-gold);
    border-radius: 50%;
    background: transparent;
    position: relative;
    z-index: 3;
}

.frost-channel-horizontal {
    width: 80%;
    height: 4vh;
    writing-mode: horizontal-tb;
}

.frost-channel-horizontal .frost-fragment {
    writing-mode: horizontal-tb;
}

/* --- CHAMBER 6: THE SILENCE --- */
.chamber-silence {
    background: var(--carrara-white);
}

.chamber-grid-silence {
    display: grid;
    grid-template-columns: 1fr 60vw 1fr;
    width: 100%;
    height: 100%;
    margin: 0;
    align-items: stretch;
    padding: var(--chamber-inset);
}

.frost-channel-expanded {
    width: 100%;
    -webkit-backdrop-filter: blur(40px);
    backdrop-filter: blur(40px);
    background: rgba(226, 232, 240, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
}

.silence-question {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(6rem, 15vw, 12rem);
    color: rgba(45, 45, 52, 0.25);
    line-height: 1;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    letter-spacing: 0;
    opacity: 1;
}

.silence-side {
    background: transparent;
}

/* --- CHAMBER 7: THE REFLECTION --- */
.chamber-reflection {
    background: var(--carrara-white);
}

.reflection-panels {
    display: flex;
    width: 100%;
    position: relative;
    z-index: 2;
}

.reflection-panel {
    flex: 1;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 1.2s ease, opacity 1.2s ease;
}

.reflection-panel p {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--ink-black);
    line-height: 1.3;
    letter-spacing: 0.04em;
}

.reflection-left {
    text-align: right;
}

.reflection-right {
    text-align: left;
}

.reflection-panels.merged .reflection-left {
    transform: translateX(25%);
    opacity: 0.5;
}

.reflection-panels.merged .reflection-right {
    transform: translateX(-25%);
    opacity: 0.5;
}

.reflection-merged {
    position: relative;
    text-align: center;
    margin-top: 3rem;
    z-index: 3;
    opacity: 0;
    transition: opacity 1.2s ease 0.8s;
}

.reflection-merged.visible {
    opacity: 1;
}

.reflection-statement {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--ink-black);
    line-height: 1.5;
    letter-spacing: 0.04em;
}

.circle-final {
    width: 200px;
    height: 200px;
    border: 1px solid var(--veined-gold);
    border-radius: 50%;
    margin-top: 3rem;
    opacity: 0.3;
    animation: circleRotate 120s linear infinite;
}

/* --- Frosted Glass Panels --- */
.glass-panel {
    background: var(--ice-membrane);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* --- Hover Interactions --- */
.weight-card:hover {
    transform: rotate(0deg) translateY(-4px) scale(1.01);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.voice:hover {
    transform: translateY(-2px) scale(1.01);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reflection-panel:hover {
    transform: scale(1.02);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- Responsive: Mobile (below 768px) --- */
@media (max-width: 768px) {
    :root {
        --chamber-inset: 24px;
        --frost-width: 4vh;
    }

    .chamber-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto 1fr;
    }

    .frost-channel {
        width: 100%;
        height: 4vh;
        writing-mode: horizontal-tb;
    }

    .frost-fragment {
        writing-mode: horizontal-tb;
        text-orientation: mixed;
    }

    .panel-left,
    .panel-right {
        align-items: center;
        text-align: center;
    }

    .panel-left .panel-body,
    .panel-left .diamond {
        margin-left: auto;
        margin-right: auto;
    }

    .voice-left {
        text-align: left;
        border-left: 3px solid var(--veined-gold);
        border-right: none;
        padding-left: 2rem;
        padding-right: 0;
        margin-left: 0;
    }

    .weight-card {
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }

    .panel[data-slide="left"] .panel-content {
        transform: translateY(-50vh);
        transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .panel[data-slide="right"] .panel-content {
        transform: translateY(50vh);
        transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s;
    }

    .panel[data-slide="left"] .panel-content.revealed,
    .panel[data-slide="right"] .panel-content.revealed {
        transform: translateY(0);
    }

    .chamber-grid-silence {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 60vh 1fr;
        padding: var(--chamber-inset);
    }

    .bauhaus-circle {
        width: min(320px, 80vw);
        height: min(320px, 80vw);
    }

    .question-text {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .scales-above,
    .scales-below {
        width: 100%;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .scales-beam {
        width: 100%;
    }

    .frost-channel-horizontal {
        width: 100%;
    }

    .reflection-panels {
        flex-direction: column;
    }

    .reflection-panels.merged .reflection-left {
        transform: translateY(15%);
    }

    .reflection-panels.merged .reflection-right {
        transform: translateY(-15%);
    }

    .blob-warm,
    .blob-cool {
        width: 60vw;
        height: 60vw;
    }

    .blob-warm {
        animation-duration: 30s;
    }

    .blob-cool {
        animation-duration: 35s;
    }
}

/* --- Fallback for no backdrop-filter support --- */
@supports not (backdrop-filter: blur(1px)) {
    .frost-channel {
        background: rgba(226, 232, 240, 0.85);
    }

    .frost-channel-expanded {
        background: rgba(226, 232, 240, 0.9);
    }
}
