/* ============================================================
   hangul.day — Terminal Aquarium Stylesheet
   Color Palette:
     Terminal Black: #0D1117
     Phosphor Green: #7EE787
     Grid Silver: #8A9BAE
     Steel Gray: #2D333B
     Slate: #484F58
     Aquarium Teal: #2EA8A0
     Betta Crimson: #E05D44
     Guppy Gold: #D4A72C
     Deep Reef: #1A3A4A
     Blue Accent: #4A6FA5
   ============================================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    background: #0D1117;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    color: #8A9BAE;
    background: #0D1117;
    line-height: 1.7;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* ---- CRT Scanline Overlay ---- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(255,255,255,0.03) 0px,
            rgba(255,255,255,0.03) 1px,
            transparent 1px,
            transparent 3px
        );
}

/* ---- CRT Vignette Overlay ---- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(0,0,0,0.4) 100%
    );
}

/* ---- Grid Dot Pattern (via background on body) ---- */
body {
    background-image:
        radial-gradient(circle, rgba(138,155,174,0.05) 1px, transparent 1px);
    background-size: calc(100vw / 80) calc(100vh / 24);
    background-position: 0 0;
}

/* ---- Scroll Progress Indicator ---- */
#scroll-progress {
    position: fixed;
    top: 0;
    right: 0;
    width: 1px;
    height: 0%;
    background: #4A6FA5;
    z-index: 10000;
    transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Fish Animation Layer ---- */
#fish-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
    filter: sepia(0.15) contrast(1.1) brightness(0.95);
}

.fish {
    position: absolute;
    opacity: 0.15;
    will-change: transform, opacity;
}

.fish svg {
    width: 100%;
    height: 100%;
}

/* Fish drift animations */
@keyframes fishDriftUp {
    0% { transform: translateY(110vh); }
    100% { transform: translateY(-15vh); }
}

@keyframes fishWobbleH {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(15px); }
    50% { transform: translateX(0); }
    75% { transform: translateX(-15px); }
}

@keyframes fishOpacityPulse {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.25; }
}

/* ---- Spring Animation Keyframes ---- */
@keyframes springIn {
    0% { transform: scale(0.6) translateY(20px); opacity: 0; }
    40% { transform: scale(1.1) translateY(-5px); opacity: 1; }
    60% { transform: scale(0.95) translateY(2px); opacity: 1; }
    80% { transform: scale(1.03) translateY(-1px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes springScale {
    0% { transform: scale(1); }
    30% { transform: scale(1.12); }
    55% { transform: scale(0.97); }
    75% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes springBlur {
    0% { filter: blur(8px); opacity: 0; }
    40% { filter: blur(0px); opacity: 1; }
    55% { filter: blur(1px); opacity: 1; }
    100% { filter: blur(0px); opacity: 1; }
}

@keyframes cursorBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 30px #2EA8A0; }
    100% { box-shadow: 0 0 0px transparent; }
}

@keyframes reefFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(3px, -5px) rotate(0.5deg); }
    50% { transform: translate(-2px, -8px) rotate(-0.3deg); }
    75% { transform: translate(4px, -3px) rotate(0.2deg); }
}

/* ---- Typography ---- */
.mono-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    line-height: 1.5;
    color: #7EE787;
}

.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.6rem, 4vw, 3.2rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #7EE787;
    margin-bottom: 1rem;
    animation: springBlur 0.8s ease-out both;
}

.section-subtitle {
    margin-bottom: 2rem;
    opacity: 0.7;
}

.prompt {
    color: #2EA8A0;
}

.highlight-teal {
    color: #2EA8A0;
    font-weight: 600;
}

.highlight-crimson {
    color: #E05D44;
    font-weight: 600;
}

/* ---- SECTION 1: Boot Sequence ---- */
#boot-sequence {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
}

.terminal-screen {
    width: 90%;
    max-width: 800px;
    padding: 2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    line-height: 1.5;
    color: #7EE787;
}

#boot-output {
    white-space: pre-wrap;
    word-break: break-all;
}

#boot-output .boot-line {
    display: block;
}

#boot-output .boot-ok {
    color: #2EA8A0;
    display: inline-block;
}

#boot-output .boot-ok.spring {
    animation: springScale 0.6s ease-out;
}

