/* ==========================================================================
   scire.bar -- corrupted crystallography database
   Palette: #0A0C10, #0D1117, #1E3A4A, #3B8EA5, #6B4C8A, #2E7D6E,
            #C8D6E0, #8A9BAE, #E04040, #40E0D0
   Typography: Share Tech Mono, IBM Plex Mono, Fira Code
   ========================================================================== */

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

html, body {
    background: #0A0C10;
    color: #C8D6E0;
    font-family: 'IBM Plex Mono', monospace;
    overflow-x: hidden;
    min-height: 100vh;
}

body {
    position: relative;
    transition: transform 0.05s linear;
}

/* ==========================================================================
   Fixed crystalline lattice background
   ========================================================================== */
#lattice-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1200ms ease-out;
}

#lattice-bg.visible {
    opacity: 0.03;
}

#lattice-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==========================================================================
   Glitch seams between columns
   ========================================================================== */
#glitch-seams {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.glitch-seam {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    mix-blend-mode: screen;
    opacity: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 6px,
        rgba(224, 64, 64, 0.5) 6px,
        rgba(224, 64, 64, 0.5) 7px,
        transparent 7px,
        transparent 13px,
        rgba(64, 224, 208, 0.5) 13px,
        rgba(64, 224, 208, 0.5) 14px
    );
}

.glitch-seam[data-seam="0"] {
    left: calc(33% + 24px);
    animation: seam-flicker-a 7s infinite;
}

.glitch-seam[data-seam="1"] {
    left: calc(66% + 24px);
    animation: seam-flicker-b 5s infinite;
}

@keyframes seam-flicker-a {
    0%, 92%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); }
    93% { opacity: 0.8; clip-path: inset(20% 0 50% 0); }
    94% { opacity: 0; clip-path: inset(0 0 100% 0); }
    96% { opacity: 0.6; clip-path: inset(60% 0 10% 0); }
    97% { opacity: 0; clip-path: inset(0 0 100% 0); }
}

@keyframes seam-flicker-b {
    0%, 88%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); }
    89% { opacity: 0.7; clip-path: inset(40% 0 30% 0); }
    90% { opacity: 0; clip-path: inset(0 0 100% 0); }
    92% { opacity: 0.5; clip-path: inset(10% 0 70% 0); }
    93% { opacity: 0; clip-path: inset(0 0 100% 0); }
}

/* ==========================================================================
   Vertical navigation strip
   ========================================================================== */
#nav-strip {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 48px;
    z-index: 100;
    background: rgba(10, 12, 16, 0.85);
    backdrop-filter: blur(4px);
    border-right: 1px solid #1E3A4A;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 28px;
    padding: 40px 0;
}

.nav-item {
    position: relative;
    cursor: pointer;
    color: #3B8EA5;
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    transition: color 200ms ease-out;
}

.nav-item:hover {
    color: #C8D6E0;
}

.nav-glyph {
    display: block;
    text-align: center;
    width: 48px;
}

.nav-label {
    position: absolute;
    left: 56px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #1E3A4A;
    border-left: 2px solid #3B8EA5;
    padding: 6px 14px;
    white-space: nowrap;
    color: #C8D6E0;
    font-family: 'Share Tech Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.75rem;
    opacity: 0;
    filter: blur(4px);
    pointer-events: none;
    transition: opacity 300ms ease-out, filter 300ms ease-out, transform 300ms ease-out;
}

.nav-item:hover .nav-label {
    opacity: 1;
    filter: blur(0);
    transform: translateY(-50%) translateX(4px);
}

#mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 101;
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid #1E3A4A;
    padding: 8px;
    cursor: pointer;
}

/* ==========================================================================
   Opening section
   ========================================================================== */
.opening-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    padding: 0 60px;
}

.opening-content {
    text-align: center;
    z-index: 5;
}

#site-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(4rem, 10vw, 8rem);
    color: #C8D6E0;
    letter-spacing: 0.05em;
    line-height: 1;
    text-transform: uppercase;
}

.title-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(0);
    transition: opacity 200ms ease-out;
}

.title-char.revealed {
    opacity: 1;
    animation: char-glitch 200ms steps(2);
}

