/* ============================================
   mang.quest — Brutalist Network Topology
   ============================================ */

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

:root {
    --concrete-gray: #A0988A;
    --dark-concrete: #5A5248;
    --burnt-orange: #D4763A;
    --amber-bright: #E8A050;
    --off-white: #F0E8D8;
    --deep-charcoal: #2A2A28;
    --rust-red: #A05030;

    --hex-width: 180px;
    --hex-height: 208px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(13px, 0.9vw, 16px);
    line-height: 1.6;
    color: var(--off-white);
    background: var(--concrete-gray);
    overflow-x: hidden;
}

/* ---------- Concrete Texture (CSS noise) ---------- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.08;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* ---------- Typography ---------- */
.mono-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--amber-bright);
}

h1, h2, h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--off-white);
}

/* ============================================
   HERO SECTION
   ============================================ */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6vw;
    background: var(--concrete-gray);
    overflow: hidden;
    z-index: 1;
}

#hero-content {
    position: relative;
    z-index: 2;
    max-width: 60%;
}

#logotype {
    font-size: clamp(48px, 10vw, 160px);
    line-height: 0.9;
    color: var(--deep-charcoal);
    text-shadow: 3px 3px 0 rgba(212, 118, 58, 0.3);
}

#logotype .dot {
    color: var(--burnt-orange);
}

#hero-subtitle {
    margin-top: 20px;
    font-size: 13px;
    color: var(--dark-concrete);
    letter-spacing: 0.12em;
}

/* ---------- Minimap ---------- */
#hero-minimap {
    position: relative;
    z-index: 2;
    width: 300px;
    height: 260px;
    flex-shrink: 0;
}

#minimap-svg {
    width: 100%;
    height: 100%;
}

.minimap-hex {
    fill: none;
    stroke: var(--burnt-orange);
    stroke-width: 2;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: minimap-draw 1.5s ease-out forwards;
}

.minimap-hex[data-index="0"] { animation-delay: 0s; }
.minimap-hex[data-index="1"] { animation-delay: 0.15s; }
.minimap-hex[data-index="2"] { animation-delay: 0.3s; }
.minimap-hex[data-index="3"] { animation-delay: 0.45s; }
.minimap-hex[data-index="4"] { animation-delay: 0.6s; }
.minimap-hex[data-index="5"] { animation-delay: 0.75s; }
.minimap-hex[data-index="6"] { animation-delay: 0.9s; }
.minimap-hex[data-index="7"] { animation-delay: 1.05s; }

@keyframes minimap-draw {
    to {
        stroke-dashoffset: 0;
    }
}

.minimap-line {
    stroke: var(--burnt-orange);
    stroke-width: 1.5;
    opacity: 0;
    animation: minimap-line-in 0.8s ease-out forwards;
    animation-delay: 1.5s;
}

@keyframes minimap-line-in {
    to {
        opacity: 0.7;
    }
}

.minimap-endpoint {
    fill: var(--burnt-orange);
    opacity: 0;
    animation: minimap-line-in 0.8s ease-out forwards;
    animation-delay: 1.8s;
}

/* ---------- Organic Blobs ---------- */
.blob {
    position: absolute;
    border-radius: 50%;
    background: rgba(90, 82, 72, 0.15);
    filter: blur(40px);
    pointer-events: none;
    z-index: 0;
}

.blob-1 {
    width: 400px;
    height: 400px;
    top: -100px;
    right: 20%;
}

.blob-2 {
    width: 350px;
    height: 300px;
    bottom: -50px;
    left: 10%;
}

.blob-3 {
    width: 500px;
    height: 500px;
    top: 5%;
    left: -5%;
}

.blob-4 {
    width: 400px;
    height: 450px;
    top: 40%;
    right: -8%;
}

.blob-5 {
    width: 350px;
    height: 350px;
    bottom: 5%;
    left: 30%;
}

/* ============================================
   HEXAGONAL GRID SECTION
   ============================================ */
#hex-grid-section {
    position: relative;
    padding: 80px 4vw 120px;
    min-height: 100vh;
    z-index: 1;
}

/* SVG Connection Lines Overlay */
#connection-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

#connection-lines line {
    stroke: var(--burnt-orange);
    stroke-width: 2;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

#connection-lines line.highlight {
    opacity: 1;
}

#connection-lines circle {
    fill: var(--burnt-orange);
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

#connection-lines circle.highlight {
    opacity: 1;
}

/* ---------- Hex Grid Layout ---------- */
#hex-grid {
    display: grid;
    grid-template-columns: repeat(4, var(--hex-width));
    grid-template-rows: repeat(4, calc(var(--hex-height) * 0.75));
    gap: 8px 12px;
    justify-content: center;
    position: relative;
    z-index: 2;
    max-width: 900px;
    margin: 0 auto;
}

/* Odd rows shifted for honeycomb */
.hex-cell[data-row="1"],
.hex-cell[data-row="3"] {
    transform: translateX(calc(var(--hex-width) / 2 + 6px));
}

/* ---------- Hexagonal Cells ---------- */
.hex-cell {
    position: relative;
    width: var(--hex-width);
    height: var(--hex-height);
    cursor: pointer;
    transition: transform 0.4s ease-out, z-index 0s;
    opacity: 0;
    transform-origin: center center;
}

.hex-cell.visible {
    opacity: 1;
}

.hex-cell.hovered {
    z-index: 5;
}

.hex-cell.hovered .hex-inner {
    background: var(--dark-concrete);
}

.hex-cell.connected {
    transform: scale(1.08);
}

