/* ============================================
   jungchi.boo -- 정치 터미널
   Terminal-style political commentary interface
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #2a1520;
    color: #e8d5c0;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: clamp(16px, 1.6vw, 19px);
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* --- CRT Scanline Overlay --- */
/* Scanline color: #000000 at 4% opacity */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background-color: #000000;
    background-color: transparent;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.04) 2px,
        rgba(0, 0, 0, 0.04) 4px
    );
}

/* --- Ghost Hangul Background Layer --- */
#ghost-hangul-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#ghost-hangul-layer.active {
    opacity: 1;
}

.ghost-char {
    position: absolute;
    font-family: 'Red Hat Mono', 'Noto Sans KR', monospace;
    font-weight: 300;
    color: #e8d5c0;
    opacity: 0;
    animation: ghost-drift 20s linear infinite;
    will-change: transform;
}

.ghost-char-1 { font-size: 3.5rem; left: 8%; animation-duration: 22s; animation-delay: 0s; opacity: 0.15; }
.ghost-char-2 { font-size: 2.8rem; left: 22%; animation-duration: 26s; animation-delay: 2s; opacity: 0.1; }
.ghost-char-3 { font-size: 4rem; left: 38%; animation-duration: 19s; animation-delay: 4s; opacity: 0.12; }
.ghost-char-4 { font-size: 2.5rem; left: 55%; animation-duration: 24s; animation-delay: 1s; opacity: 0.08; }
.ghost-char-5 { font-size: 3rem; left: 72%; animation-duration: 21s; animation-delay: 3s; opacity: 0.14; }
.ghost-char-6 { font-size: 2.2rem; left: 88%; animation-duration: 28s; animation-delay: 5s; opacity: 0.09; }
.ghost-char-7 { font-size: 3.8rem; left: 15%; animation-duration: 25s; animation-delay: 7s; opacity: 0.11; }
.ghost-char-8 { font-size: 2.6rem; left: 45%; animation-duration: 23s; animation-delay: 6s; opacity: 0.13; }
.ghost-char-9 { font-size: 3.2rem; left: 65%; animation-duration: 20s; animation-delay: 8s; opacity: 0.07; }
.ghost-char-10 { font-size: 2.4rem; left: 82%; animation-duration: 27s; animation-delay: 9s; opacity: 0.1; }

@keyframes ghost-drift {
    0% {
        transform: translateY(110vh) rotate(0deg);
        opacity: 0;
    }
    5% {
        opacity: var(--ghost-opacity, 0.12);
    }
    90% {
        opacity: var(--ghost-opacity, 0.12);
    }
    100% {
        transform: translateY(-20vh) rotate(5deg);
        opacity: 0;
    }
}

/* --- Parallax Sections --- */
.parallax-section {
    position: relative;
    width: 100%;
    z-index: 2;
}

/* --- Section 1: Hero / Terminal --- */
#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2a1520;
    padding: 2em;
}

#terminal-window {
    width: min(80%, 900px);
    max-height: 70vh;
    background-color: #2a1520;
    border: 1px solid #f5e6d0;
    border-radius: 6px;
    overflow: hidden;
    opacity: 0;
    /* Border animation state - starts with no border */
    border-color: transparent;
}

#terminal-window.border-top {
    border-top-color: #f5e6d0;
}
#terminal-window.border-right {
    border-right-color: #f5e6d0;
}
#terminal-window.border-bottom {
    border-bottom-color: #f5e6d0;
}
#terminal-window.border-left {
    border-left-color: #f5e6d0;
}

#terminal-window.visible {
    opacity: 1;
}

/* Title Bar */
#terminal-titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background-color: #3d2030;
    border-bottom: 1px solid rgba(245, 230, 208, 0.2);
    opacity: 0;
    transition: opacity 0.4s ease;
}

#terminal-titlebar.visible {
    opacity: 1;
}

.titlebar-circles {
    display: flex;
    gap: 7px;
}

.circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.circle.visible {
    opacity: 1;
    transform: scale(1);
}

.circle-red { background-color: #ff5f56; }
.circle-yellow { background-color: #ffbd2e; }
.circle-green { background-color: #27c93f; }

#titlebar-text {
    font-family: 'Red Hat Mono', monospace;
    font-size: 13px;
    font-weight: 400;
    color: #c4956a;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#titlebar-text.visible {
    opacity: 1;
}

/* Terminal Body */
#terminal-body {
    padding: 2em;
    min-height: 200px;
    display: flex;
    align-items: flex-start;
}

#terminal-prompt {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 400;
    font-size: clamp(15px, 1.6vw, 18px);
    color: #e8d5c0;
    line-height: 1.6;
}

