/* === RESET & BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    background: #1a1410; /* #f5ece0 crystal highlight, #d4956a oxidized copper */
    color: #f0e4d4;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* === SCANLINES === */
.scanlines {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(26,20,16,0.15) 1px,
        rgba(26,20,16,0.15) 2px
    );
    pointer-events: none;
    z-index: 9999;
    animation: scanline-scroll 8s linear infinite;
}
@keyframes scanline-scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(20px); }
}

/* === SECTION 1: IGNITION === */
.ignition {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(ellipse at center, #2d1f18 0%, #1a1410 70%);
    overflow: hidden;
}
.ignition-content { text-align: center; position: relative; z-index: 2; }
.hero-hangul {
    width: clamp(280px, 60vw, 700px);
    height: auto;
    display: block;
    margin: 0 auto;
}
.hangul-char polygon {
    opacity: 0;
    animation: char-assemble 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hangul-char polygon:nth-child(1) { animation-delay: 0.1s; }
.hangul-char polygon:nth-child(2) { animation-delay: 0.2s; }
.hangul-char polygon:nth-child(3) { animation-delay: 0.3s; }
.hangul-char polygon:nth-child(4) { animation-delay: 0.4s; }
.hangul-char polygon:nth-child(5) { animation-delay: 0.5s; }
.hangul-char polygon:nth-child(6) { animation-delay: 0.6s; }
.hangul-char polygon:nth-child(7) { animation-delay: 0.7s; }
.hangul-char[data-delay="200"] polygon:nth-child(1) { animation-delay: 0.3s; }
.hangul-char[data-delay="200"] polygon:nth-child(2) { animation-delay: 0.4s; }
.hangul-char[data-delay="200"] polygon:nth-child(3) { animation-delay: 0.5s; }
.hangul-char[data-delay="200"] polygon:nth-child(4) { animation-delay: 0.6s; }
.hangul-char[data-delay="200"] polygon:nth-child(5) { animation-delay: 0.7s; }
.hangul-char[data-delay="200"] polygon:nth-child(6) { animation-delay: 0.8s; }
.hangul-char[data-delay="200"] polygon:nth-child(7) { animation-delay: 0.9s; }

@keyframes char-assemble {
    0% {
        opacity: 0;
        transform: translate(calc(-5px + 10px * var(--rand, 0.5)), -8px);
        filter: hue-rotate(15deg);
    }
    60% {
        opacity: 0.7;
        filter: hue-rotate(-5deg);
    }
    100% {
        opacity: var(--target-opacity, 0.85);
        transform: translate(0, 0);
        filter: none;
    }
}

.hero-subtitle {
    margin-top: 2rem;
    overflow: hidden;
}
.subtitle-text {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f0e4d4;
    display: inline-block;
    animation: subtitle-reveal 1.2s 1.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes subtitle-reveal {
    0% { opacity: 0; transform: translateY(100%); }
    100% { opacity: 1; transform: translateY(0); }
}

.deco-rule {
    width: 0;
    height: 3px;
    margin: 1.5rem auto 0;
    background: linear-gradient(90deg, #c4623a, #e8b86d);
    animation: rule-draw 0.8s 1.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes rule-draw {
    0% { width: 0; }
    100% { width: clamp(120px, 25vw, 300px); }
}

/* Corner fans */
.corner-fan { position: absolute; width: 120px; height: 120px; }
.corner-fan.top-left { top: 0; left: 0; }
.corner-fan.bottom-right { bottom: 0; right: 0; }

/* === SECTION 2: BENTO GRID === */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: 3px;
    background: linear-gradient(135deg, #c4623a, #e8b86d);
    width: 100vw;
    margin: 0;
    padding: 0;
}
.cell {
    background: #1a1410;
    overflow: hidden;
    position: relative;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1), transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cell.visible {
    opacity: 1;
    transform: translateY(0);
}
.cell--wide { grid-column: span 6; }
.cell--tall { grid-row: span 2; }
.cell--feature { grid-column: span 8; grid-row: span 2; }
.cell--square { grid-column: span 3; grid-row: span 1; aspect-ratio: 1; }

.cell-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.65rem, 0.8vw, 0.8rem);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #a89080;
    position: absolute;
    top: 1.2rem;
    left: 1.5rem;
}
.cell-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f0e4d4;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}
.cell-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    color: #a89080;
    font-size: clamp(0.85rem, 1vw, 1rem);
    line-height: 1.7;
    max-width: 45ch;
}
.iso-icon {
    width: clamp(80px, 12vw, 140px);
    height: auto;
    margin-bottom: 1rem;
}

/* Cell hover glitch */
.cell::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #ff6b35;
    opacity: 0;
    mix-blend-mode: screen;
    pointer-events: none;
    transition: opacity 0.12s;
}
.cell:hover::after {
    animation: glitch-flash 0.15s steps(3) 1;
}
@keyframes glitch-flash {
    0% { opacity: 0.08; clip-path: inset(0 0 85% 0); transform: translate(-3px, 0); }
    25% { opacity: 0.12; clip-path: inset(40% 0 20% 0); transform: translate(3px, 0); }
    50% { opacity: 0.06; clip-path: inset(70% 0 5% 0); transform: translate(-2px, 1px); }
    75% { opacity: 0.1; clip-path: inset(10% 0 60% 0); transform: translate(2px, -1px); }
    100% { opacity: 0; clip-path: inset(0); transform: translate(0); }
}

