/* ============================================
   diplomacy.quest - Cotton-Candy Statecraft
   HUD-overlay pastel diplomatic landscape
   ============================================ */

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

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

body {
    font-family: 'Inter', sans-serif;
    color: #5B5278;
    background: #F7F0FF;
    overflow-x: hidden;
    min-height: 400vh;
}

/* --- Layer 0: Background Canvas --- */
#background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(135deg, #FDE2E4, #E2ECF7, #D4F0D3, #FDE2E4, #E2ECF7, #D4F0D3);
    background-size: 400% 400%;
    animation: gradientCycle 45s ease infinite;
}

@keyframes gradientCycle {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 0%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 100%; }
    100% { background-position: 0% 50%; }
}

/* --- Layer 1: Wave Terrain --- */
#wave-terrain {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 45%;
    z-index: 1;
    pointer-events: none;
}

#wave-terrain path {
    fill: none;
    stroke-width: 2;
    opacity: 0.5;
}

/* --- Layer 2: HUD Frame --- */
#hud-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#hud-brackets {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hud-bracket {
    fill: none;
    stroke: #E8D5F0;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawBracket 1.8s ease-out forwards;
}

.bracket-tl { animation-delay: 0s; }
.bracket-tr { animation-delay: 0.2s; }
.bracket-bl { animation-delay: 0.4s; }
.bracket-br { animation-delay: 0.6s; }

@keyframes drawBracket {
    to { stroke-dashoffset: 0; }
}

.hud-horizon {
    stroke: #E8D5F0;
    stroke-width: 0.5;
    opacity: 0.5;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawHorizon 2.5s ease-out 0.8s forwards;
}

@keyframes drawHorizon {
    to { stroke-dashoffset: 0; }
}

/* HUD Labels */
.hud-label {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #B8A9C8;
    opacity: 0.7;
    pointer-events: none;
}

.hud-label-tl { top: 40px; left: 45px; }
.hud-label-tr { top: 40px; right: 45px; }
.hud-label-bl { bottom: 40px; left: 45px; }
.hud-label-br { bottom: 40px; right: 45px; }
.hud-label-top-center { top: 15%; left: 50%; transform: translateX(-50%); }
.hud-label-bottom-left { bottom: 70px; left: 45px; }

/* --- Protocol Ribbons --- */
#protocol-ribbons {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

#protocol-ribbons path {
    fill: none;
    stroke: #B8A9C8;
    stroke-width: 1;
    opacity: 0.3;
}

/* --- Layer 3: Content Area --- */
#content-flow {
    position: relative;
    z-index: 5;
    width: 100%;
}

.content-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    position: relative;
}

/* --- Typography --- */
.display-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(36px, 6vw, 68px);
    letter-spacing: -0.02em;
    color: #4A3F6B;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.8s ease-out 1.5s forwards;
}

.subtitle {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.65;
    color: #5B5278;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.8s ease-out 1.8s forwards;
    margin-top: 16px;
}

.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(22px, 3vw, 40px);
    color: #4A3F6B;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Opening Section --- */
#opening {
    min-height: 100vh;
    justify-content: center;
    text-align: center;
}

/* --- Glass Panels --- */
.glass-panel {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #E0D0F0;
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 520px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    animation: panelFloat 6s ease-in-out infinite;
}

.glass-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

@supports not (backdrop-filter: blur(8px)) {
    .glass-panel {
        background: rgba(247, 240, 255, 0.85);
    }
}

@keyframes panelFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.glass-panel.visible {
    animation: panelFloat 6s ease-in-out infinite;
}

.glass-panel p {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.65;
    color: #5B5278;
}

/* --- Handshake Section --- */
#handshake-section {
    min-height: 180vh;
    padding-top: 100vh;
}

#handshake-glyph {
    width: min(700px, 85vw);
    height: auto;
    margin-bottom: 60px;
}

.handshake-path {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.05s linear;
}

.handshake-panels {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    max-width: 65vw;
}

.handshake-panels .glass-panel {
    flex: 1 1 280px;
    max-width: 340px;
}

/* --- Round Table Section --- */
#round-table-section {
    min-height: 280vh;
    padding-top: 60px;
    gap: 60px;
}

#round-table-container {
    width: 320px;
    height: 320px;
    position: relative;
    margin: 40px auto;
}

.orbital-ring {
    width: 100%;
    height: 100%;
    position: relative;
    animation: orbitSpin 120s linear infinite;
}

@keyframes orbitSpin {
    to { transform: rotate(360deg); }
}

.orbital-shape {
    position: absolute;
    width: 28px;
    height: 28px;
    top: 50%;
    left: 50%;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.orbital-shape.visible {
    opacity: 1;
}

.shape-circle {
    border-radius: 50%;
}

.shape-rounded-rect {
    border-radius: 6px;
}

.shape-soft-tri {
    border-radius: 4px;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

/* Color assignments for orbital shapes */
.orbital-shape:nth-child(1) { background: #FDE2E4; }
.orbital-shape:nth-child(2) { background: #AEDFF7; }
.orbital-shape:nth-child(3) { background: #C9B1FF; }
.orbital-shape:nth-child(4) { background: #FFD6BA; }
.orbital-shape:nth-child(5) { background: #D4F0D3; }
.orbital-shape:nth-child(6) { background: #E0D0F0; }
.orbital-shape:nth-child(7) { background: #FDE2E4; }
.orbital-shape:nth-child(8) { background: #AEDFF7; }
.orbital-shape:nth-child(9) { background: #C9B1FF; }
.orbital-shape:nth-child(10) { background: #FFD6BA; }

.round-table-panels {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    justify-content: center;
    max-width: 65vw;
}

.round-table-panels .glass-panel {
    flex: 1 1 280px;
    max-width: 380px;
}

/* --- Bridge Section --- */
#bridge-section {
    min-height: 180vh;
    gap: 40px;
}

.bridge-svg {
    width: min(600px, 80vw);
    height: auto;
    margin: 20px auto;
    display: block;
}

.bridge-curve {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 0.8s ease-out;
}

.bridge-curve.drawn {
    stroke-dashoffset: 0;
}

.bridge-suspender {
    stroke-width: 1;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.5s ease-out;
}

.bridge-suspender.drawn {
    stroke-dashoffset: 0;
}

.bridge-anchor {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.bridge-anchor.visible {
    opacity: 1;
}

.bridge-text-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    max-width: 65vw;
    margin: 20px auto;
}

.bridge-panel-left,
.bridge-panel-right {
    flex: 1 1 260px;
    max-width: 340px;
}

/* --- Closing Section --- */
#closing-section {
    min-height: 100vh;
}

.closing-panel {
    max-width: 560px;
    border: 2px solid #C9B1FF;
    text-align: center;
}

.closing-panel .section-heading {
    color: #4A3F6B;
}

/* --- Scroll Progress Indicators --- */
#scroll-indicators {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    gap: 12px;
}

.scroll-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid #B8A9C8;
    background: transparent;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.scroll-dot.active {
    background: #C9B1FF;
    border-color: #C9B1FF;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .handshake-panels,
    .round-table-panels,
    .bridge-text-pair {
        max-width: 90vw;
    }

    .glass-panel {
        max-width: 90vw;
        padding: 20px 24px;
    }

    .hud-label {
        font-size: 8px;
    }

    #round-table-container {
        width: 240px;
        height: 240px;
    }

    .content-section {
        padding: 40px 20px;
    }
}