#prompt-symbol {
    color: #c4956a;
}

#typed-text {
    white-space: pre-wrap;
}

/* Blinking Cursor */
.cursor-blink {
    display: inline-block;
    width: 1em;
    height: 2px;
    background-color: #f5e6d0;
    vertical-align: baseline;
    margin-bottom: 2px;
    animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Section 2: Dispatches --- */
#dispatches {
    background-color: #2a1520;
    padding: 6em 2em;
    min-height: 100vh;
}

.section-title {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 500;
    font-size: clamp(28px, 4.5vw, 56px);
    color: #f5e6d0;
    margin-bottom: 2em;
    text-align: left;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.title-en {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 300;
    font-size: 0.5em;
    color: #c4956a;
    display: block;
    margin-top: 0.3em;
}

.dispatch-card {
    max-width: 900px;
    margin: 0 auto 2em auto;
    border-left: 3px solid #8b2252;
    padding-left: 1.5em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.dispatch-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.dispatch-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    margin-bottom: 0.75em;
}

.dispatch-timestamp {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 400;
    font-size: clamp(12px, 1.2vw, 14px);
    color: #c4956a;
}

.dispatch-number {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 500;
    font-size: clamp(12px, 1.2vw, 14px);
    color: #8b2252;
}

.dispatch-content p {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: clamp(16px, 1.6vw, 19px);
    color: #e8d5c0;
    line-height: 1.75;
}

/* --- Section 3: Ghost Archive --- */
#ghost-archive {
    background-color: #2a1520;
    min-height: 100vh;
    padding: 6em 2em;
    position: relative;
    overflow: hidden;
    /* Subtle CRT barrel distortion */
    border-radius: 8px;
}

.archive-hint {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 300;
    font-size: clamp(14px, 1.4vw, 16px);
    color: #c4956a;
    text-align: center;
    margin-bottom: 3em;
    opacity: 0.6;
    animation: hint-pulse 3s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

#archive-field {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    min-height: 60vh;
}

.trigger-zone {
    position: absolute;
    width: 180px;
    height: 180px;
    cursor: default;
}

.ghost-quote {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Red Hat Mono', monospace;
    font-weight: 300;
    font-size: clamp(13px, 1.3vw, 16px);
    color: #e8d5c0;
    opacity: 0;
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
    max-width: 350px;
    white-space: normal;
    line-height: 1.5;
    transition: opacity 0.6s ease;
}

.ghost-quote.materializing {
    opacity: 0.55;
}

.ghost-quote.fading {
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* Ripple Effect */
#ripple-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.ripple {
    position: absolute;
    border: 1px solid rgba(232, 213, 192, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple-expand 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-expand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0.4;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* --- Section 4: Cursor / Ending --- */
#cursor-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2a1520;
    padding: 2em;
}

#final-terminal {
    text-align: center;
}

#final-cursor {
    display: block;
    width: 1em;
    height: 2px;
    background-color: #f5e6d0;
    margin: 0 auto 2em auto;
    animation: cursor-blink 1s step-end infinite;
}

#final-text {
    font-family: 'Red Hat Mono', monospace;
    font-weight: 400;
    font-size: clamp(18px, 2.5vw, 28px);
    color: #f5e6d0;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#final-text.visible {
    opacity: 1;
}

#final-text .title-en {
    display: block;
    font-size: 0.6em;
    margin-top: 0.5em;
}

/* --- Parallax Transform Helpers --- */
.parallax-bg {
    will-change: transform;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #terminal-window {
        width: 95%;
    }

    .dispatch-card {
        padding-left: 1em;
    }

    .trigger-zone {
        width: 120px;
        height: 120px;
    }

    .ghost-quote {
        max-width: 250px;
        font-size: 13px;
    }

    #dispatches {
        padding: 4em 1.5em;
    }

    #ghost-archive {
        padding: 4em 1.5em;
    }

    .section-title {
        margin-bottom: 1.5em;
    }
}

@media (max-width: 480px) {
    #terminal-body {
        padding: 1.2em;
    }

    .trigger-zone {
        width: 100px;
        height: 100px;
    }
}
