/* ============================================================
   opensource.day — styles.css
   aesthetic: glitch | palette: dark-neon | layout: full-bleed
   typography: rounded-sans (Nunito) | tone: elegant-sophisticated
   ============================================================ */

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

:root {
    --deep-void: #0A0A0F;
    --substrate: #14141F;
    --scan-line: #1A1A2E;
    --neon-cyan: #00F0FF;
    --neon-magenta: #FF00C8;
    --neon-violet: #8B00FF;
    --soft-white: #E8E8F0;
    --muted-lavender: #9898B8;
    --warning-amber: #FFB800;
    --dim-cyan: #4A8A90;
    --gradient-spine: linear-gradient(180deg, #00F0FF 0%, #8B00FF 50%, #FF00C8 100%);
}

html {
    scroll-behavior: smooth;
    background: var(--deep-void);
}

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--soft-white);
    background: var(--deep-void);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(0, 240, 255, 0.2);
    color: var(--soft-white);
}

/* --- Scan-line Overlay --- */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.8s ease;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(26, 26, 46, 0.4) 2px,
        rgba(26, 26, 46, 0.4) 3px
    );
}

.scanlines.active {
    opacity: 0.4;
}

.scanlines.dense {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 0.5px,
        rgba(26, 26, 46, 0.5) 0.5px,
        rgba(26, 26, 46, 0.5) 1px
    );
}

/* --- Bibliographic Footer --- */
.biblio-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: rgba(10, 10, 15, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted-lavender);
    letter-spacing: 0.08em;
    text-transform: none;
    border-top: 1px solid rgba(26, 26, 46, 0.6);
}

/* --- Plates (Full-bleed sections) --- */
.plate {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--deep-void);
}

/* --- Plate Numbers (Roman numerals) --- */
.plate-number {
    position: absolute;
    top: 24px;
    right: 32px;
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 0.9rem;
    color: var(--scan-line);
    transition: color 0.6s ease;
    z-index: 5;
}

.plate-number.visible {
    color: var(--muted-lavender);
}

/* --- Margin Notes --- */
.margin-note {
    position: absolute;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted-lavender);
    opacity: 0.5;
    writing-mode: horizontal-tb;
    z-index: 5;
    max-width: 140px;
    line-height: 1.4;
}

.margin-note-left {
    left: 3%;
}

/* --- Footnote Markers --- */
.fn-marker {
    font-family: 'Space Mono', monospace;
    font-size: 0.65em;
    color: var(--neon-cyan);
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.3);
    vertical-align: super;
    margin-left: 2px;
}

/* --- Binding Gutter Divider --- */
.binding-gutter {
    width: 100%;
    height: 2px;
    background: var(--gradient-spine);
    position: relative;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3), 0 0 24px rgba(139, 0, 255, 0.2);
}

.binding-gutter::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -1px;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--gradient-spine);
    border-radius: 2px;
}

/* --- Corruption Blocks --- */
.corruption-block {
    position: absolute;
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--scan-line);
    opacity: 0.15;
    line-height: 1.2;
    overflow: hidden;
    word-break: break-all;
    pointer-events: none;
    z-index: 2;
}

.corruption-1 {
    bottom: 40px;
    right: 20px;
    width: 200px;
    height: 60px;
}

.corruption-2 {
    top: 60px;
    right: 30px;
    width: 180px;
    height: 50px;
}

/* --- Plate Sentinels (invisible boundary markers) --- */
.plate-sentinel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    pointer-events: none;
}

/* ============================================================
   PLATE I — Title
   ============================================================ */
.plate-1 {
    flex-direction: column;
}

.title-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    position: relative;
}

.title-main {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(2.8rem, 7vw, 6.4rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: #FFFFFF;
    white-space: nowrap;
    position: relative;
}

.title-main .letter {
    display: inline-block;
    opacity: 0;
    transform: perspective(800px) rotateX(-15deg);
    transition: none;
}

.title-main .letter.revealed {
    opacity: 1;
    transform: perspective(800px) rotateX(0deg);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Chromatic aberration on hover for title */
.title-main:hover {
    text-shadow:
        -2px 0 var(--neon-cyan),
        2px 0 var(--neon-magenta);
}

.title-sub {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3), 0 0 24px rgba(0, 240, 255, 0.1);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    margin-top: 8px;
}

.title-sub.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   PLATE II — Thesis
   ============================================================ */
.plate-2 {
    align-items: flex-start;
    padding-top: 0;
}

.thesis-column {
    width: 680px;
    max-width: 90vw;
    margin: 0 auto;
    position: relative;
    top: 61.8%;
    transform: translateY(-50%);
}

.thesis-line {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    color: var(--soft-white);
    opacity: 0.15;
    transition: opacity 0.4s ease, text-shadow 0.4s ease;
    margin-bottom: 0.3em;
}

.thesis-line.active {
    opacity: 1;
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.2);
}

.thesis-line.read {
    opacity: 1;
    text-shadow: none;
}

/* Chromatic aberration on specific words (applied via JS) */
.chroma-word {
    position: relative;
    display: inline-block;
}

.chroma-word.split {
    color: transparent;
    text-shadow:
        -1.5px 0 var(--neon-cyan),
        1.5px 0 var(--neon-magenta);
}

/* ============================================================
   PLATE III — Code
   ============================================================ */
.plate-3 {
    align-items: center;
    justify-content: center;
}

.code-container {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
    position: relative;
}

.code-ghost {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    color: var(--scan-line);
    opacity: 0.08;
    overflow: hidden;
    padding: 20px;
}

.code-ghost-left {
    transform: rotate(2deg);
    text-align: right;
}

.code-ghost-right {
    transform: rotate(-2deg);
    text-align: left;
}