.hex-cell[data-row="1"].connected,
.hex-cell[data-row="3"].connected {
    transform: translateX(calc(var(--hex-width) / 2 + 6px)) scale(1.08);
}

/* Expanded state */
.hex-cell.expanded {
    transform: scale(2);
    z-index: 10;
}

.hex-cell[data-row="1"].expanded,
.hex-cell[data-row="3"].expanded {
    transform: translateX(calc(var(--hex-width) / 2 + 6px)) scale(2);
    z-index: 10;
}

/* Hex border (pseudo-element behind) */
.hex-border {
    position: absolute;
    inset: -2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--burnt-orange);
    z-index: 0;
    transition: background 0.3s ease;
}

.hex-cell.hovered .hex-border,
.hex-cell.connected .hex-border {
    background: var(--amber-bright);
}

.hex-cell.expanded .hex-border {
    background: var(--amber-bright);
}

/* Hex inner content */
.hex-inner {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--dark-concrete);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    transition: background 0.3s ease;
    overflow: hidden;
    /* Concrete texture on cells */
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='128' height='128' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
        linear-gradient(135deg, var(--dark-concrete) 0%, #4A4438 100%);
    background-size: 128px 128px, 100% 100%;
}

.hex-label {
    margin-bottom: 4px;
    font-size: 9px;
    opacity: 0.7;
}

.hex-title {
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1;
    margin-bottom: 4px;
    color: var(--off-white);
}

.hex-desc {
    font-size: 10px;
    line-height: 1.3;
    color: var(--off-white);
    opacity: 0.6;
    max-width: 140px;
}

/* ---------- Data Viz (hidden by default, shown on expand) ---------- */
.data-viz {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease 0.1s;
    position: absolute;
    bottom: 28%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 50%;
}

.hex-cell.expanded .data-viz {
    opacity: 1;
    pointer-events: auto;
}

.data-viz svg {
    width: 100%;
    height: 100%;
}

.viz-label {
    fill: var(--off-white);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.04em;
}

.viz-label-center {
    fill: var(--off-white);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 16px;
    letter-spacing: 0.04em;
}

.viz-label-sm {
    fill: var(--off-white);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.04em;
}

.viz-label-tiny {
    fill: var(--off-white);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 7px;
    letter-spacing: 0.02em;
}

/* ============================================
   STATUS BAR FOOTER
   ============================================ */
#status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--deep-charcoal);
    border-top: 2px solid var(--burnt-orange);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-item .mono-label {
    font-size: 10px;
    color: var(--amber-bright);
    opacity: 0.7;
}

.status-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--off-white);
    letter-spacing: 0.04em;
}

.status-value.active {
    color: var(--amber-bright);
}

/* ============================================
   ANIMATIONS — Stagger entrance
   ============================================ */
@keyframes hex-appear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Odd rows need to preserve translate on appear */
@keyframes hex-appear-odd {
    from {
        opacity: 0;
        transform: translateX(calc(var(--hex-width) / 2 + 6px)) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(calc(var(--hex-width) / 2 + 6px)) scale(1);
    }
}

/* Connection line fade-in */
@keyframes connection-fade {
    from { opacity: 0; }
    to { opacity: 0.3; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    :root {
        --hex-width: 140px;
        --hex-height: 162px;
    }

    #hex-grid {
        grid-template-columns: repeat(4, var(--hex-width));
    }

    .hex-cell[data-row="1"],
    .hex-cell[data-row="3"] {
        transform: translateX(calc(var(--hex-width) / 2 + 6px));
    }

    .hex-cell[data-row="1"].connected,
    .hex-cell[data-row="3"].connected {
        transform: translateX(calc(var(--hex-width) / 2 + 6px)) scale(1.08);
    }

    .hex-cell[data-row="1"].expanded,
    .hex-cell[data-row="3"].expanded {
        transform: translateX(calc(var(--hex-width) / 2 + 6px)) scale(2);
    }
}

@media (max-width: 700px) {
    :root {
        --hex-width: 110px;
        --hex-height: 127px;
    }

    #hero {
        flex-direction: column;
        justify-content: center;
        gap: 40px;
        padding: 0 5vw;
    }

    #hero-content {
        max-width: 100%;
        text-align: center;
    }

    #hero-minimap {
        width: 200px;
        height: 175px;
    }

    #hex-grid {
        grid-template-columns: repeat(3, var(--hex-width));
    }

    .hex-title {
        font-size: 16px;
    }

    .hex-desc {
        font-size: 8px;
    }

    #status-bar {
        padding: 0 12px;
        height: 36px;
        overflow-x: auto;
        gap: 16px;
        justify-content: flex-start;
    }

    .status-item {
        flex-shrink: 0;
    }
}

@media (max-width: 500px) {
    :root {
        --hex-width: 90px;
        --hex-height: 104px;
    }

    #hex-grid {
        grid-template-columns: repeat(2, var(--hex-width));
        gap: 4px 6px;
    }

    .hex-cell[data-row="1"],
    .hex-cell[data-row="3"] {
        transform: translateX(calc(var(--hex-width) / 2 + 3px));
    }

    .hex-cell[data-row="1"].connected,
    .hex-cell[data-row="3"].connected {
        transform: translateX(calc(var(--hex-width) / 2 + 3px)) scale(1.08);
    }

    .hex-cell[data-row="1"].expanded,
    .hex-cell[data-row="3"].expanded {
        transform: translateX(calc(var(--hex-width) / 2 + 3px)) scale(2);
    }

    .hex-label {
        font-size: 7px;
    }

    .hex-title {
        font-size: 13px;
    }

    .hex-desc {
        display: none;
    }
}
