/* =========================================
   gabs.news — Dopamine Newsroom / Hexagonal Honeycomb
   Terracotta-Warm Palette | Space Grotesk + Outfit + Azeret Mono
   ========================================= */

:root {
    --deep-ground: #2c1810;
    --primary-surface: #c2703a;
    --hot-accent: #e8961c;
    --warm-highlight: #d4885a;
    --text-primary: #f2e8d9;
    --text-secondary: #bfa88e;
    --alert-red: #c43e2a;
    --cool-contrast: #3a6b5e;

    --hex-width: 280px;
    --hex-height: calc(var(--hex-width) * 1.1547);
    --hex-gap: 4px;
    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);

    --font-headline: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --font-mono: 'Azeret Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-ground);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    letter-spacing: 0.005em;
    line-height: 1.55;
    overflow-x: hidden;
    min-height: 100vh;
}

/* =========================================
   Marble Background Canvas
   ========================================= */

#marble-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
}

/* =========================================
   Classical Motifs
   ========================================= */

.classical-motifs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
}

.ionic-volute {
    position: absolute;
    width: 80px;
    height: 200px;
    opacity: 0.12;
}

.volute-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

.volute-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.volute-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawVolute 4s ease-out forwards;
}

.volute-stem {
    opacity: 0;
    animation: fadeIn 2s 3s ease-out forwards;
}

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

@keyframes fadeIn {
    to { opacity: 1; }
}

.acanthus {
    position: fixed;
    width: 120px;
    height: 120px;
    pointer-events: none;
}

.acanthus-tl { top: 10px; left: 10px; }
.acanthus-tr { top: 10px; right: 10px; }
.acanthus-bl { bottom: 10px; left: 10px; }
.acanthus-br { bottom: 10px; right: 10px; }

/* =========================================
   Hexagonal Toolbar
   ========================================= */

#hex-toolbar {
    position: fixed;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hex-badge {
    width: 56px;
    height: 64px;
    clip-path: var(--hex-clip);
    background: rgba(44, 24, 16, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    color: var(--text-secondary);
    border: none;
    position: relative;
}

.hex-badge::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: var(--hex-clip);
    background: transparent;
    transition: background 0.3s ease;
}

.hex-badge:hover {
    background: rgba(194, 112, 58, 0.6);
    color: var(--text-primary);
    transform: scale(1.1);
}

.hex-badge.active {
    background: var(--primary-surface);
    color: var(--text-primary);
}

.badge-icon {
    width: 18px;
    height: 18px;
}

.badge-label {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    margin-top: 2px;
    text-transform: uppercase;
}

/* =========================================
   Broadcast Chamber (Hero)
   ========================================= */

#broadcast-chamber {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 100px;
}

.hero-hex-ring {
    position: relative;
    width: 100%;
    max-width: 1000px;
    height: 700px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   Hex Cell Base Styles
   ========================================= */

.hex-cell {
    position: relative;
    width: var(--hex-width);
    height: var(--hex-height);
    clip-path: var(--hex-clip);
    will-change: transform;
    transition: filter 0.3s ease;
    filter: drop-shadow(0 4px 20px rgba(139, 69, 19, 0.3));
}

.hex-inner {
    width: 100%;
    height: 100%;
    clip-path: var(--hex-clip);
    background: linear-gradient(160deg, rgba(44, 24, 16, 0.92), rgba(44, 24, 16, 0.98));
    position: relative;
    overflow: hidden;
    transition: background 0.3s ease;
}

.hex-cell:hover .hex-inner {
    background: linear-gradient(160deg, rgba(58, 32, 20, 0.95), rgba(44, 24, 16, 0.98));
}

.hex-content {
    position: absolute;
    top: 18%;
    left: 12%;
    right: 12%;
    bottom: 18%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.hex-category {
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.7vw, 0.7rem);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cool-contrast);
    margin-bottom: 6px;
}

