/* ============================================================
   gabs.ai -- Surrealist Research Terminal
   Dopamine-Neon on Void / Grotesque-Neo Typography
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    background: #0D0D1A;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 17px;
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: #C8C8D4;
    background: #0D0D1A;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 52px;
    letter-spacing: -0.02em;
    color: #FFFFFF;
    margin-bottom: 24px;
    line-height: 1.1;
}

p {
    margin-bottom: 16px;
}

p:last-child {
    margin-bottom: 0;
}

/* --- Links: Underline-Draw Animation --- */
a {
    color: #C8C8D4;
    text-decoration: none;
    background-image: linear-gradient(#FF2D7B, #FF2D7B);
    background-size: 0% 1.5px;
    background-position: left bottom;
    background-repeat: no-repeat;
    transition: background-size 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

a:hover {
    background-size: 100% 1.5px;
}

/* --- Pull Quotes --- */
.pull-quote {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 30px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #FF2D7B;
    line-height: 1.35;
    margin-bottom: 20px;
}

/* --- Index Rail Navigation --- */
#index-rail {
    position: fixed;
    top: 0;
    left: 0;
    width: 48px;
    height: 100vh;
    background: #0D0D1A;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 1000;
    border-right: 1px solid rgba(0, 240, 255, 0.08);
}

.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding: 4px 0;
}

.rail-numeral {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 13px;
    font-variant: small-caps;
    color: #8888AA;
    transition: color 300ms ease;
}

.rail-item:hover .rail-numeral,
.rail-item.active .rail-numeral {
    color: #39FF14;
}

.rail-underline {
    width: 0;
    height: 2px;
    background: #39FF14;
    margin-top: 3px;
    transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.rail-item:hover .rail-underline,
.rail-item.active .rail-underline {
    width: 24px;
}

.rail-item.active .rail-underline {
    animation: railPulse 2s ease-in-out infinite;
}

@keyframes railPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* --- Specimen Table (Main Grid Container) --- */
#specimen-table {
    margin-left: 48px;
    padding: 2px;
}

/* --- Grid Sections --- */
.grid-section {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(80px, auto);
    gap: 2px;
    margin-bottom: 2px;
}

/* --- Module Base Styles --- */
.module {
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.module.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* --- HUD Corner Brackets --- */
.module::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border-top: 2px solid rgba(0, 240, 255, 0.4);
    border-left: 2px solid rgba(0, 240, 255, 0.4);
    z-index: 5;
    opacity: 0;
    transition: opacity 300ms ease 200ms;
}

.module::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-bottom: 2px solid rgba(0, 240, 255, 0.4);
    border-right: 2px solid rgba(0, 240, 255, 0.4);
    z-index: 5;
    opacity: 0;
    transition: opacity 300ms ease 200ms;
}

.module.in-view::before,
.module.in-view::after {
    opacity: 1;
}

/* --- Module Border Trace on Hover --- */
.module-border-trace {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}

.module-border-trace svg {
    width: 100%;
    height: 100%;
}

.module-border-trace rect {
    fill: none;
    stroke: #00F0FF;
    stroke-width: 1;
    stroke-dasharray: var(--perimeter);
    stroke-dashoffset: var(--perimeter);
    transition: stroke-dashoffset 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.module:hover .module-border-trace rect {
    stroke-dashoffset: 0;
}

/* --- Coordinate Labels --- */
.coord-label {
    position: absolute;
    top: 6px;
    right: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: #8888AA;
    z-index: 6;
    white-space: nowrap;
    pointer-events: none;
}

/* --- Thesis Blocks --- */
.thesis-block {
    background: #0D0D1A;
    padding: 40px 36px 36px 48px;
}

.thesis-block .left-rule {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: #FF2D7B;
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.thesis-block.in-view .left-rule {
    transform: scaleY(1);
}

/* --- Annotation Modules --- */
.annotation-module {
    background: rgba(13, 13, 26, 0.7);
    padding: 20px 18px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12.5px;
    line-height: 1.5;
    color: #8888AA;
    backdrop-filter: blur(2px);
}

/* --- Highlight Burst (neon yellow, rare) --- */
.highlight-burst {
    border: 1px solid rgba(230, 255, 0, 0.3);
    color: #E6FF00;
}

.highlight-burst .coord-label {
    color: #E6FF00;
}

/* --- Specimen Panels --- */
.specimen-panel {
    background: #12122B;
    padding: 16px;
    position: relative;
}

.collage-container {
    position: relative;
    width: 100%;
    height: calc(100% - 16px);
    overflow: hidden;
}

.collage-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: luminosity;
    filter: grayscale(1) contrast(1.4) brightness(0.6);
}

.collage-base svg {
    width: 100%;
    height: 100%;
}

.collage-signal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
}

.collage-signal svg {
    width: 100%;
    height: 100%;
}

.collage-specimen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    filter: drop-shadow(4px 4px 0 #FF2D7B);
}

.collage-specimen svg {
    width: 60px;
    height: 60px;
}

/* Annotation layer via pseudo-element (crosshairs) */
.collage-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background:
        linear-gradient(#8888AA 1px, transparent 1px),
        linear-gradient(90deg, #8888AA 1px, transparent 1px);
    background-size: 100% 100%;
    background-position: center center;
    opacity: 0.08;
    pointer-events: none;
}

/* --- Scanning Line Effect --- */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(57, 255, 20, 0.6);
    z-index: 3;
    animation: scanLine 4s linear infinite;
    animation-play-state: paused;
}

.specimen-panel.in-view .scan-line {
    animation-play-state: running;
}

@keyframes scanLine {
    0% { top: 0; }
    100% { top: 100%; }
}

/* --- Data Slivers --- */
.data-sliver {
    background: #0D0D1A;
    padding: 20px 12px;
    border-left: 1px solid rgba(0, 240, 255, 0.1);
}

.sliver-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

.sliver-readout {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sliver-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8888AA;
}

.sliver-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: #00F0FF;
    letter-spacing: 0.02em;
}

/* --- Signal Ring --- */
.signal-ring-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
}

.signal-ring-svg circle {
    stroke-dasharray: 345.575;
    stroke-dashoffset: 345.575;
    transition: stroke-dashoffset 3s cubic-bezier(0.16, 1, 0.3, 1);
}

.signal-ring-active circle {
    stroke-dashoffset: 0;
}

/* --- Selection --- */
::selection {
    background: rgba(255, 45, 123, 0.3);
    color: #FFFFFF;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #0D0D1A;
}

::-webkit-scrollbar-thumb {
    background: #8888AA;
}

::-webkit-scrollbar-thumb:hover {
    background: #FF2D7B;
}

/* --- Mobile Responsive (< 768px) --- */
@media (max-width: 768px) {
    #index-rail {
        width: 36px;
        gap: 16px;
    }

    #specimen-table {
        margin-left: 36px;
    }

    .grid-section {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    h2 {
        font-size: 32px;
    }

    .pull-quote {
        font-size: 22px;
    }

    .thesis-block {
        padding: 28px 20px 24px 32px;
    }

    .annotation-module {
        padding: 16px 14px;
    }

    .data-sliver {
        padding: 16px 12px;
    }

    .sliver-content {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    .sliver-readout {
        min-width: 80px;
    }

    .specimen-panel {
        min-height: 250px;
    }

    .collage-specimen svg {
        width: 50px;
        height: 50px;
    }
}

/* --- Medium screens (768px - 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
    h2 {
        font-size: 40px;
    }

    .pull-quote {
        font-size: 26px;
    }

    .thesis-block {
        padding: 32px 28px 28px 40px;
    }
}