.cursor {
    display: inline-block;
    animation: cursorBlink 1.06s step-end infinite;
    color: #7EE787;
    font-weight: 600;
}

/* ---- SECTION 2: Main Content ---- */
#main-content {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0s linear 0.5s;
    position: relative;
    z-index: 2;
}

#main-content.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease, visibility 0s;
}

/* ---- Syllable Block Explorer ---- */
#syllable-explorer {
    min-height: 200vh;
    padding: 6rem 3rem 4rem;
}

.explorer-grid {
    display: grid;
    grid-template-columns: 55fr 10fr 35fr;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
}

.explorer-left {
    padding: 2rem;
}

.explorer-right {
    padding: 2rem;
    border-left: 1px solid #484F58;
}

.explorer-gutter {
    position: relative;
    overflow: hidden;
}

.aquarium-strip {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(26,58,74,0.1) 0%,
        rgba(46,168,160,0.05) 50%,
        rgba(26,58,74,0.1) 100%
    );
    border-left: 1px solid rgba(72,79,88,0.5);
    border-right: 1px solid rgba(72,79,88,0.5);
}

.gutter-fish {
    position: absolute;
    width: 30px;
    height: 20px;
    background: #8A9BAE;
    opacity: 0.15;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    left: 50%;
    transform: translateX(-50%);
}

.gutter-fish-1 {
    animation: fishDriftUp 25s linear infinite;
    animation-delay: 0s;
}
.gutter-fish-2 {
    animation: fishDriftUp 32s linear infinite;
    animation-delay: -10s;
    width: 24px;
    height: 16px;
}
.gutter-fish-3 {
    animation: fishDriftUp 20s linear infinite;
    animation-delay: -18s;
    width: 20px;
    height: 14px;
}

/* Syllable Display */
#syllable-display {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 2rem auto;
    background: #2D333B;
    border: 1px solid #484F58;
    border-radius: 4px;
}

#syllable-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#jamo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 55% 45%;
    grid-template-rows: 65% 35%;
}

.jamo-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: springIn 0.8s ease-out both;
}

.jamo-initial {
    grid-column: 1;
    grid-row: 1;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #2EA8A0;
}

.jamo-medial {
    grid-column: 2;
    grid-row: 1;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #E05D44;
}

.jamo-final {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #D4A72C;
}

.syllable-label {
    text-align: center;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.syllable-result {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    color: #7EE787;
}

.block-annotations {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.annotation {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.annotation-marker {
    font-size: 0.6rem;
    margin-top: 0.35rem;
    flex-shrink: 0;
}

.annotation .mono-text {
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
}

/* Terminal Commentary */
.terminal-commentary {
    position: sticky;
    top: 2rem;
}

.terminal-commentary p {
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid #2D333B;
    transition: border-color 0.3s ease;
}

.terminal-commentary p:hover {
    border-left-color: #2EA8A0;
}

/* ---- Vowel Meridian ---- */
#vowel-meridian {
    min-height: 100vh;
    padding: 6rem 2rem;
    position: relative;
}

.vowel-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    justify-content: center;
    max-width: 1400px;
    margin: 0 auto;
}

.vowel-tank {
    position: relative;
    width: clamp(70px, 8vw, 120px);
    height: clamp(100px, 12vw, 180px);
    background: rgba(45,51,59,0.6);
    border: 1px solid #484F58;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 4px;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
    overflow: hidden;
}

.vowel-tank::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(26,58,74,0.2) 0%,
        rgba(46,168,160,0.05) 100%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
}

.vowel-tank:hover::before {
    opacity: 1;
}

.vowel-tank:hover {
    border-color: #2EA8A0;
    transform: translateY(-4px) scale(1.05);
}

.vowel-tank:nth-child(odd) {
    margin-top: 20px;
}

.vowel-tank:nth-child(3n) {
    margin-top: 35px;
}

.vowel-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 700;
    color: #7EE787;
    position: relative;
    z-index: 1;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.vowel-tank:hover .vowel-char {
    color: #2EA8A0;
    text-shadow: 0 0 20px rgba(46,168,160,0.4);
}

.vowel-name {
    font-size: 0.7rem !important;
    color: #484F58;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
}