.hex-cell.breaking .hex-category {
    color: var(--alert-red);
}

.hex-headline {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(0.9rem, 1.8vw, 1.4rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    font-feature-settings: 'ss01' 1;
    margin-bottom: 6px;
}

.hex-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    line-height: 1.45;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hex-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}

.hex-timestamp {
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.7vw, 0.7rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.hex-engagement {
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.7vw, 0.7rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--warm-highlight);
}

.engagement-count {
    color: var(--hot-accent);
}

/* =========================================
   Scanlines Overlay
   ========================================= */

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent 0,
        transparent 2px,
        rgba(44, 24, 16, 0.08) 2px,
        rgba(44, 24, 16, 0.08) 4px
    );
    pointer-events: none;
    opacity: 0.5;
}

/* =========================================
   Glitch Layers
   ========================================= */

.glitch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
}

/* =========================================
   Hero Hex Special Styles
   ========================================= */

.hero-hex {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    height: calc(420px * 1.1547);
    z-index: 10;
}

.hero-hex .hex-headline {
    font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.hero-hex .hex-body {
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    -webkit-line-clamp: 4;
}

.hero-hex .hex-content {
    top: 16%;
    left: 10%;
    right: 10%;
    bottom: 16%;
}

.hero-hex .greek-key-border {
    position: absolute;
    top: -2px;
    left: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    pointer-events: none;
    z-index: 11;
}

.meander-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: drawMeander 2s 0.5s ease-out forwards;
}

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

/* Breaking news pulse */
.hex-cell.breaking {
    animation: breakingPulse 1.5s ease-in-out infinite alternate;
}

@keyframes breakingPulse {
    from {
        filter: drop-shadow(0 0 0 var(--hot-accent)) drop-shadow(0 4px 20px rgba(139, 69, 19, 0.3));
    }
    to {
        filter: drop-shadow(0 0 20px rgba(232, 150, 28, 0.4)) drop-shadow(0 4px 20px rgba(139, 69, 19, 0.3));
    }
}

/* =========================================
   Trending Hexes (Ring around Hero)
   ========================================= */

.trending-hex {
    position: absolute;
    width: 200px;
    height: calc(200px * 1.1547);
    z-index: 5;
}

.trending-hex .hex-headline {
    font-size: clamp(0.7rem, 1.1vw, 0.95rem);
}

.trending-hex .hex-content {
    top: 20%;
    left: 14%;
    right: 14%;
    bottom: 20%;
}

/* Position trending hexes in a ring */
.trending-hex[data-position="1"] {
    top: 0%;
    left: 50%;
    transform: translateX(-50%);
}

.trending-hex[data-position="2"] {
    top: 12%;
    right: 5%;
    transform: none;
    left: auto;
}

.trending-hex[data-position="3"] {
    bottom: 12%;
    right: 5%;
    transform: none;
    left: auto;
}

.trending-hex[data-position="4"] {
    bottom: 0%;
    left: 50%;
    transform: translateX(-50%);
}

.trending-hex[data-position="5"] {
    bottom: 12%;
    left: 5%;
    transform: none;
}

.trending-hex[data-position="6"] {
    top: 12%;
    left: 5%;
    transform: none;
}

/* =========================================
   Honeycomb Grid Field
   ========================================= */

#honeycomb-field {
    position: relative;
    z-index: 2;
    padding: 40px 40px 120px;
}

.honeycomb-grid {
    max-width: 1800px;
    margin: 0 auto;
}

.hex-row {
    display: flex;
    justify-content: center;
    gap: var(--hex-gap);
    margin-top: calc(var(--hex-height) * -0.25 - var(--hex-gap));
}

.hex-row:first-child {
    margin-top: 0;
}

.hex-row-offset {
    transform: translateX(calc(var(--hex-width) / 2 + var(--hex-gap) / 2));
}

/* =========================================
   Glitch Animation Classes
   ========================================= */

