/* xity.quest — Hexagonal Quest Descent */

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

:root {
    --ember: #FF6B35;
    --ember-ground: #1A0A00;
    --jade: #2EC4B6;
    --jade-ground: #0A1A18;
    --violet: #9B5DE5;
    --violet-ground: #1A0A2E;
    --gold: #F0C040;
    --gold-ground: #1A1400;
    --frost: #A8D8EA;
    --frost-ground: #0A1420;
    --parchment: #E8E0D0;
    --charcoal: #2A2A2A;
    --passage-dark: #0D0D0D;

    --district-accent: var(--ember);
    --district-ground: var(--ember-ground);

    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);

    --hex-sm: 120px;
    --hex-md: 180px;
    --hex-lg: 240px;
}

html, body {
    background-color: var(--district-ground);
    color: var(--parchment);
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    line-height: 1.65;
    transition: background-color 200ms ease;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
}

.quest {
    width: 100%;
    overflow-x: hidden;
}

/* ---------- Prologue ---------- */

.prologue {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(ellipse at center, #1A0A00 0%, #050200 80%);
    overflow: hidden;
}

.prologue-title {
    font-family: 'Bungee', cursive;
    font-size: clamp(48px, 10vw, 120px);
    color: var(--ember);
    letter-spacing: 0.04em;
    text-shadow: 4px 4px 0 #2A0500, 8px 8px 0 rgba(0,0,0,0.5);
    z-index: 2;
}

.prologue-title .dot {
    color: var(--frost);
    animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.prologue-sub {
    font-family: 'Caveat', cursive;
    font-size: 26px;
    color: var(--parchment);
    margin-top: 18px;
    z-index: 2;
}

.prologue-coord {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    color: rgba(232, 224, 208, 0.6);
    margin-top: 28px;
    letter-spacing: 0.1em;
    z-index: 2;
}

.scroll-cue {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}

.cue-arrow {
    width: 14px;
    height: 14px;
    border-right: 2px solid var(--ember);
    border-bottom: 2px solid var(--ember);
    transform: rotate(45deg);
    opacity: 0.3;
    animation: cue-bob 1.6s infinite ease-in-out;
}

.cue-arrow:nth-child(2) { animation-delay: 0.2s; }
.cue-arrow:nth-child(3) { animation-delay: 0.4s; }

@keyframes cue-bob {
    0%, 100% { opacity: 0.3; transform: rotate(45deg) translate(-2px, -2px); }
    50% { opacity: 1; transform: rotate(45deg) translate(2px, 2px); }
}

/* ---------- Compass Rose ---------- */

.compass-rose {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 420px;
    height: 420px;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    animation: rose-rotate 60s linear infinite;
    pointer-events: none;
    z-index: 1;
}

.rose-line {
    position: absolute;
    top: 50%;
    left: 50%;
    background: var(--ember);
    transform-origin: 0 0;
}

.rose-n, .rose-s {
    width: 2px;
    height: 200px;
    margin-top: -100px;
    margin-left: -1px;
}

.rose-e, .rose-w {
    width: 200px;
    height: 2px;
    margin-top: -1px;
    margin-left: -100px;
}

.rose-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 360px;
    height: 360px;
    margin: -180px 0 0 -180px;
    border: 1px solid var(--ember);
    border-radius: 50%;
}

.rose-ring-inner {
    width: 240px;
    height: 240px;
    margin: -120px 0 0 -120px;
    border-style: dashed;
}

.rose-pip {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: var(--ember);
}

@keyframes rose-rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ---------- District ---------- */

.district {
    min-height: 150vh;
    padding: 120px 40px 100px;
    position: relative;
    background: var(--district-ground);
    overflow: hidden;
    transition: background-color 200ms ease;
}

.district-ember { --district-accent: var(--ember); --district-ground: var(--ember-ground); background: var(--ember-ground); }
.district-jade { --district-accent: var(--jade); --district-ground: var(--jade-ground); background: var(--jade-ground); }
.district-violet { --district-accent: var(--violet); --district-ground: var(--violet-ground); background: var(--violet-ground); }
.district-gold { --district-accent: var(--gold); --district-ground: var(--gold-ground); background: var(--gold-ground); }
.district-frost { --district-accent: var(--frost); --district-ground: var(--frost-ground); background: var(--frost-ground); }

.district-rose {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 380px;
    height: 380px;
    border: 1px solid var(--district-accent);
    border-radius: 50%;
    opacity: 0.15;
    pointer-events: none;
}

.district-rose::before,
.district-rose::after {
    content: "";
    position: absolute;
    background: var(--district-accent);
}

.district-rose::before {
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    margin-left: -0.5px;
}

.district-rose::after {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    margin-top: -0.5px;
}

.district-head {
    position: relative;
    z-index: 5;
    text-align: center;
    margin-bottom: 80px;
}

.district-index {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    color: var(--district-accent);
    opacity: 0.7;
    display: block;
    margin-bottom: 14px;
    letter-spacing: 0.2em;
}

.district-name {
    font-family: 'Bungee', cursive;
    font-size: clamp(40px, 7vw, 80px);
    color: var(--district-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 4px 4px 0 rgba(0,0,0,0.4);
}

.district-tag {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    color: var(--parchment);
    margin-top: 16px;
    opacity: 0.85;
}

/* ---------- Honeycomb Grid ---------- */

.honeycomb {
    position: relative;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(auto-fit, var(--hex-md));
    gap: 24px 18px;
    justify-content: center;
    padding: 0 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.hex {
    position: relative;
    width: var(--hex-md);
    height: calc(var(--hex-md) * 1.155);
    clip-path: var(--hex-clip);
    background: var(--district-accent);
    box-shadow: 3px 3px 10px rgba(0,0,0,0.5);
    transform: scale(0.7);
    opacity: 0;
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 400ms ease, filter 250ms ease;
}

.hex.is-visible {
    transform: scale(1);
    opacity: 1;
}

.hex:hover {
    filter: brightness(1.15);
    cursor: pointer;
}

.hex-sm { width: var(--hex-sm); height: calc(var(--hex-sm) * 1.155); }
.hex-md { width: var(--hex-md); height: calc(var(--hex-md) * 1.155); }
.hex-lg { width: var(--hex-lg); height: calc(var(--hex-lg) * 1.155); grid-column: span 2; }

.honeycomb > .hex:nth-child(2n) {
    margin-top: 36px;
}

.hex-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18%;
    text-align: center;
    background: var(--district-ground);
    clip-path: var(--hex-clip);
    margin: 4px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
}

/* Lore cells: parchment background */
.cell-lore .hex-inner {
    background: var(--parchment);
    color: var(--charcoal);
}

.cell-lore .lore {
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--charcoal);
}

.hex-lg.cell-lore .lore {
    font-size: 16px;
}

.cell-lore .waypoint {
    margin-top: 10px;
    color: var(--district-accent);
}

/* Waypoint cells: dark with pixel labels */
.cell-waypoint .hex-inner {
    background: var(--district-ground);
}

.cell-waypoint .waypoint {
    color: var(--district-accent);
    opacity: 0.85;
    font-size: 10px;
    margin: 3px 0;
}

.waypoint {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    color: var(--district-accent);
    opacity: 0.7;
    letter-spacing: 0.1em;
}

/* Iso cells */
.cell-iso .hex-inner {
    background: var(--district-ground);
    perspective: 600px;
}

.cell-iso .waypoint {
    position: absolute;
    bottom: 22%;
    font-size: 8px;
}

/* End cell */
.cell-end .hex-inner {
    background: var(--frost);
    color: var(--frost-ground);
}

.end-word {
    font-family: 'Press Start 2P', cursive;
    font-size: 28px;
    color: var(--frost-ground);
    letter-spacing: 0.1em;
    animation: end-blink 1.4s infinite step-end;
}

@keyframes end-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* ---------- Isometric Buildings ---------- */

.iso-building {
    position: relative;
    width: 56px;
    height: 56px;
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateZ(-45deg);
}

.iso-face {
    position: absolute;
    background: var(--district-accent);
}

.iso-top {
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    background: var(--district-accent);
    transform: translateZ(28px);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}

.iso-left {
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    background: color-mix(in srgb, var(--district-accent) 70%, black);
    transform: rotateY(-90deg) translateZ(0px);
    transform-origin: left center;
}

.iso-right {
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    background: color-mix(in srgb, var(--district-accent) 50%, black);
    transform: rotateX(90deg) translateZ(0px);
    transform-origin: center bottom;
}

/* Specific building variants */

.iso-warehouse { width: 64px; height: 32px; }
.iso-warehouse .iso-top { width: 64px; height: 32px; transform: translateZ(20px); }
.iso-warehouse .iso-left { width: 64px; height: 20px; }
.iso-warehouse .iso-right { width: 32px; height: 20px; }

.iso-warehouse-tall { width: 48px; height: 40px; }
.iso-warehouse-tall .iso-top { width: 48px; height: 40px; transform: translateZ(28px); }
.iso-warehouse-tall .iso-left { width: 48px; height: 28px; }
.iso-warehouse-tall .iso-right { width: 40px; height: 28px; }

.iso-forge { width: 40px; height: 40px; }
.iso-forge .iso-top { width: 40px; height: 40px; transform: translateZ(36px); }
.iso-forge .iso-left { width: 40px; height: 36px; }
.iso-forge .iso-right { width: 40px; height: 36px; }

.iso-pagoda { width: 48px; height: 48px; }
.iso-pagoda .iso-top { width: 48px; height: 48px; transform: translateZ(24px); }
.iso-pagoda .iso-left { width: 48px; height: 24px; }
.iso-pagoda .iso-right { width: 48px; height: 24px; }
.iso-pagoda .iso-top-2 { width: 36px; height: 36px; left: 6px; top: 6px; transform: translateZ(48px); }
.iso-pagoda .iso-left-2 { width: 36px; height: 24px; left: 6px; top: 6px; transform: rotateY(-90deg) translateZ(-6px); }
.iso-pagoda .iso-right-2 { width: 36px; height: 24px; left: 6px; top: 6px; transform: rotateX(90deg) translateZ(-6px); }

.iso-pagoda-tall { width: 36px; height: 36px; }
.iso-pagoda-tall .iso-top { width: 36px; height: 36px; transform: translateZ(54px); }
.iso-pagoda-tall .iso-left { width: 36px; height: 54px; }
.iso-pagoda-tall .iso-right { width: 36px; height: 54px; }

.iso-tower { width: 32px; height: 32px; }
.iso-tower .iso-top { width: 32px; height: 32px; transform: translateZ(64px); }
.iso-tower .iso-left { width: 32px; height: 64px; }
.iso-tower .iso-right { width: 32px; height: 64px; }

.iso-inverted { width: 56px; height: 56px; transform: rotateX(55deg) rotateZ(-45deg) rotateY(180deg); }
.iso-inverted .iso-top { transform: translateZ(36px); }
.iso-inverted-sm { width: 36px; height: 36px; }
.iso-inverted-sm .iso-top { width: 36px; height: 36px; transform: translateZ(24px); }
.iso-inverted-sm .iso-left { width: 36px; height: 24px; }
.iso-inverted-sm .iso-right { width: 36px; height: 24px; }

.iso-floatcube { width: 44px; height: 44px; animation: float-bob 3.5s ease-in-out infinite; }
.iso-floatcube .iso-top { width: 44px; height: 44px; transform: translateZ(44px); }
.iso-floatcube .iso-left { width: 44px; height: 44px; }
.iso-floatcube .iso-right { width: 44px; height: 44px; }

@keyframes float-bob {
    0%, 100% { transform: rotateX(55deg) rotateZ(-45deg) translateZ(0px); }
    50% { transform: rotateX(55deg) rotateZ(-45deg) translateZ(8px); }
}

.iso-stall { width: 56px; height: 28px; }
.iso-stall .iso-top { width: 56px; height: 28px; transform: translateZ(18px); }
.iso-stall .iso-left { width: 56px; height: 18px; }
.iso-stall .iso-right { width: 28px; height: 18px; }

.iso-stall-tall { width: 36px; height: 36px; }
.iso-stall-tall .iso-top { width: 36px; height: 36px; transform: translateZ(40px); }
.iso-stall-tall .iso-left { width: 36px; height: 40px; }
.iso-stall-tall .iso-right { width: 36px; height: 40px; }

.iso-bazaar { width: 56px; height: 56px; }
.iso-bazaar .iso-top { width: 56px; height: 56px; transform: translateZ(20px); }
.iso-bazaar .iso-left { width: 56px; height: 20px; }
.iso-bazaar .iso-right { width: 56px; height: 20px; }
.iso-bazaar .iso-top-2 { width: 30px; height: 30px; left: 13px; top: 13px; transform: translateZ(40px); }

.iso-gate { width: 60px; height: 40px; }
.iso-gate .iso-top { width: 60px; height: 40px; transform: translateZ(50px); }
.iso-gate .iso-left { width: 60px; height: 50px; }
.iso-gate .iso-right { width: 40px; height: 50px; }

.iso-gate-2 { width: 48px; height: 48px; }
.iso-gate-2 .iso-top { width: 48px; height: 48px; transform: translateZ(56px); }
.iso-gate-2 .iso-left { width: 48px; height: 56px; }
.iso-gate-2 .iso-right { width: 48px; height: 56px; }

/* ---------- Quest Path SVG ---------- */

.quest-path {
    position: absolute;
    top: 280px;
    left: 0;
    width: 100%;
    height: calc(100% - 320px);
    pointer-events: none;
    z-index: 2;
    opacity: 0.55;
}

.quest-path path {
    fill: none;
    stroke: var(--district-accent);
    stroke-width: 2;
    stroke-dasharray: 6 8;
    stroke-linecap: round;
    animation: marching-ants 2s linear infinite;
}

@keyframes marching-ants {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -28; }
}