@keyframes char-glitch {
    0% {
        text-shadow:
            -3px 0 0 #E04040,
            3px 0 0 #40E0D0;
    }
    50% {
        text-shadow:
            -1px 0 0 #E04040,
            1px 0 0 #40E0D0;
    }
    100% {
        text-shadow:
            0 0 0 transparent,
            0 0 0 transparent;
    }
}

#site-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: #8A9BAE;
    letter-spacing: 0.08em;
    margin-top: 1rem;
    opacity: 0;
    filter: blur(4px);
    transition: opacity 500ms ease-out, filter 500ms ease-out;
}

#site-subtitle.revealed {
    opacity: 1;
    filter: blur(0);
}

/* Corruption band */
.corruption-band {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 8px;
    transform: translateY(-50%);
    background: repeating-linear-gradient(
        to right,
        #E04040 0px,
        #E04040 1px,
        #40E0D0 1px,
        #40E0D0 2px,
        #0A0C10 2px,
        #0A0C10 3px,
        transparent 3px,
        transparent 4px
    );
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    mix-blend-mode: screen;
}

.corruption-band.flashing {
    animation: corruption-flash 600ms steps(1, end);
}

@keyframes corruption-flash {
    0%, 20%, 40%, 60% { opacity: 0; }
    10% { opacity: 0.8; }
    30% { opacity: 0.7; }
    50% { opacity: 0.85; }
    70%, 100% { opacity: 0; }
}

/* ==========================================================================
   Section headers
   ========================================================================== */
.section-header {
    position: relative;
    width: 100%;
    padding: 32px 60px 32px 96px;
    margin: 60px 0 32px 0;
    background: rgba(13, 17, 23, 0.6);
    backdrop-filter: blur(8px);
    border-top: 1px solid #1E3A4A;
    border-bottom: 1px solid #1E3A4A;
    z-index: 5;
}

.section-header::before {
    content: "";
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 1px;
    background: #3B8EA5;
}

.section-header::after {
    content: "";
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 1px;
    background: linear-gradient(to right, #3B8EA5, transparent);
}

.header-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: #C8D6E0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
    transition: letter-spacing 800ms ease-out;
    display: inline-block;
}

.section-header.in-view .header-text {
    letter-spacing: 0.15em;
}

/* ==========================================================================
   Masonry grid
   ========================================================================== */
.masonry-grid {
    column-count: 3;
    column-gap: 24px;
    padding: 0 60px 60px 96px;
    z-index: 5;
    position: relative;
}

@media (max-width: 1200px) {
    .masonry-grid {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .masonry-grid {
        column-count: 1;
        padding: 0 24px 32px 24px;
    }
    #nav-strip { display: none; }
    #mobile-nav-toggle { display: block; }
    .section-header {
        padding: 24px 24px 24px 24px;
    }
    .section-header::before { display: none; }
    .opening-section { padding: 0 24px; }
}

/* ==========================================================================
   Panels
   ========================================================================== */
.panel {
    position: relative;
    background: #0D1117;
    border: 1px solid rgba(30, 58, 74, 0.4);
    margin: 0 0 24px 0;
    padding: 32px 28px 28px 28px;
    break-inside: avoid;
    overflow: hidden;
    transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
}

.panel:hover {
    border-color: rgba(30, 58, 74, 0.8);
    box-shadow: 0 0 20px rgba(59, 142, 165, 0.08);
}

.panel-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #3B8EA5;
}

