/* yesang.xyz — Glassmorphism over Glitch Decay */

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

:root {
    --deep-burgundy: #6B1D2A;
    --burgundy-black: #3B1520;
    --warm-cream: #F2E8DC;
    --frosted-cream: rgba(245, 235, 225, 0.42);
    --blush-accent: #C4606E;
    --glitch-magenta: #E8255A;
    --corruption-cyan: #2AE8D4;
    --panel-border: rgba(107, 29, 42, 0.18);
    --shadow-burgundy: #2A0E14;
    --meta-color: rgba(120, 20, 40, 0.55);
}

body {
    background: var(--warm-cream);
    color: var(--burgundy-black);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    line-height: 1.65;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* ========== INTRO OVERLAY ========== */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--shadow-burgundy);
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#intro-overlay.revealed {
    opacity: 0;
}

.glitch-tear {
    position: absolute;
    left: 0;
    width: 100%;
    background: var(--warm-cream);
    opacity: 0;
    transform: scaleX(0);
}

.glitch-tear-1 { top: 15%; height: 8px; }
.glitch-tear-2 { top: 32%; height: 12px; }
.glitch-tear-3 { top: 48%; height: 6px; }
.glitch-tear-4 { top: 67%; height: 14px; }
.glitch-tear-5 { top: 83%; height: 10px; }

@keyframes tearRip {
    0% { transform: scaleX(0); opacity: 1; }
    15% { transform: scaleX(1.1); opacity: 1; }
    20% { transform: scaleX(0.95); opacity: 1; }
    30% { transform: scaleX(1.05); opacity: 1; }
    50% { transform: scaleX(1); opacity: 1; height: 60vh; }
    100% { transform: scaleX(1); opacity: 1; height: 100vh; }
}

#intro-overlay.tearing .glitch-tear {
    animation: tearRip 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#intro-overlay.tearing .glitch-tear-1 { animation-delay: 0s; }
#intro-overlay.tearing .glitch-tear-2 { animation-delay: 0.08s; }
#intro-overlay.tearing .glitch-tear-3 { animation-delay: 0.15s; }
#intro-overlay.tearing .glitch-tear-4 { animation-delay: 0.05s; }
#intro-overlay.tearing .glitch-tear-5 { animation-delay: 0.12s; }

/* ========== NOISE CANVAS ========== */
#noise-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 900;
    pointer-events: none;
    opacity: 0.06;
    mix-blend-mode: multiply;
}

/* ========== DATA STREAMS ========== */
#data-streams {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    display: flex;
    justify-content: space-around;
    overflow: hidden;
    opacity: 0.04;
}

.data-column {
    width: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--deep-burgundy);
    line-height: 1.4;
    white-space: nowrap;
    writing-mode: vertical-lr;
    overflow: hidden;
}

/* ========== GLITCH GUTTER ========== */
#glitch-gutter {
    position: fixed;
    top: 0;
    left: 0;
    width: 24px;
    height: 100vh;
    z-index: 50;
    overflow: hidden;
    background: repeating-linear-gradient(
        to bottom,
        var(--glitch-magenta) 0px,
        var(--corruption-cyan) 2px,
        var(--shadow-burgundy) 4px,
        transparent 6px,
        transparent 12px
    );
    opacity: 0.35;
    animation: gutterShift 3s steps(8) infinite;
}

@keyframes gutterShift {
    0% { background-position: 0 0; }
    25% { background-position: 3px 8px; }
    50% { background-position: -2px 16px; }
    75% { background-position: 5px 4px; }
    100% { background-position: 0 0; }
}

/* ========== WATERMARKS ========== */
.watermark {
    position: fixed;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 15vw;
    color: rgba(107, 29, 42, 0.04);
    pointer-events: none;
    z-index: 2;
    user-select: none;
    transform: rotate(-3deg);
    line-height: 1;
}

.watermark-1 { top: 10%; left: 5%; }
.watermark-2 { top: 45%; left: 30%; }
.watermark-3 { top: 78%; left: 15%; }

/* ========== MASONRY GRID ========== */
#masonry-grid {
    position: relative;
    z-index: 10;
    padding: 80px 0 120px 28px;
    column-count: 3;
    column-gap: 0;
    column-fill: balance;
}