.vowel-tank:hover .vowel-name {
    color: #8A9BAE;
}

/* ---- Consonant Reef ---- */
#consonant-reef {
    min-height: 100vh;
    padding: 6rem 2rem;
    position: relative;
}

.reef-scatter {
    position: relative;
    width: 100%;
    max-width: 1200px;
    height: 80vh;
    margin: 2rem auto;
}

.reef-jamo {
    position: absolute;
    left: calc(var(--rx) * 1%);
    top: calc(var(--ry) * 1%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default;
    animation: reefFloat 8s ease-in-out infinite;
    animation-delay: calc(var(--rx) * -0.1s);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reef-jamo:hover {
    transform: scale(1.2);
    z-index: 10;
}

.consonant-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    color: #7EE787;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    filter: sepia(0.15) contrast(1.1) brightness(0.95);
}

.reef-jamo:hover .consonant-char {
    color: #E05D44;
    text-shadow: 0 0 25px rgba(224,93,68,0.4);
}

.consonant-name {
    font-size: 0.65rem !important;
    color: #484F58;
    margin-top: 0.25rem;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.reef-jamo:hover .consonant-name {
    color: #8A9BAE;
}

/* ---- Final Sequence: Assembly Terminal ---- */
#final-sequence {
    min-height: 50vh;
    padding: 6rem 2rem 8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.assembly-terminal {
    width: 100%;
    max-width: 700px;
    background: #2D333B;
    border: 1px solid #484F58;
    border-radius: 4px;
    padding: 2rem;
    text-align: center;
}

.assembly-prompt {
    margin-bottom: 2rem;
}

#assembly-stage {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 1.5rem;
    background: rgba(13,17,23,0.8);
    border: 1px solid #484F58;
    border-radius: 4px;
    overflow: hidden;
}

#assembled-syllable {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 8rem;
    font-weight: 700;
    color: #7EE787;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#assembled-syllable.show {
    opacity: 1;
    animation: glowPulse 0.8s ease-out;
}

#jamo-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.jamo-particle {
    position: absolute;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    color: #2EA8A0;
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#assembly-info {
    min-height: 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem !important;
}

.assembly-hint {
    font-size: 0.8rem !important;
    color: #484F58 !important;
    margin-bottom: 1.5rem;
}

.demo-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.demo-btn {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    background: rgba(13,17,23,0.6);
    color: #8A9BAE;
    border: 1px solid #484F58;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.demo-btn:hover {
    border-color: #2EA8A0;
    color: #7EE787;
    transform: scale(1.08);
    box-shadow: 0 0 15px rgba(46,168,160,0.2);
}

.demo-btn:active {
    transform: scale(0.95);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .explorer-grid {
        grid-template-columns: 1fr;
    }

    .explorer-gutter {
        height: 60px;
    }

    .explorer-right {
        border-left: none;
        border-top: 1px solid #484F58;
    }

    .aquarium-strip {
        border-left: none;
        border-right: none;
        border-top: 1px solid rgba(72,79,88,0.5);
        border-bottom: 1px solid rgba(72,79,88,0.5);
    }

    .gutter-fish {
        left: auto;
        top: 50%;
        transform: translateY(-50%);
    }

    .gutter-fish-1 { left: 20%; }
    .gutter-fish-2 { left: 50%; }
    .gutter-fish-3 { left: 75%; }

    .reef-scatter {
        height: auto;
        min-height: 80vh;
    }

    #syllable-explorer {
        padding: 4rem 1.5rem 3rem;
    }

    #vowel-meridian,
    #consonant-reef,
    #final-sequence {
        padding: 4rem 1rem;
    }
}

@media (max-width: 600px) {
    .vowel-tank {
        width: clamp(55px, 18vw, 80px);
        height: clamp(80px, 22vw, 120px);
    }

    #assembly-stage {
        width: 220px;
        height: 220px;
    }

    #assembled-syllable {
        font-size: 5rem;
    }

    .jamo-particle {
        font-size: 2rem;
    }
}

/* ---- Visible grid lines at 8% opacity ---- */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, rgba(138,155,174,0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(138,155,174,0.08) 1px, transparent 1px);
    background-size: calc(100vw / 80) calc(100vh / 24);
}
