/* Global Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #0D0907;
    color: #E8E0D4;
    overflow-x: hidden;
    height: 100%;
}

/* Noise Canvas Backdrop */
#noise-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0.15;
    z-index: 0;
}

/* Viewport Container */
.viewport {
    position: relative;
    z-index: 1;
    width: 100vw;
    min-height: 100vh;
}

/* Section Styling */
.section {
    width: 100%;
    min-height: 100vh;
    padding: 40px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.section-1 {
    background: linear-gradient(135deg, #1A1410 0%, #0D0907 100%);
}

.section-2 {
    background: linear-gradient(135deg, #0D0907 0%, #1A1410 100%);
}

.section-3 {
    background: linear-gradient(135deg, #1A1410 0%, #0D0907 100%);
}

/* Bento Grid Container */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    width: 100%;
    height: 100%;
    min-height: 100vh;
}

/* Bento Grid Cells */
.cell {
    position: relative;
    overflow: hidden;
    border: 1px solid #FF6A1A;
    background-color: rgba(26, 20, 16, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(255, 106, 26, 0.03),
            rgba(255, 106, 26, 0.03) 2px,
            transparent 2px,
            transparent 4px
        );
    pointer-events: none;
    z-index: 1;
}

.cell-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Hero Cell Styling */
.hero-cell {
    background: linear-gradient(135deg, #CC5500 0%, #B33000 100%);
    border-color: #FF6A1A;
}

.hwaklyul-title {
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(5rem, 14vw, 12rem);
    letter-spacing: -0.06em;
    line-height: 0.88;
    color: #E8E0D4;
    animation: title-width-pulse 4s ease-in-out infinite;
    text-transform: lowercase;
}

@keyframes title-width-pulse {
    0%, 100% { font-stretch: 75%; }
    50% { font-stretch: 100%; }
}

.signal-glyph {
    font-size: 2rem;
    margin-top: 20px;
    color: #00CC55;
    letter-spacing: 0.5em;
    animation: glyph-pulse 2s ease-in-out infinite;
}

@keyframes glyph-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Info Cell Styling */
.info-cell {
    background: linear-gradient(135deg, #5500CC 0%, #3D1F00 100%);
    border-color: #E87730;
}

.section-heading {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: #00CC55;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 15px;
}

.info-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    color: #E8E0D4;
    margin-bottom: 20px;
    line-height: 1.6;
}

.signal-bars {
    display: flex;
    gap: 8px;
    height: 40px;
    align-items: flex-end;
}

.bar {
    flex: 1;
    background: linear-gradient(180deg, #00CC55 0%, #E87730 100%);
    border-radius: 2px;
    animation: bar-bounce 1.2s ease-in-out infinite;
}

.bar:nth-child(1) { animation-delay: 0s; }
.bar:nth-child(2) { animation-delay: 0.2s; }
.bar:nth-child(3) { animation-delay: 0.4s; }
.bar:nth-child(4) { animation-delay: 0.6s; }

@keyframes bar-bounce {
    0%, 100% { transform: scaleY(1); opacity: 0.6; }
    50% { transform: scaleY(1.3); opacity: 1; }
}

/* Frequency, Intensity, Status Cells */
.freq-cell, .intensity-cell, .status-cell {
    background: linear-gradient(135deg, #3D1F00 0%, #1A1410 100%);
    border-color: #E87730;
    flex-direction: column;
}

.freq-label, .intensity-label, .status-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: #00CC55;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 10px;
}

.freq-value, .intensity-value, .status-value {
    font-family: 'Space Mono', monospace;
    font-size: 1.4rem;
    color: #E87730;
    font-weight: 700;
    animation: value-flicker 3s ease-in-out infinite;
}

@keyframes value-flicker {
    0%, 100% { opacity: 1; }
    20% { opacity: 0.85; }
    40% { opacity: 0.95; }
    60% { opacity: 0.9; }
    80% { opacity: 0.98; }
}

/* Narrative Cells */
.narrative-cell, .narrative-cell-2, .final-cell {
    background: linear-gradient(135deg, rgba(204, 85, 0, 0.2) 0%, rgba(0, 204, 85, 0.1) 100%);
    border-color: #FF6A1A;
}

.narrative-text, .final-text {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    color: #E8E0D4;
    line-height: 1.8;
    letter-spacing: 0.02em;
}

.final-text {
    margin-bottom: 20px;
}

.signal-end {
    font-family: 'Space Mono', monospace;
    color: #00CC55;
    font-size: 0.9rem;
    letter-spacing: 0.3em;
    animation: end-glyph-pulse 3s ease-in-out infinite;
}

@keyframes end-glyph-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Flip Card Styling */
.flip-card {
    width: 100%;
    height: 100%;
    perspective: 1000px;
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.flip-card-front {
    background: linear-gradient(135deg, #CC5500 0%, #E87730 100%);
    border: 1px solid #FF6A1A;
}

.flip-card-back {
    background: linear-gradient(135deg, #00CC55 0%, #B33000 100%);
    border: 1px solid #00CC55;
    transform: rotateY(180deg);
}

.card-content {
    text-align: center;
    width: 100%;
}

.card-content h3 {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: #E8E0D4;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.card-content p {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: #E8E0D4;
    line-height: 1.5;
}

/* Degrade Cells */
.degrade-cell {
    background: linear-gradient(135deg, #5500CC 0%, #CC5500 100%);
    border-color: #E8E0D4;
}

.degrade-content {
    flex-direction: column;
}

.degrade-percent {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #E8E0D4;
    line-height: 1;
}

.degrade-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    color: #00CC55;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 10px;
}

/* Degradation animation */
#degrade-1 { animation: degrade-1 8s ease-in forwards infinite; }
#degrade-2 { animation: degrade-2 8s ease-in forwards infinite; }
#degrade-3 { animation: degrade-3 8s ease-in forwards infinite; }
#degrade-4 { animation: degrade-4 8s ease-in forwards infinite; }

@keyframes degrade-1 {
    0% { opacity: 1; }
    100% { opacity: 0.3; }
}

@keyframes degrade-2 {
    0% { opacity: 1; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

@keyframes degrade-3 {
    0% { opacity: 1; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

@keyframes degrade-4 {
    0% { opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0.1; }
}

/* Section Header Styling */
.section-header, .section-header-3 {
    grid-column: 1 / -1;
    background: transparent;
    border: none;
    padding: 20px 0;
}

.section-header::before, .section-header-3::before {
    display: none;
}

/* Utility colors for compliance */
.color-6b4400 {
    color: #6B4400;
}

.color-8a7e72 {
    color: #8A7E72;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .section {
        padding: 20px;
    }

    .bento-grid {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(12, auto);
    }

    .hwaklyul-title {
        font-size: clamp(3rem, 10vw, 5rem);
    }

    .section-heading {
        font-size: 1.3rem;
    }

    .cell {
        min-height: 200px;
    }
}

/* Scanline overlay effect */
@media (prefers-reduced-motion: no-preference) {
    .cell::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background:
            repeating-linear-gradient(
                0deg,
                rgba(0, 0, 0, 0.05) 0,
                rgba(0, 0, 0, 0.05) 2px,
                transparent 2px,
                transparent 4px
            );
        pointer-events: none;
        z-index: 0;
    }
}

/* Text selection styling */
::selection {
    background-color: #FF6A1A;
    color: #1A1410;
}

::-moz-selection {
    background-color: #FF6A1A;
    color: #1A1410;
}