.hex-cell.glitching {
    animation: glitchShake 300ms steps(4) forwards;
}

.hex-cell.glitching .hex-headline {
    text-shadow: 2px 0 var(--alert-red), -2px 0 var(--cool-contrast);
}

.hex-cell.glitching .scanlines {
    opacity: 1;
    background: repeating-linear-gradient(
        transparent 0,
        transparent 2px,
        rgba(44, 24, 16, 0.25) 2px,
        rgba(44, 24, 16, 0.25) 4px
    );
}

@keyframes glitchShake {
    0% { transform: translateX(0); }
    25% { transform: translateX(8px); }
    50% { transform: translateX(-8px); }
    75% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* Cell entrance flash */
.hex-cell.entering {
    animation: cellEnter 150ms ease-out forwards;
}

@keyframes cellEnter {
    0% {
        opacity: 0;
        transform: translateX(1px);
    }
    30% {
        opacity: 1;
        filter: brightness(1.3) drop-shadow(0 4px 20px rgba(139, 69, 19, 0.3));
    }
    100% {
        opacity: 1;
        transform: translateX(0);
        filter: drop-shadow(0 4px 20px rgba(139, 69, 19, 0.3));
    }
}

/* Chromatic hover effect */
.hex-cell.chromatic-hover .glitch-r {
    opacity: 0.4;
    mix-blend-mode: screen;
    background: var(--alert-red);
    transform: translateX(2px);
    transition: all 0.2s ease-out;
}

.hex-cell.chromatic-hover .glitch-g {
    opacity: 0.4;
    mix-blend-mode: screen;
    background: var(--cool-contrast);
    transform: translateX(-2px);
    transition: all 0.2s ease-out;
}

/* Hero glitch intro */
.hero-hex.hero-glitch-intro .hex-inner {
    animation: heroGlitchIntro 1.2s steps(6) forwards;
}

@keyframes heroGlitchIntro {
    0% { clip-path: polygon(0% 0%, 100% 0%, 100% 33%, 0% 33%); transform: translateX(-10px); }
    15% { clip-path: polygon(0% 0%, 100% 0%, 100% 33%, 0% 33%); transform: translateX(10px); }
    30% { clip-path: polygon(0% 33%, 100% 33%, 100% 66%, 0% 66%); transform: translateX(5px); }
    45% { clip-path: polygon(0% 33%, 100% 33%, 100% 66%, 0% 66%); transform: translateX(-5px); }
    60% { clip-path: polygon(0% 66%, 100% 66%, 100% 100%, 0% 100%); transform: translateX(8px); }
    80% { clip-path: polygon(0% 66%, 100% 66%, 100% 100%, 0% 100%); transform: translateX(-3px); }
    100% { clip-path: var(--hex-clip); transform: translateX(0); }
}

/* Heat map border glow for engagement */
.hex-cell {
    --engagement-glow: var(--text-secondary);
}

.hex-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: var(--hex-clip);
    border: 1px solid var(--engagement-glow);
    opacity: 0.3;
    pointer-events: none;
    transition: border-color 0.5s ease, opacity 0.5s ease;
}

.hex-cell:hover .hex-inner::before {
    opacity: 0.6;
    border-color: var(--hot-accent);
}

/* Greek key hover animation on regular hex cells */
.hex-cell:hover .scanlines {
    opacity: 0.3;
}

/* =========================================
   Broadcast Ticker Footer
   ========================================= */

#broadcast-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(44, 24, 16, 0.95);
    border-top: 1px solid rgba(194, 112, 58, 0.3);
    padding: 8px 0;
    backdrop-filter: blur(10px);
}

.broadcast-ticker {
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
}

.ticker-label {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: clamp(0.6rem, 0.8vw, 0.75rem);
    letter-spacing: 0.15em;
    color: var(--alert-red);
    background: rgba(196, 62, 42, 0.15);
    padding: 4px 16px;
    flex-shrink: 0;
    border-right: 1px solid rgba(194, 112, 58, 0.3);
    position: relative;
}

