/* ============================================
   tanso.wiki — Anti-Design Carbon Encyclopedia
   ============================================ */

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

:root {
    --bone-ash: #f5efe6;
    --carbon-black: #1a1a1a;
    --tangerine: #ff6b35;
    --coral-ember: #e8573a;
    --saffron: #f4a940;
    --graphite: #2b2b2b;
    --ash-paper: #f0e6d8;
    --sienna: #a0522d;
    --charcoal: #3d3d3d;
    --orangered: #ff4500;
    --orange: #ffa500;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--carbon-black);
    color: var(--graphite);
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    overflow-x: hidden;
    position: relative;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Scanline Overlay --- */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0,0,0,0.03) 2px,
        rgba(0,0,0,0.03) 4px
    );
}

/* --- Noise Overlay --- */
.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noise-base);
    pointer-events: none;
    z-index: 1;
}

/* --- Sections --- */
.section {
    position: relative;
    min-height: 100vh;
    padding: 80px 0;
    overflow: hidden;
}

.section-dark {
    background: var(--carbon-black);
    color: var(--ash-paper);
}

.section-light {
    background: var(--bone-ash);
    color: var(--graphite);
}

/* Chromatic noise band between sections */
.section::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    width: 100%;
    height: 30px;
    filter: url(#noise-chromatic);
    z-index: 5;
}

/* --- Opening Section --- */
#opening {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0;
}

.opening-content {
    position: relative;
    z-index: 10;
    text-align: center;
    opacity: 0;
    animation: revealContent 1.5s ease-out 0.8s forwards;
}

.opening-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(8rem, 20vw, 20rem);
    color: var(--tangerine);
    letter-spacing: -0.02em;
    line-height: 0.85;
    display: flex;
    justify-content: center;
    filter: url(#displacement);
}

.opening-title .letter {
    display: inline-block;
    transition: transform 0.3s ease;
}

.opening-kanji {
    font-family: 'Bebas Neue', serif;
    font-size: clamp(6rem, 15vw, 16rem);
    color: var(--tangerine);
    margin-left: 30px;
    line-height: 1;
    opacity: 0.9;
}

.opening-wiki {
    font-family: 'Work Sans', sans-serif;
    font-size: clamp(2rem, 5vw, 5rem);
    letter-spacing: 1em;
    color: var(--ash-paper);
    margin-top: 10px;
}

@keyframes revealContent {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Margin Annotations (Opening) --- */
.margin-annotations {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    font-family: 'Inconsolata', monospace;
    font-weight: 300;
    font-size: 11px;
    line-height: 1.4;
    color: var(--sienna);
    opacity: 0;
    animation: fadeIn 1s ease 2.5s forwards;
}

.margin-left {
    left: 3%;
}

.margin-right {
    right: 3%;
    text-align: right;
}

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

/* --- Section Headers --- */
.section-header {
    position: relative;
    z-index: 10;
    padding: 0 20%;
    margin-bottom: 40px;
    overflow: visible;
}

.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(4rem, 12vw, 14rem);
    letter-spacing: -0.02em;
    line-height: 0.9;
    white-space: nowrap;
    /* Overflow right deliberately */
    margin-right: -20%;
}

.section-light .section-title {
    color: var(--carbon-black);
}

.section-dark .section-title {
    color: var(--tangerine);
}

.section-index {
    font-family: 'Abril Fatface', serif;
    font-size: 120px;
    color: var(--orangered);
    opacity: 0.15;
    position: absolute;
    top: -30px;
    right: 5%;
    z-index: 0;
}

/* --- Section Body --- */
.section-body {
    position: relative;
    z-index: 10;
    display: flex;
    gap: 20px;
    padding: 0 3%;
}

.content-main {
    flex: 1;
    margin-left: 17%;
    max-width: 55%;
    position: relative;
}

.body-text {
    margin-bottom: 24px;
    position: relative;
}

/* Alternate paragraph widths for ragged rhythm */
.body-text:nth-child(odd) {
    transform: rotate(0.3deg);
}

.body-text:nth-child(even) {
    transform: rotate(-0.2deg);
}

/* --- Margin Notes --- */
.margin-notes {
    position: absolute;
    top: 0;
    width: 15%;
    z-index: 10;
    font-family: 'Inconsolata', monospace;
    font-weight: 300;
    font-size: 11px;
    line-height: 1.4;
    color: var(--sienna);
}

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

.margin-notes.margin-right {
    right: 3%;
    text-align: right;
}

.margin-note {
    margin-bottom: 16px;
    opacity: 0.85;
}

/* --- Pull Quotes --- */
.pull-quote {
    font-family: 'Abril Fatface', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--orangered);
    margin: 40px 0;
    padding-left: 20px;
    border-left: 4px solid var(--tangerine);
    transform: rotate(-1deg);
    line-height: 1.3;
}

.section-dark .pull-quote {
    color: var(--orange);
}

/* --- Corruption Blocks --- */
.corruption-block {
    position: absolute;
    background: var(--coral-ember);
    z-index: 20;
    transition: opacity 0.5s ease;
    mix-blend-mode: multiply;
}

