/* monopole.style - Hexagonal City Map Styles */
/* Palette: #1a1209, #d4a843, #3b2a1a, #f5e6c8, #5a6e7f, #a0522d, #c9a87c, #c4988a */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: radial-gradient(ellipse at center, #f5e6c8 0%, #e8d5b0 70%, #d9c49e 100%);
    color: #3b2a1a;
}

/* =========================================
   HEXAGONAL GRID LAYOUT
   ========================================= */

#hex-map {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    width: 100vw;
    height: 100vh;
    padding: 3px;
    gap: 0;
    align-content: center;
    justify-content: center;
    position: relative;
}

/* =========================================
   HEX WRAPPER - Base hex container
   ========================================= */

.hex-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1.1547;
    perspective: 800px;
    opacity: 0;
    transform: scale(0.8);
    animation: hexEntrance 0.5s ease-out forwards;
    cursor: default;
}

/* Offset odd rows (0, 2, 4) by half a hex width */
.hex-wrapper[data-row='0'],
.hex-wrapper[data-row='2'],
.hex-wrapper[data-row='4'] {
    margin-left: calc(100% / 12);
}

/* Row positioning via grid */
.hex-wrapper[data-row='0'] { grid-row: 1; }
.hex-wrapper[data-row='1'] { grid-row: 2; margin-top: -18%; }
.hex-wrapper[data-row='2'] { grid-row: 3; margin-top: -18%; }
.hex-wrapper[data-row='3'] { grid-row: 4; margin-top: -18%; }
.hex-wrapper[data-row='4'] { grid-row: 5; margin-top: -18%; }

/* Column assignment */
.hex-wrapper[data-col='0'] { grid-column: 1; }
.hex-wrapper[data-col='1'] { grid-column: 2; }
.hex-wrapper[data-col='2'] { grid-column: 3; }
.hex-wrapper[data-col='3'] { grid-column: 4; }
.hex-wrapper[data-col='4'] { grid-column: 5; }
.hex-wrapper[data-col='5'] { grid-column: 6; }

/* =========================================
   HEX CELL - Clipped hexagon with flip
   ========================================= */