.code-ghost pre {
    white-space: pre-wrap;
    font-family: inherit;
}

.code-main {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    line-height: 1.65;
    padding: 40px 20px;
}

.code-line {
    display: flex;
    gap: 16px;
    padding: 2px 0;
    position: relative;
}

.line-number {
    color: var(--dim-cyan);
    opacity: 0.5;
    min-width: 28px;
    text-align: right;
    user-select: none;
    animation: lineNumPulse 4s ease-in-out infinite;
}

@keyframes lineNumPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; text-shadow: 0 0 6px rgba(0, 240, 255, 0.2); }
}

/* Code starts unhighlighted (dim cyan) */
.code-keyword,
.code-func,
.code-string,
.code-comment {
    color: var(--dim-cyan);
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* Highlighted state (activated via JS on scroll) */
.code-line.highlighted .code-keyword {
    color: var(--neon-cyan);
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.2);
}

.code-line.highlighted .code-func {
    color: var(--neon-cyan);
}

.code-line.highlighted .code-string {
    color: var(--warning-amber);
    text-shadow: 0 0 4px rgba(255, 184, 0, 0.15);
}

.code-line.highlighted .code-comment {
    color: var(--soft-white);
    opacity: 0.8;
}

/* Neon underscores on highlighted lines */
.code-line.highlighted::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 44px;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.3), transparent);
}

/* ============================================================
   PLATE IV — Timeline
   ============================================================ */
.plate-4 {
    align-items: flex-start;
    padding: 80px 0 120px;
    min-height: 100vh;
}

.timeline-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.timeline-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gradient-spine);
    transform: translateX(-50%);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3), 0 0 24px rgba(139, 0, 255, 0.15);
}

.timeline-entry {
    position: relative;
    width: 44%;
    margin-bottom: 60px;
    perspective: 1000px;
}

.timeline-left {
    margin-right: auto;
    text-align: right;
    padding-right: 40px;
}

.timeline-right {
    margin-left: auto;
    text-align: left;
    padding-left: 40px;
}

.tilt-card {
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
    border-left: 2px solid rgba(0, 240, 255, 0.2);
    padding: 20px;
    position: relative;
    background: rgba(20, 20, 31, 0.4);
    overflow: hidden;
}

.timeline-left .tilt-card,
.timeline-left.tilt-card {
    border-left: none;
    border-right: 2px solid rgba(0, 240, 255, 0.2);
}

/* Radial glow overlay for tilt cards */
.tilt-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(0, 240, 255, 0.15), transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tilt-card:hover::before {
    opacity: 1;
}

.tilt-card:hover {
    border-color: rgba(0, 240, 255, 0.6);
    box-shadow: 0 0 12px rgba(139, 0, 255, 0.4);
}

.timeline-date {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3), 0 0 24px rgba(0, 240, 255, 0.1);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.timeline-content h3 {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: #FFFFFF;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.timeline-content p {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--muted-lavender);
    line-height: 1.6;
}

/* Timeline dot markers on spine */
.timeline-entry::after {
    content: '';
    position: absolute;
    top: 24px;
    width: 10px;
    height: 10px;
    background: var(--neon-cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    z-index: 2;
}

.timeline-left::after {
    right: -47px;
}

.timeline-right::after {
    left: -47px;
}

/* ============================================================
   PLATE V — Colophon
   ============================================================ */
.plate-5 {
    align-items: center;
    justify-content: center;
    padding-bottom: 60px;
}

.colophon-content {
    max-width: 560px;
    text-align: center;
    padding: 0 20px;
}

.colophon-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--muted-lavender);
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin-bottom: 40px;
}

.colophon-body p {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.8rem, 1.3vw, 0.95rem);
    color: var(--muted-lavender);
    line-height: 1.85;
    margin-bottom: 20px;
}

.colophon-license {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(26, 26, 46, 0.6);
    font-style: italic;
}

.colophon-year {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--scan-line);
    letter-spacing: 0.1em;
    margin-top: 40px;
}

/* ============================================================
   Neon Pulse Animation
   ============================================================ */
@keyframes neonPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}

.timeline-spine,
.binding-gutter {
    animation: neonPulse 4s ease-in-out infinite;
}

/* ============================================================
   Glitch Burst (applied momentarily via JS)
   ============================================================ */
body.glitch-shift-right {
    transform: translateX(2px);
}

body.glitch-shift-left {
    transform: translateX(-2px);
}

/* ============================================================
   Chromatic Aberration on Heading Hover
   ============================================================ */
.timeline-content h3:hover,
.colophon-title:hover {
    text-shadow:
        -2px 0 var(--neon-cyan),
        2px 0 var(--neon-magenta);
    transition: text-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ============================================================
   Responsive Adjustments
   ============================================================ */
@media (max-width: 768px) {
    .code-container {
        grid-template-columns: 1fr;
    }

    .code-ghost {
        display: none;
    }

    .timeline-entry {
        width: 80%;
        margin-left: 20%;
        text-align: left;
        padding-left: 30px;
        padding-right: 0;
    }

    .timeline-left {
        padding-right: 0;
        padding-left: 30px;
        text-align: left;
    }

    .timeline-left .tilt-card,
    .timeline-left.tilt-card {
        border-right: none;
        border-left: 2px solid rgba(0, 240, 255, 0.2);
    }

    .timeline-spine {
        left: 15%;
    }

    .timeline-left::after,
    .timeline-right::after {
        left: -22px;
        right: auto;
    }

    .margin-note {
        display: none;
    }

    .thesis-column {
        top: 50%;
    }
}

@media (max-width: 480px) {
    .title-main {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .timeline-entry {
        width: 85%;
        margin-left: 15%;
    }

    .timeline-spine {
        left: 10%;
    }
}