/* ---------- Passage ---------- */

.passage {
    background: var(--passage-dark);
    padding: 80px 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
    transition: max-width 600ms ease;
}

.passage-text {
    font-family: 'Caveat', cursive;
    font-size: 24px;
    line-height: 1.5;
    color: var(--parchment);
    max-width: 100%;
    text-align: center;
    margin: 0 auto;
    opacity: 0.6;
    transition: max-width 600ms ease, opacity 600ms ease;
}

.passage.is-visible .passage-text {
    max-width: 400px;
    opacity: 1;
}

.passage::before {
    content: "✦";
    display: block;
    text-align: center;
    color: var(--parchment);
    font-size: 18px;
    opacity: 0.4;
    margin-bottom: 18px;
    width: 100%;
}

/* ---------- Progress indicator ---------- */

.progress {
    position: fixed;
    top: 50%;
    right: 24px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 50;
    padding: 12px 8px;
}

.progress-pip {
    width: 10px;
    height: 10px;
    clip-path: var(--hex-clip);
    background: rgba(232, 224, 208, 0.25);
    transition: background 300ms ease, transform 300ms ease;
}

.progress-pip.is-current {
    background: var(--district-accent);
    transform: scale(1.4);
}

.progress-pip.is-passed {
    background: rgba(232, 224, 208, 0.6);
}

/* ---------- Light district adjustments ---------- */

.district-frost .lore { color: var(--charcoal); }
.district-frost .district-tag { color: var(--parchment); }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
    :root {
        --hex-sm: 96px;
        --hex-md: 132px;
        --hex-lg: 168px;
    }
    .honeycomb {
        gap: 16px 10px;
        padding: 0 10px;
    }
    .district { padding: 80px 16px 60px; }
    .progress { right: 10px; gap: 10px; }
    .district-rose { width: 240px; height: 240px; top: 50px; }
    .compass-rose { width: 280px; height: 280px; }
    .rose-n, .rose-s { height: 120px; margin-top: -60px; }
    .rose-e, .rose-w { width: 120px; margin-left: -60px; }
    .rose-ring { width: 240px; height: 240px; margin: -120px 0 0 -120px; }
    .rose-ring-inner { width: 160px; height: 160px; margin: -80px 0 0 -80px; }
}