.section-dark .corruption-block {
    background: var(--saffron);
    mix-blend-mode: screen;
}

.corruption-block:hover {
    opacity: 0;
}

/* --- Carbon Lattice Background --- */
.lattice-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.04;
    z-index: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 66L0 50L0 16L28 0L56 16L56 50L28 66' fill='none' stroke='%23ff6b35' stroke-width='1'/%3E%3Cpath d='M28 100L0 84L0 50L28 34L56 50L56 84L28 100' fill='none' stroke='%23ff6b35' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 56px 100px;
    animation: rotateLattice 120s linear infinite;
}

@keyframes rotateLattice {
    from { transform: rotate(0deg) scale(1.5); }
    to { transform: rotate(360deg) scale(1.5); }
}

/* --- Data Ticker --- */
.data-ticker {
    height: 120px;
    background: var(--charcoal);
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    z-index: 50;
    border-top: 2px solid var(--tangerine);
    border-bottom: 2px solid var(--tangerine);
}

.ticker-track {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    height: 100%;
    align-items: center;
    animation: tickerScroll 30s linear infinite;
    width: max-content;
}

.data-ticker:hover .ticker-track {
    animation-play-state: paused;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-card {
    flex-shrink: 0;
    width: 200px;
    padding: 16px;
    background: var(--carbon-black);
    border: 1px solid var(--tangerine);
    scroll-snap-align: start;
    font-family: 'Inconsolata', monospace;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ticker-card-inverted {
    background: var(--tangerine);
    border-color: var(--carbon-black);
    color: var(--carbon-black);
}

.ticker-card-noisy {
    background: var(--charcoal);
    border-color: var(--saffron);
}

.ticker-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sienna);
}

.ticker-card-inverted .ticker-label {
    color: var(--carbon-black);
    opacity: 0.7;
}

.ticker-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 24px;
    color: var(--ash-paper);
}

.ticker-card-inverted .ticker-value {
    color: var(--carbon-black);
}

/* --- Navigation Atom --- */
.nav-atom {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    z-index: 2000;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-atom.expanded {
    width: 320px;
    height: auto;
    bottom: 16px;
    right: 16px;
}

.atom-svg {
    width: 48px;
    height: 48px;
    transition: opacity 0.3s ease;
}

.nav-atom.expanded .atom-svg {
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

.orbit-1 {
    animation: orbitSpin1 4s linear infinite;
    transform-origin: center;
}

.orbit-2 {
    animation: orbitSpin2 6s linear infinite;
    transform-origin: center;
    transform: rotate(60deg);
}

@keyframes orbitSpin1 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes orbitSpin2 {
    from { transform: rotate(60deg); }
    to { transform: rotate(420deg); }
}

.nav-expanded {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px;
    background: var(--carbon-black);
    border: 2px solid var(--tangerine);
}

.nav-atom.expanded .nav-expanded {
    display: grid;
}

.nav-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    text-decoration: none;
    color: var(--carbon-black);
    font-family: 'Inconsolata', monospace;
    transition: transform 0.2s ease;
}

.nav-cell:hover {
    transform: scale(1.1);
}

.nav-cell-index {
    font-size: 9px;
    opacity: 0.7;
}

.nav-cell-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    line-height: 1;
}

/* --- Vertical section-edge text --- */
.section-light .section-header::before {
    content: 'CARBON';
    position: absolute;
    right: 2%;
    top: 0;
    writing-mode: vertical-rl;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 80px;
    color: var(--tangerine);
    opacity: 0.08;
    letter-spacing: 0.1em;
}

/* --- Glitch transition classes (JS-driven) --- */
.glitch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.glitch-layer.red {
    mix-blend-mode: screen;
    background: rgba(255, 107, 53, 0.3);
}

.glitch-layer.green {
    mix-blend-mode: screen;
    background: rgba(244, 169, 64, 0.2);
}

.glitch-layer.blue {
    mix-blend-mode: screen;
    background: rgba(232, 87, 58, 0.2);
}

/* --- Electron orbital decorations --- */
.section::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border: 1px solid var(--tangerine);
    border-radius: 50%;
    opacity: 0.08;
    z-index: 0;
    animation: orbitalPulse 3s ease-in-out infinite;
}

.section:nth-child(odd)::before {
    top: 40px;
    left: 40px;
}

.section:nth-child(even)::before {
    bottom: 40px;
    right: 40px;
}

@keyframes orbitalPulse {
    0%, 100% { transform: scale(0.95); opacity: 0.06; }
    50% { transform: scale(1.05); opacity: 0.12; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-main {
        margin-left: 5%;
        max-width: 90%;
    }

    .margin-notes {
        display: none;
    }

    .section-header {
        padding: 0 5%;
    }

    .section-title {
        font-size: clamp(3rem, 15vw, 8rem);
    }

    .opening-title {
        font-size: clamp(5rem, 18vw, 12rem);
    }

    .margin-annotations {
        display: none;
    }

    .nav-atom.expanded {
        width: 240px;
    }
}