.masonry-panel {
    break-inside: avoid;
    margin-bottom: 20px;
    padding: 0 6px;
    opacity: 0;
    filter: blur(40px);
    transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.masonry-panel.visible {
    opacity: 1;
    filter: blur(0);
}

.panel-inner {
    position: relative;
    background: var(--frosted-cream);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    border: 1px solid var(--panel-border);
    box-shadow: 0 8px 32px rgba(42, 14, 20, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    padding: 28px 24px;
    animation: borderPulse 4s ease-in-out infinite;
    overflow: hidden;
}

/* Randomized border-radius per panel */
.masonry-panel:nth-child(1) .panel-inner { border-radius: 12px 20px 8px 16px; }
.masonry-panel:nth-child(2) .panel-inner { border-radius: 18px 10px 22px 14px; }
.masonry-panel:nth-child(3) .panel-inner { border-radius: 8px 24px 16px 12px; }
.masonry-panel:nth-child(4) .panel-inner { border-radius: 20px 14px 10px 24px; }
.masonry-panel:nth-child(5) .panel-inner { border-radius: 14px 8px 20px 18px; }
.masonry-panel:nth-child(6) .panel-inner { border-radius: 22px 16px 12px 8px; }
.masonry-panel:nth-child(7) .panel-inner { border-radius: 10px 22px 18px 14px; }
.masonry-panel:nth-child(8) .panel-inner { border-radius: 16px 12px 24px 20px; }
.masonry-panel:nth-child(9) .panel-inner { border-radius: 24px 18px 14px 10px; }
.masonry-panel:nth-child(10) .panel-inner { border-radius: 12px 16px 22px 8px; }
.masonry-panel:nth-child(11) .panel-inner { border-radius: 18px 24px 10px 20px; }
.masonry-panel:nth-child(12) .panel-inner { border-radius: 8px 14px 18px 22px; }
.masonry-panel:nth-child(13) .panel-inner { border-radius: 20px 10px 16px 12px; }
.masonry-panel:nth-child(14) .panel-inner { border-radius: 14px 22px 8px 18px; }
.masonry-panel:nth-child(15) .panel-inner { border-radius: 16px 8px 24px 14px; }

/* Varying vertical gaps via margin */
.masonry-panel:nth-child(3n+1) { margin-bottom: 24px; }
.masonry-panel:nth-child(3n+2) { margin-bottom: 36px; }
.masonry-panel:nth-child(3n)   { margin-bottom: 18px; }

/* Intentional misalignment offsets */
.masonry-panel:nth-child(4n+1) { transform: translateX(4px); }
.masonry-panel:nth-child(4n+2) { transform: translateX(-6px); }
.masonry-panel:nth-child(4n+3) { transform: translateX(7px); }
.masonry-panel:nth-child(4n)   { transform: translateX(-5px); }

.masonry-panel.visible:nth-child(4n+1) { transform: translateX(4px); }
.masonry-panel.visible:nth-child(4n+2) { transform: translateX(-6px); }
.masonry-panel.visible:nth-child(4n+3) { transform: translateX(7px); }
.masonry-panel.visible:nth-child(4n)   { transform: translateX(-5px); }

/* ========== BORDER PULSE ANIMATION ========== */
@keyframes borderPulse {
    0%   { border-color: rgba(107, 29, 42, 0.10); }
    50%  { border-color: rgba(107, 29, 42, 0.35); }
    85%  { border-color: rgba(107, 29, 42, 0.20); }
    87%  { border-color: rgba(232, 37, 90, 0.9); }
    89%  { border-color: rgba(107, 29, 42, 0.20); }
    100% { border-color: rgba(107, 29, 42, 0.10); }
}

/* Stagger border animation timing */
.masonry-panel:nth-child(1) .panel-inner { animation-duration: 3.8s; animation-delay: 0.2s; }
.masonry-panel:nth-child(2) .panel-inner { animation-duration: 4.5s; animation-delay: 1.1s; }
.masonry-panel:nth-child(3) .panel-inner { animation-duration: 3.5s; animation-delay: 0.7s; }
.masonry-panel:nth-child(4) .panel-inner { animation-duration: 4.8s; animation-delay: 1.8s; }
.masonry-panel:nth-child(5) .panel-inner { animation-duration: 4.2s; animation-delay: 0.4s; }
.masonry-panel:nth-child(6) .panel-inner { animation-duration: 3.6s; animation-delay: 2.1s; }
.masonry-panel:nth-child(7) .panel-inner { animation-duration: 5.0s; animation-delay: 0.9s; }
.masonry-panel:nth-child(8) .panel-inner { animation-duration: 3.9s; animation-delay: 1.5s; }
.masonry-panel:nth-child(9) .panel-inner { animation-duration: 4.3s; animation-delay: 0.3s; }
.masonry-panel:nth-child(10) .panel-inner { animation-duration: 4.7s; animation-delay: 1.7s; }
.masonry-panel:nth-child(11) .panel-inner { animation-duration: 3.7s; animation-delay: 0.6s; }
.masonry-panel:nth-child(12) .panel-inner { animation-duration: 4.1s; animation-delay: 2.3s; }
.masonry-panel:nth-child(13) .panel-inner { animation-duration: 4.6s; animation-delay: 1.0s; }
.masonry-panel:nth-child(14) .panel-inner { animation-duration: 3.8s; animation-delay: 0.5s; }
.masonry-panel:nth-child(15) .panel-inner { animation-duration: 4.4s; animation-delay: 1.4s; }

/* ========== REGISTRATION MARKS ========== */
.registration-mark {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(107, 29, 42, 0.25);
    z-index: 5;
}

.registration-mark::before,
.registration-mark::after {
    content: '';
    position: absolute;
    background: rgba(107, 29, 42, 0.2);
}

.registration-mark::before {
    width: 1px;
    height: 12px;
    top: -2px;
    left: 3px;
}

.registration-mark::after {
    width: 12px;
    height: 1px;
    top: 3px;
    left: -2px;
}

.mark-tl { top: 6px; left: 6px; }
.mark-tr { top: 6px; right: 6px; }
.mark-bl { bottom: 6px; left: 6px; }
.mark-br { bottom: 6px; right: 6px; }

/* ========== TYPOGRAPHY ========== */
h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3.8rem);
    letter-spacing: 0.04em;
    line-height: 1.08;
    text-transform: uppercase;
    color: var(--burgundy-black);
    margin-bottom: 16px;
}