.panel[data-accent="#3B8EA5"] .panel-accent { background: #3B8EA5; }
.panel[data-accent="#6B4C8A"] .panel-accent { background: #6B4C8A; }
.panel[data-accent="#2E7D6E"] .panel-accent { background: #2E7D6E; }

.panel-corner-node {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    pointer-events: none;
}

/* Hex watermark inside panels */
.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='139' viewBox='0 0 80 139'><path d='M40 0 L80 23.1 L80 69.3 L40 92.4 L0 69.3 L0 23.1 Z' fill='none' stroke='%233B8EA5' stroke-width='0.5'/><path d='M40 46.2 L80 69.3 L80 115.5 L40 138.6 L0 115.5 L0 69.3 Z' fill='none' stroke='%236B4C8A' stroke-width='0.5'/></svg>");
    background-size: 80px 139px;
    opacity: 0.025;
    pointer-events: none;
}

/* Data corruption bands across panels */
.panel::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 6px;
    top: 30%;
    background: repeating-linear-gradient(
        to right,
        #E04040 0px,
        #E04040 1px,
        #40E0D0 1px,
        #40E0D0 2px,
        #0A0C10 2px,
        #0A0C10 3px,
        transparent 3px,
        transparent 4px
    );
    mix-blend-mode: screen;
    opacity: 0;
    pointer-events: none;
    animation: corruption-drift 20s linear infinite;
}

@keyframes corruption-drift {
    0% { top: 100%; opacity: 0; }
    10% { opacity: 0.4; }
    50% { opacity: 0.5; }
    90% { opacity: 0.3; }
    100% { top: -10%; opacity: 0; }
}

/* Blur-focus reveal */
.blur-target {
    filter: blur(6px);
    opacity: 0.4;
    transition: filter 600ms ease-out, opacity 600ms ease-out, border-color 200ms ease-out, box-shadow 200ms ease-out;
}

.blur-target.in-focus {
    filter: blur(0);
    opacity: 1;
}

/* ==========================================================================
   Text panels
   ========================================================================== */
.panel-content p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.875rem, 1.2vw, 1rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: #8A9BAE;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 2;
}

.panel-content p:last-child {
    margin-bottom: 0;
}

.highlight-term {
    background: rgba(59, 142, 165, 0.12);
    color: #C8D6E0;
    padding: 1px 4px;
    border-left: 1px solid #3B8EA5;
}

/* ==========================================================================
   Quote panels
   ========================================================================== */
.quote-panel {
    padding: 40px 32px;
}

.quote-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(1.125rem, 1.8vw, 1.5rem);
    line-height: 1.4;
    color: #C8D6E0;
    letter-spacing: 0.04em;
    text-transform: none;
    position: relative;
    z-index: 2;
}

/* ==========================================================================
   Chromatic aberration text
   ========================================================================== */
.chromatic-text {
    text-shadow:
        -2px 0 0 #E04040,
        2px 0 0 #40E0D0;
    transition: text-shadow 0.15s steps(3);
}

.chromatic-text:hover {
    text-shadow:
        -5px 0 0 #E04040,
        5px 0 0 #40E0D0;
}

/* During global glitch event */
body.glitch-active .chromatic-text {
    text-shadow:
        -3px 0 0 #E04040,
        3px 0 0 #40E0D0;
}

/* ==========================================================================
   Data panels (canvas)
   ========================================================================== */
.data-panel {
    padding: 36px 16px 16px 16px;
}

.data-label {
    position: absolute;
    top: 10px;
    left: 16px;
    font-family: 'Fira Code', monospace;
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3B8EA5;
    z-index: 2;
}

.crystal-canvas {
    width: 100%;
    height: auto;
    display: block;
    background: #0A0C10;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   Metric panels
   ========================================================================== */
.metric-panel {
    padding: 40px 24px 24px 24px;
    text-align: center;
}

.metric-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1;
    color: #C8D6E0;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
    text-shadow:
        -1px 0 0 rgba(224, 64, 64, 0.7),
        1px 0 0 rgba(64, 224, 208, 0.7);
    position: relative;
    z-index: 2;
    word-break: break-all;
}

.metric-label {
    font-family: 'Fira Code', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3B8EA5;
    line-height: 1.4;
    position: relative;
    z-index: 2;
}

/* ==========================================================================
   Body scroll padding for nav
   ========================================================================== */
body {
    padding-left: 48px;
}

@media (max-width: 768px) {
    body {
        padding-left: 0;
    }
}

/* ==========================================================================
   Subtle scanline overlay across entire viewport
   ========================================================================== */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(200, 214, 224, 0.015) 2px,
        rgba(200, 214, 224, 0.015) 3px
    );
}

/* ==========================================================================
   Selection
   ========================================================================== */
::selection {
    background: #3B8EA5;
    color: #0A0C10;
}
