/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f0ece4;
    --bg-secondary: #e8e0f0;
    --text-primary: #3d3a4b;
    --text-secondary: #8a7f96;
    --accent-rose: #d4a0a0;
    --accent-sage: #b8d4c9;
    --accent-butter: #d9cf9e;
    --accent-lavender: #c9b8db;
    --dark-ground: #2a2636;
    --grain-intensity: 0.12;
    --ease-sharp: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
}

/* === GRAIN OVERLAY === */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    filter: url(#grain-filter);
    mix-blend-mode: multiply;
    opacity: var(--grain-intensity);
    background: var(--bg-primary);
}

/* === SECTION 1: THE BROADCAST === */
#broadcast {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 4rem;
    position: relative;
    overflow: visible;
}

.broadcast-inner {
    max-width: 90vw;
}

.hero-title {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.hero-char {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    display: inline-block;
    transform: rotate(calc(var(--char-rot) * 1deg));
    opacity: 0;
    transition: opacity 0.3s var(--ease-sharp), transform 0.5s var(--ease-elastic);
}

.hero-char.visible {
    opacity: 1;
}

.broadcast-timestamp {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 40%;
    line-height: 1.6;
}

/* === SLASH CONSTELLATIONS === */
.slash-constellation {
    position: absolute;
    bottom: 10%;
    right: 8%;
    font-family: 'Space Mono', monospace;
    font-size: 2rem;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

.slash-constellation.visible {
    opacity: 1;
}

.constellation-mid {
    position: relative;
    text-align: center;
    margin: 4rem auto;
    bottom: auto;
    right: auto;
}

.slash.a1 {
    color: var(--accent-lavender);
    margin: 0 0.15em;
}

.slash.a2 {
    color: var(--accent-sage);
    margin: 0 0.15em;
}

/* === SECTION 2: THE SCATTER FIELD === */
#scatter-field {
    padding: 4rem 2rem;
    position: relative;
}

.shattered-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 6px;
    max-width: 1400px;
    margin: 0 auto;
}

.card {
    position: relative;
    transform: rotate(calc(var(--card-rot) * 1deg));
    overflow: visible;
    opacity: 0;
    transition: opacity 400ms var(--ease-sharp), transform 400ms var(--ease-sharp);
}

.card.revealed {
    opacity: 1;
}

.card-inner {
    background: var(--bg-primary);
    border: 1px solid var(--accent-sage);
    padding: 1.5rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.card-empty .card-inner {
    background: transparent;
    border: 1px dashed var(--accent-lavender);
    min-height: 80px;
}

.card-texture .card-inner {
    background: var(--bg-primary);
    border: 1px solid var(--bg-secondary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.texture-chars {
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    color: var(--bg-secondary);
    line-height: 1;
    word-break: break-all;
    animation: texture-pulse 6s ease-in-out infinite;
}

@keyframes texture-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.card-label {
    font-family: 'Anybody', sans-serif;
    font-weight: 900;
    font-size: clamp(0.65rem, 0.9vw, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
}

.card p {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    color: var(--text-primary);
}

.card-date {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--accent-rose);
}

.card-hex {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.color-swatch {
    width: 100%;
    height: 40px;
    border: 1px solid var(--text-secondary);
}

/* Sharp angle decorators */
.sharp-angle {
    position: absolute;
    width: 40px;
    height: 1px;
    background: var(--accent-lavender);
    z-index: 2;
}

.sharp-angle.top-left {
    top: -4px;
    left: -8px;
    transform: rotate(45deg);
}

.sharp-angle.top-right {
    top: -4px;
    right: -8px;
    transform: rotate(-45deg);
}

.sharp-angle.bottom-left {
    bottom: -4px;
    left: -8px;
    transform: rotate(-45deg);
}

.sharp-angle.bottom-right {
    bottom: -4px;
    right: -8px;
    transform: rotate(45deg);
}

/* Card hover */
.card:hover .sharp-angle {
    width: 80px;
    transition: width 300ms var(--ease-sharp);
}

.card:hover .sharp-angle.top-left,
.card:hover .sharp-angle.bottom-left {
    left: -20px;
}

.card:hover .sharp-angle.top-right,
.card:hover .sharp-angle.bottom-right {
    right: -20px;
}

/* === SECTION 3: THE LEDGER === */
#ledger {
    padding: 6rem 2rem;
    max-width: 60ch;
    margin: 0 auto;
}

.ledger-inner {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.ledger-line {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms var(--ease-sharp), transform 600ms var(--ease-sharp);
}

.ledger-line.revealed {
    opacity: 1;
    transform: translateY(0);
}

.line-number {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    padding-top: 0.15em;
}

.ledger-line p {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    color: var(--text-primary);
}

.slash-divider {
    font-family: 'Space Mono', monospace;
    font-size: 2rem;
    padding-left: 3.5rem;
    line-height: 1;
}

/* === SECTION 4: THE SIGNAL OUT === */
#signal-out {
    min-height: 50vh;
    background: var(--dark-ground);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    position: relative;
    overflow: hidden;
}

.signal-out-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.signal-repeat {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: calc(clamp(2rem, 8vw, 6rem) * var(--sig-scale));
    letter-spacing: 0.08em;
    color: var(--bg-primary);
    opacity: var(--sig-opacity);
    transform: rotate(calc(var(--sig-rot) * 1deg));
    transition: filter 3s ease;
}

#signal-out.dissolving .signal-repeat {
    animation: dissolve 3s forwards;
}

@keyframes dissolve {
    to {
        filter: saturate(0) blur(2px);
        opacity: 0.05;
    }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    #broadcast {
        padding: 2rem;
    }

    .broadcast-timestamp {
        max-width: 90%;
    }

    .hero-title {
        flex-wrap: wrap;
    }

    .shattered-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .card {
        grid-column: span 3 !important;
    }

    #ledger {
        padding: 4rem 1.5rem;
    }

    .slash-constellation {
        right: 4%;
    }
}