.panel-meta {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--meta-color);
    margin-bottom: 12px;
}

p {
    color: var(--burgundy-black);
    margin-bottom: 12px;
}

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

.dispatch-text {
    font-weight: 600;
    font-size: clamp(1.1rem, 1.3vw, 1.35rem);
    line-height: 1.55;
}

.single-line {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 2.2rem);
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.timestamp-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--meta-color);
    margin-bottom: 4px;
}

/* ========== GLITCH IMAGE CONTAINERS ========== */
.glitch-image-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--shadow-burgundy);
}

.tall-container {
    height: 320px;
}

.glitch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: difference;
}

.glitch-r {
    background: linear-gradient(
        135deg,
        rgba(107, 29, 42, 0.8) 0%,
        rgba(42, 14, 20, 0.6) 40%,
        rgba(196, 96, 110, 0.4) 70%,
        rgba(107, 29, 42, 0.9) 100%
    );
    transform: translateX(2px) translateY(-1px);
    animation: glitchR 8s steps(3) infinite;
}

.glitch-g {
    background: linear-gradient(
        225deg,
        rgba(59, 21, 32, 0.6) 0%,
        rgba(242, 232, 220, 0.3) 50%,
        rgba(107, 29, 42, 0.7) 100%
    );
    transform: translateX(-3px) translateY(2px);
    animation: glitchG 6s steps(4) infinite;
}

.glitch-b {
    background: linear-gradient(
        45deg,
        rgba(42, 232, 212, 0.15) 0%,
        rgba(42, 14, 20, 0.5) 35%,
        rgba(232, 37, 90, 0.2) 65%,
        rgba(59, 21, 32, 0.7) 100%
    );
    transform: translateX(1px) translateY(-2px);
    animation: glitchB 10s steps(5) infinite;
}

@keyframes glitchR {
    0%, 100% { transform: translateX(2px) translateY(-1px); }
    20% { transform: translateX(-4px) translateY(1px); }
    40% { transform: translateX(3px) translateY(-3px); }
    60% { transform: translateX(-1px) translateY(2px); }
    80% { transform: translateX(4px) translateY(0); }
}