.hex-cell {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.hex-cell.flipped {
    transform: rotateY(180deg);
}

.hex-front,
.hex-back {
    position: absolute;
    inset: 3px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hex-front {
    background: linear-gradient(175deg, #f5e6c8 0%, #ecdbb5 100%);
}

.hex-back {
    background: linear-gradient(175deg, #3b2a1a 0%, #2a1d10 100%);
    transform: rotateY(180deg);
    padding: 20% 12%;
    color: #f5e6c8;
}

/* =========================================
   HEX TYPE STYLES
   ========================================= */

/* Hero Hex */
.hero-hex {
    z-index: 10;
}

.hero-hex .hex-front {
    background: linear-gradient(175deg, #3b2a1a 0%, #1a1209 100%);
}

.hero-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(1rem, 2.5vw, 2.8rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #f5e6c8;
    transform: rotate(-2deg);
    text-align: center;
    line-height: 1.1;
    position: relative;
    z-index: 2;
}

.hero-dot {
    color: #d4a843;
}

.hero-subtitle {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.4rem, 0.7vw, 0.65rem);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #c9a87c;
    margin-top: 0.5em;
    position: relative;
    z-index: 2;
}

/* Hero shimmer effect */
.hero-shimmer {
    position: absolute;
    inset: -2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, transparent 30%, #d4a843 50%, transparent 70%);
    background-size: 300% 300%;
    animation: shimmer 6s linear infinite;
    opacity: 0.3;
    z-index: 1;
}

/* Hero flourishes */
.hero-flourish {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: #d4a843;
    border-style: solid;
    border-width: 0;
    z-index: 2;
    opacity: 0.6;
}

.hero-flourish.tl { top: 28%; left: 18%; border-top-width: 1px; border-left-width: 1px; }
.hero-flourish.tr { top: 28%; right: 18%; border-top-width: 1px; border-right-width: 1px; }
.hero-flourish.bl { bottom: 28%; left: 18%; border-bottom-width: 1px; border-left-width: 1px; }
.hero-flourish.br { bottom: 28%; right: 18%; border-bottom-width: 1px; border-right-width: 1px; }

/* Hero pulse */
.hero-hex .hex-cell {
    animation: heroPulse 3s ease-in-out infinite;
}

/* District Hex */
.district-hex {
    cursor: pointer;
}

.district-hex .hex-front {
    background: linear-gradient(175deg, #f5e6c8 0%, #e8d5b0 100%);
    transition: all 0.2s ease;
}

.district-name {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(0.5rem, 1.2vw, 1rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #a0522d;
    text-align: center;
    position: relative;
    z-index: 2;
    transition: color 0.2s ease;
    padding: 0 8%;
    line-height: 1.3;
}

.district-description {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.55rem, 0.9vw, 0.85rem);
    line-height: 1.65;
    letter-spacing: 0.02em;
    color: #f5e6c8;
    text-align: center;
    margin-bottom: 8%;
}

.back-mini-viz {
    width: 60%;
    height: auto;
    margin-bottom: 5%;
}

.hex-close {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 1.2rem);
    color: #c9a87c;
    background: none;
    border: 1px solid #c9a87c;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.hex-close:hover {
    color: #d4a843;
    border-color: #d4a843;
}

/* District hover effects */
.district-hex:hover .hex-front {
    background: linear-gradient(175deg, #f0e0c0 0%, #e0d0a5 100%);
}

.district-hex:hover .district-name {
    color: #d4a843;
}

.district-hex:hover {
    transform: scale(1.05);
    z-index: 5;
    filter: drop-shadow(0 0 8px rgba(212, 168, 67, 0.4));
}

/* Data Hex */
.data-hex .hex-front {
    background: linear-gradient(175deg, #f5e6c8 0%, #eedcc0 100%);
}

.data-viz {
    width: 70%;
    height: 70%;
}

.hex-metric-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.35rem, 0.55vw, 0.5rem);
    letter-spacing: 0.05em;
    color: #5a6e7f;
    position: absolute;
    bottom: 30%;
    text-align: center;
}

/* Empty Hex */
.empty-hex {
    pointer-events: none;
}

.empty-hex .hex-front {
    background: linear-gradient(175deg, #f5e6c8 0%, #ecdbb5 100%);
    opacity: 0.3;
}

/* Nav Hex */
.nav-hex {
    cursor: pointer;
}

.nav-hex .hex-front {
    background: linear-gradient(175deg, #3b2a1a 0%, #2a1d10 100%);
}

.nav-icon {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(1.2rem, 2vw, 2rem);
    color: #d4a843;
}

.nav-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.35rem, 0.55vw, 0.5rem);
    letter-spacing: 0.3em;
    color: #c9a87c;
    margin-top: 4px;
}

.nav-description {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.55rem, 0.9vw, 0.85rem);
    line-height: 1.65;
    color: #f5e6c8;
    text-align: center;
    margin-bottom: 10%;
}

.nav-hex:hover {
    transform: scale(1.05);
    z-index: 5;
    filter: drop-shadow(0 0 8px rgba(212, 168, 67, 0.4));
}

/* =========================================
   HEX PATTERNS (CSS backgrounds)
   ========================================= */

.hex-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.15;
    z-index: 1;
}

.diagonal-stripes {
    background: repeating-linear-gradient(
        45deg,
        #a0522d,
        #a0522d 2px,
        transparent 2px,
        transparent 12px
    );
}

.diagonal-stripes.reverse {
    background: repeating-linear-gradient(
        -45deg,
        #a0522d,
        #a0522d 2px,
        transparent 2px,
        transparent 12px
    );
}

.concentric-hex {
    background:
        conic-gradient(from 0deg at 50% 50%, transparent 0deg, #a0522d 1deg, #a0522d 2deg, transparent 3deg) 50% 50% / 80% 80% no-repeat,
        conic-gradient(from 0deg at 50% 50%, transparent 0deg, #a0522d 1deg, #a0522d 2deg, transparent 3deg) 50% 50% / 60% 60% no-repeat,
        conic-gradient(from 0deg at 50% 50%, transparent 0deg, #a0522d 1deg, #a0522d 2deg, transparent 3deg) 50% 50% / 40% 40% no-repeat;
    background: repeating-radial-gradient(
        circle at center,
        transparent 0px,
        transparent 10px,
        #a0522d 10px,
        #a0522d 11px
    );
}

.dot-grid {
    background: radial-gradient(circle, #a0522d 1.5px, transparent 1.5px);
    background-size: 10px 10px;
}

.street-grid {
    background:
        linear-gradient(0deg, #c9a87c 0.5px, transparent 0.5px),
        linear-gradient(90deg, #c9a87c 0.5px, transparent 0.5px);
    background-size: 14px 14px;
    transform: rotate(30deg);
}

.window-grid {
    background:
        linear-gradient(0deg, #3b2a1a 2px, transparent 2px),
        linear-gradient(90deg, #3b2a1a 2px, transparent 2px),
        linear-gradient(0deg, #d4a843 1px, transparent 1px);
    background-size: 8px 10px, 8px 10px, 4px 5px;
}

.contour-lines {
    background: repeating-radial-gradient(
        circle at center,
        transparent 0px,
        transparent 15px,
        #c9a87c 15px,
        #c9a87c 16px
    );
}

.noise-texture {
    background: radial-gradient(circle, #c9a87c 0.5px, transparent 0.5px);
    background-size: 4px 4px;
    opacity: 0.4;
}

/* Halftone overlay for some hexes */
.district-hex .hex-front::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, #3b2a1a 0.5px, transparent 0.5px);
    background-size: 4px 4px;
    opacity: 0.03;
    pointer-events: none;
    mix-blend-mode: multiply;
}

/* =========================================
   ANIMATIONS
   ========================================= */

@keyframes hexEntrance {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes heroPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

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

@keyframes arcSweep {
    to { stroke-dashoffset: var(--target-offset); }
}

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

@keyframes gaugeNeedle {
    to { transform: rotate(var(--target-rotation)); }
}

@keyframes gaugeFill {
    to { stroke-dashoffset: var(--gauge-target); }
}

/* Data animation classes - applied via JS */
.arc-fill.animate {
    animation: arcSweep 1.2s ease-out forwards;
}

.sparkline.animate {
    animation: sparkDraw 1.5s ease-out forwards;
}

.gauge-needle.animate {
    animation: gaugeNeedle 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.gauge-fill.animate {
    animation: gaugeFill 1.2s ease-out forwards;
}

/* Data hex hover - speed up animations */
.data-hex:hover .data-viz {
    animation-duration: 0.5s !important;
}

/* =========================================
   DOT MATRIX (generated via JS)
   ========================================= */

.dot-matrix circle {
    transition: opacity 0.3s ease;
}

/* =========================================
   RESPONSIVE - Mobile (< 768px)
   ========================================= */

@media (max-width: 768px) {
    html, body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    #hex-map {
        grid-template-columns: repeat(3, 1fr);
        height: auto;
        min-height: 100vh;
        padding: 10px;
    }

    .hex-wrapper {
        min-width: 100px;
    }

    /* Reassign columns for 3-col layout */
    .hex-wrapper[data-col='0'] { grid-column: 1; }
    .hex-wrapper[data-col='1'] { grid-column: 2; }
    .hex-wrapper[data-col='2'] { grid-column: 3; }
    .hex-wrapper[data-col='3'] { grid-column: 1; }
    .hex-wrapper[data-col='4'] { grid-column: 2; }
    .hex-wrapper[data-col='5'] { grid-column: 3; }

    /* Reset row-based grid positioning for auto-flow */
    .hex-wrapper[data-row='0'],
    .hex-wrapper[data-row='1'],
    .hex-wrapper[data-row='2'],
    .hex-wrapper[data-row='3'],
    .hex-wrapper[data-row='4'] {
        grid-row: auto;
        margin-top: 0;
    }

    /* Offset alternate rows on mobile */
    .hex-wrapper[data-col='0'],
    .hex-wrapper[data-col='3'] {
        margin-left: 0;
    }

    .hex-wrapper[data-row='0'],
    .hex-wrapper[data-row='2'],
    .hex-wrapper[data-row='4'] {
        margin-left: calc(100% / 6);
    }

    /* Card flip uses rotateX on mobile */
    .hex-cell.flipped {
        transform: rotateX(180deg);
    }

    .hex-back {
        transform: rotateX(180deg);
    }

    .hero-title {
        font-size: clamp(0.9rem, 4vw, 1.8rem);
    }
}

/* =========================================
   UTILITY
   ========================================= */

/* Prevent text selection on hex cells */
.hex-wrapper {
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection on back faces */
.hex-back {
    -webkit-user-select: text;
    user-select: text;
}