.ticker-label::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 50%;
    width: 6px;
    height: 6px;
    background: var(--alert-red);
    border-radius: 50%;
    transform: translateY(-50%);
    animation: tickerPulse 1s ease-in-out infinite;
}

@keyframes tickerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.ticker-scroll {
    display: flex;
    align-items: center;
    animation: tickerMove 60s linear infinite;
    padding-left: 20px;
}

.ticker-item {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    color: var(--text-secondary);
    white-space: nowrap;
    padding: 0 8px;
}

.ticker-separator {
    color: var(--primary-surface);
    font-size: 0.6rem;
    opacity: 0.5;
    padding: 0 8px;
}

@keyframes tickerMove {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* =========================================
   Category-based filtering visibility
   ========================================= */

.hex-cell.filtered-out {
    opacity: 0.1;
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.hex-cell.filtered-in {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* =========================================
   Responsive Design
   ========================================= */

@media (max-width: 1200px) {
    :root {
        --hex-width: 220px;
    }

    .hero-hex {
        width: 340px;
        height: calc(340px * 1.1547);
    }

    .trending-hex {
        width: 160px;
        height: calc(160px * 1.1547);
    }
}

@media (max-width: 768px) {
    :root {
        --hex-width: 180px;
    }

    #hex-toolbar {
        position: fixed;
        left: 50%;
        top: auto;
        bottom: 48px;
        transform: translateX(-50%);
        flex-direction: row;
        z-index: 101;
        background: rgba(44, 24, 16, 0.9);
        padding: 6px;
        border-radius: 8px;
        backdrop-filter: blur(10px);
    }

    .hex-badge {
        width: 42px;
        height: 48px;
    }

    .badge-label {
        font-size: 0.4rem;
    }

    #broadcast-chamber {
        padding: 40px 20px;
        min-height: 80vh;
    }

    .hero-hex-ring {
        height: 500px;
    }

    .hero-hex {
        width: 260px;
        height: calc(260px * 1.1547);
    }

    .hero-hex .hex-headline {
        font-size: clamp(1rem, 2.5vw, 1.6rem);
    }

    .trending-hex {
        width: 120px;
        height: calc(120px * 1.1547);
    }

    .trending-hex .hex-headline {
        font-size: 0.6rem;
    }

    .trending-hex .hex-meta {
        display: none;
    }

    .hex-row {
        flex-wrap: wrap;
    }

    .hex-row-offset {
        transform: translateX(calc(var(--hex-width) / 2));
    }

    #honeycomb-field {
        padding: 20px 10px 100px;
    }

    .ionic-volute {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --hex-width: 160px;
    }

    .hex-row {
        justify-content: center;
        flex-wrap: wrap;
    }

    .hex-row-offset {
        transform: translateX(calc(var(--hex-width) / 2));
    }

    .hero-hex {
        width: 220px;
        height: calc(220px * 1.1547);
    }

    .trending-hex {
        width: 100px;
        height: calc(100px * 1.1547);
    }

    .trending-hex .hex-category {
        display: none;
    }

    .trending-hex .hex-headline {
        font-size: 0.5rem;
    }
}

/* =========================================
   Marble fallback (CSS-only for low-end)
   ========================================= */

.marble-fallback {
    background:
        radial-gradient(ellipse at 20% 30%, rgba(194, 112, 58, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(194, 112, 58, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(232, 150, 28, 0.04) 0%, transparent 70%),
        conic-gradient(from 45deg at 30% 60%, rgba(194, 112, 58, 0.06), transparent 120deg, rgba(232, 150, 28, 0.03), transparent),
        var(--deep-ground);
    animation: marbleDrift 30s linear infinite;
}

@keyframes marbleDrift {
    from { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
    to { background-position: 100px 50px, -50px 100px, 75px -25px, -30px 60px, 0px 0px; }
}