/* === SECTION 3: CRYSTALLINE INTERLUDE === */
.interlude {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #2d1f18 0%, #1a1410 80%);
    position: relative;
    overflow: hidden;
}
.crystal-assembly {
    width: clamp(250px, 45vw, 450px);
    height: auto;
}
.crystal-svg { width: 100%; height: auto; }
.crystal-face {
    transform-origin: 200px 200px;
}
.interlude-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: #a89080;
    letter-spacing: 0.04em;
    margin-top: 3rem;
    opacity: 0;
    transition: opacity 1s ease;
}
.interlude-text.visible { opacity: 1; color: #f5ece0; }

/* === SECTION 4: ARCHIVE CORRIDOR === */
.archive {
    padding: 3px 0;
    background: linear-gradient(135deg, #c4623a, #e8b86d);
}
.archive-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: 3px;
    max-width: 100vw;
}
.archive-cell {
    grid-column: span 2;
}
.archive-portrait {
    width: clamp(60px, 8vw, 100px);
    height: auto;
    margin-bottom: 0.75rem;
}

/* === SECTION 5: TERMINAL === */
.terminal {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #2d1f18 0%, #1a1410 70%);
    position: relative;
}
.terminal-content { text-align: center; }
.terminal-hangul {
    width: clamp(220px, 50vw, 550px);
}
.glitch-perpetual polygon {
    animation: micro-glitch 4s infinite steps(3);
}
@keyframes micro-glitch {
    0%, 90%, 100% { transform: translate(0); filter: none; }
    92% { transform: translate(-2px, 1px); filter: hue-rotate(10deg); }
    94% { transform: translate(2px, -1px); filter: hue-rotate(-5deg); }
    96% { transform: translate(-1px, 0); }
    98% { transform: translate(1px, 1px); filter: hue-rotate(5deg); }
}
.terminal-phrase {
    font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #f0e4d4;
    margin-top: 2rem;
    word-break: keep-all;
    font-feature-settings: "kern" 1;
    opacity: 0;
    transition: opacity 1.5s ease;
}
.terminal-phrase.visible { opacity: 1; }
.terminal-phrase.visible ~ .terminal-translation { color: #d4956a; }
.terminal-translation {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: #a89080;
    letter-spacing: 0.06em;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 1.5s 0.5s ease;
}
.terminal-translation.visible { opacity: 1; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .bento-grid { grid-template-columns: repeat(8, 1fr); }
    .cell--wide { grid-column: span 4; }
    .cell--feature { grid-column: span 6; }
    .archive-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 768px) {
    .bento-grid { grid-template-columns: repeat(4, 1fr); }
    .cell--wide, .cell--feature { grid-column: span 4; }
    .cell--square { grid-column: span 2; }
    .cell[style*="span 3"] { grid-column: span 2 !important; }
    .cell[style*="span 4"] { grid-column: span 4 !important; }
    .cell[style*="span 5"] { grid-column: span 4 !important; }
    .cell[style*="span 7"] { grid-column: span 4 !important; }
    .archive-grid { grid-template-columns: repeat(4, 1fr); }
    .archive-cell { grid-column: span 4 !important; grid-row: span 1 !important; }
}