@keyframes glitchG {
    0%, 100% { transform: translateX(-3px) translateY(2px); }
    25% { transform: translateX(2px) translateY(-2px); }
    50% { transform: translateX(-4px) translateY(3px); }
    75% { transform: translateX(1px) translateY(-1px); }
}

@keyframes glitchB {
    0%, 100% { transform: translateX(1px) translateY(-2px); }
    15% { transform: translateX(-3px) translateY(1px); }
    35% { transform: translateX(4px) translateY(-3px); }
    55% { transform: translateX(-2px) translateY(2px); }
    80% { transform: translateX(3px) translateY(-1px); }
}

.scan-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(42, 14, 20, 0.15) 2px,
        rgba(42, 14, 20, 0.15) 4px
    );
    pointer-events: none;
    z-index: 3;
}

.corruption-block {
    position: absolute;
    z-index: 4;
    animation: corruptionFlicker 3s steps(1) infinite;
}

.corruption-block:nth-child(4) {
    width: 80px;
    height: 20px;
    top: 30%;
    left: 10%;
    background: var(--glitch-magenta);
    animation-delay: 0.5s;
}

.corruption-block:nth-child(5) {
    width: 60px;
    height: 15px;
    top: 65%;
    left: 50%;
    background: var(--corruption-cyan);
    animation-delay: 1.2s;
}

.corruption-block:nth-child(6) {
    width: 100px;
    height: 12px;
    top: 48%;
    left: 25%;
    background: var(--glitch-magenta);
    animation-delay: 2.0s;
}

@keyframes corruptionFlicker {
    0%, 70%, 100% { opacity: 0; }
    72% { opacity: 1; }
    78% { opacity: 0; }
    80% { opacity: 1; }
    85% { opacity: 0; }
}

/* ========== HOVER GLITCH INTERACTION ========== */
.masonry-panel:hover .panel-inner {
    border-color: var(--glitch-magenta);
}

.masonry-panel:hover .panel-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    animation: hoverGlitch 0.2s steps(2) forwards;
}

@keyframes hoverGlitch {
    0% {
        box-shadow:
            2px 0 0 rgba(232, 37, 90, 0.5),
            -2px 0 0 rgba(42, 232, 212, 0.5);
        clip-path: inset(40% 0 30% 0);
    }
    50% {
        box-shadow:
            -3px 0 0 rgba(232, 37, 90, 0.7),
            3px 0 0 rgba(42, 232, 212, 0.7);
        clip-path: inset(20% 0 50% 0);
    }
    100% {
        box-shadow: none;
        clip-path: none;
    }
}

.masonry-panel:hover {
    transition: transform 0.1s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* ========== FLOATING NAV ========== */
#floating-nav {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    display: flex;
    gap: 24px;
    padding: 12px 28px;
    background: rgba(245, 235, 225, 0.55);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(107, 29, 42, 0.15);
    border-radius: 40px;
    box-shadow: 0 4px 20px rgba(42, 14, 20, 0.15);
}

.nav-label {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--deep-burgundy);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.nav-label:hover {
    color: var(--glitch-magenta);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    #masonry-grid {
        column-count: 2;
        padding-left: 28px;
        padding-right: 4px;
    }
}

@media (max-width: 640px) {
    #masonry-grid {
        column-count: 1;
        padding-left: 28px;
        padding-right: 8px;
    }

    .watermark {
        font-size: 25vw;
    }

    #floating-nav {
        gap: 16px;
        padding: 10px 20px;
    }

    .nav-label {
        font-size: 0.75rem;
    }

    h2 {
        font-size: clamp(1.6rem, 5vw, 2.4rem);
    }
}

/* ========== ASYMMETRIC COLUMN WIDTHS (via padding hack) ========== */
@media (min-width: 1025px) {
    #masonry-grid {
        padding-right: 4px;
    }

    .masonry-panel:nth-child(3n+1) {
        padding-right: 10px;
        padding-left: 4px;
    }

    .masonry-panel:nth-child(3n+2) {
        padding-right: 8px;
        padding-left: 8px;
    }

    .masonry-panel:nth-child(3n) {
        padding-right: 4px;
        padding-left: 10px;
    }
}
