/* ============================================
   COZZZBLACK — 부팅 시퀀스 (앰버 CRT / 올드 PC)
   ============================================ */

:root {
    --amber: #ffb02e;
    --amber-bright: #ffd77a;
    --amber-dim: #a8681a;
    --crt-bg: #0d0904;
}

html.boot-lock,
body.boot-lock {
    overflow: hidden !important;
}

#boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: var(--crt-bg);
    overflow: hidden;
    transform-origin: center center;
    font-family: 'Galmuri9', 'Galmuri7', 'Courier New', monospace;
}

#boot-overlay.is-black {
    background: #060402;
}

/* --- CRT 질감 --- */
#boot-scanlines {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    background: repeating-linear-gradient(to bottom,
            rgba(255, 176, 46, 0.05) 0px,
            rgba(255, 176, 46, 0.05) 1px,
            transparent 1px,
            transparent 3px);
    animation: bootScanDrift 8s linear infinite;
}

@keyframes bootScanDrift {
    from { background-position-y: 0; }
    to   { background-position-y: 60px; }
}

#boot-vignette {
    position: absolute;
    inset: 0;
    z-index: 9;
    pointer-events: none;
    background: radial-gradient(ellipse at center,
            transparent 42%,
            rgba(0, 0, 0, 0.62) 100%);
}

/* --- 스테이지 --- */
#boot-stage {
    position: absolute;
    inset: 0;
    z-index: 3;
    transition: opacity 0.45s ease;
}

#boot-stage.is-gone {
    opacity: 0;
}

/* --- 플로피 디스크 --- */
#boot-floppy-wrap {
    position: absolute;
    left: 50%;
    top: 55%;
    z-index: 3;
    cursor: pointer;
    outline: none;
    transform: translate(-50%, -50%);
}

#boot-floppy {
    display: block;
    width: 172px;
    height: 172px;
    filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 22px rgba(255, 176, 46, 0.22));
    transform-origin: center bottom;
    animation: floppyIdle 3.6s ease-in-out infinite;
    transition: transform 0.7s cubic-bezier(0.45, 0, 0.55, 1), filter 0.5s ease;
}

@keyframes floppyIdle {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-12px) rotate(3deg); }
}

#boot-floppy-wrap:hover #boot-floppy,
#boot-floppy-wrap:focus-visible #boot-floppy {
    filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 34px rgba(255, 176, 46, 0.65));
}

/* 1단계: 슬롯 입구에 정렬 */
#boot-floppy-wrap.to-mouth #boot-floppy {
    animation: none;
    transform: translateY(var(--y-mouth, -200px)) rotate(0deg);
}

/* 2단계: 드라이브 안으로 완전히 삽입 */
#boot-floppy-wrap.inserting #boot-floppy {
    animation: none;
    transform: translateY(var(--y-in, -420px)) rotate(0deg);
    transition: transform 1.05s cubic-bezier(0.7, 0.02, 0.3, 1);
}

/* 슬롯 위쪽을 가려 디스크가 빨려 들어가 보이게 함 */
#boot-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    background: var(--crt-bg);
    z-index: 4;
    pointer-events: none;
}

#boot-overlay.is-black #boot-mask {
    background: #060402;
}

/* --- 드라이브 --- */
#boot-drive {
    position: absolute;
    left: 50%;
    top: 16%;
    transform: translateX(-50%);
    z-index: 5;
}

#boot-drive-face {
    position: relative;
    width: 292px;
    padding: 34px 18px 5px;
    border-radius: 5px;
    background: linear-gradient(180deg, #33302a 0%, #201e19 55%, #131210 100%);
    border: 1px solid #4d483d;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.09),
        inset 0 -2px 6px rgba(0, 0, 0, 0.7),
        0 18px 40px rgba(0, 0, 0, 0.65);
}

#boot-drive.clunk #boot-drive-face {
    animation: driveClunk 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes driveClunk {
    0%, 100% { transform: translateY(0); }
    20%      { transform: translateY(3px) scaleY(0.985); }
    45%      { transform: translateY(-2px); }
    70%      { transform: translateY(1px); }
}

#boot-slot {
    width: 214px;
    margin: 0 auto;
    height: 16px;
    border-radius: 2px;
    background: #000;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 3px 7px rgba(0, 0, 0, 1),
        inset 0 -1px 0 rgba(255, 255, 255, 0.12),
        0 1px 0 rgba(255, 255, 255, 0.07);
}

#boot-slot-inner {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 176, 46, 0.25), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#boot-drive.active #boot-slot-inner { opacity: 1; }

#boot-drive-led {
    position: absolute;
    right: 20px;
    top: 13px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #2a1c08;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.9);
}

#boot-drive.active #boot-drive-led {
    background: var(--amber);
    box-shadow: 0 0 12px 3px rgba(255, 176, 46, 0.8);
    animation: ledBlink 0.16s steps(1) infinite;
}

@keyframes ledBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

#boot-eject {
    position: absolute;
    left: 20px;
    top: 12px;
    width: 30px;
    height: 12px;
    border-radius: 2px;
    background: linear-gradient(180deg, #454036, #26231d);
    border: 1px solid #57513f;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* --- 안내 문구 --- */
#boot-hint {
    position: absolute;
    left: 50%;
    top: 78%;
    transform: translateX(-50%);
    z-index: 6;
    margin: 0;
    color: var(--amber);
    font-size: 0.85rem;
    letter-spacing: 4px;
    white-space: nowrap;
    animation: hintPulse 1.6s ease-in-out infinite;
    transition: opacity 0.25s ease;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.35; text-shadow: none; }
    50%      { opacity: 1; text-shadow: 0 0 16px rgba(255, 176, 46, 0.9); }
}

#boot-hint.is-hidden {
    opacity: 0;
    animation: none;
}

#boot-skip {
    position: absolute;
    right: 22px;
    bottom: 18px;
    z-index: 10;
    margin: 0;
    color: rgba(255, 176, 46, 0.32);
    font-size: 0.7rem;
    letter-spacing: 2px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#boot-skip.is-visible { opacity: 1; }

/* --- 글리치 플래시 --- */
#boot-flash {
    position: absolute;
    inset: 0;
    z-index: 7;
    opacity: 0;
    background: #000;
    pointer-events: none;
}

#boot-flash.bands {
    background: repeating-linear-gradient(to bottom,
            rgba(255, 176, 46, 0.85) 0px,
            rgba(255, 176, 46, 0.85) 4px,
            rgba(120, 40, 0, 0.7) 4px,
            rgba(120, 40, 0, 0.7) 9px,
            rgba(255, 240, 200, 0.95) 9px,
            rgba(255, 240, 200, 0.95) 13px);
    animation: bandSlide 0.12s steps(2) infinite;
}

@keyframes bandSlide {
    from { transform: translateY(0); }
    to   { transform: translateY(13px); }
}

/* --- BIOS 터미널 --- */
#boot-term {
    position: absolute;
    left: 7vw;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: min(640px, 84vw);
    color: var(--amber);
    font-size: clamp(0.68rem, 1.05vw, 0.92rem);
    line-height: 2;
    letter-spacing: 0.5px;
    text-shadow: 0 0 9px rgba(255, 176, 46, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

#boot-term.is-visible { opacity: 1; }

#boot-term .ok      { color: var(--amber-bright); }
#boot-term .dim     { color: var(--amber-dim); }
#boot-term .headline {
    color: var(--amber-bright);
    text-shadow: 0 0 14px rgba(255, 215, 122, 0.8);
}

/* 진행 막대 */
#boot-progress {
    margin-top: 18px;
    height: 14px;
    border: 1px solid rgba(255, 176, 46, 0.55);
    padding: 2px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#boot-progress.is-visible { opacity: 1; }

#boot-progress-bar {
    display: block;
    height: 100%;
    width: 0%;
    background: repeating-linear-gradient(90deg,
            var(--amber) 0px,
            var(--amber) 7px,
            transparent 7px,
            transparent 10px);
    box-shadow: 0 0 12px rgba(255, 176, 46, 0.7);
    transition: width 0.12s linear;
}

/* --- CRT 전원 꺼짐 → 도시 등장 --- */
#boot-overlay.crt-off {
    animation: crtOff 0.62s cubic-bezier(0.6, 0, 0.9, 0.2) forwards;
}

@keyframes crtOff {
    0%   { transform: scale(1, 1);        filter: brightness(1); }
    45%  { transform: scale(1, 0.9);      filter: brightness(2.2); }
    70%  { transform: scale(1.02, 0.012); filter: brightness(4); }
    100% { transform: scale(1.02, 0.004); filter: brightness(6); opacity: 1; }
}

#boot-crt-line {
    position: fixed;
    left: 0;
    top: 50%;
    width: 100%;
    height: 3px;
    background: #fff6e2;
    box-shadow: 0 0 24px 6px rgba(255, 230, 180, 0.9), 0 0 60px 16px rgba(255, 176, 46, 0.75);
    transform: translateY(-50%) scaleX(1);
    opacity: 0;
    z-index: 100001;
    pointer-events: none;
}

#boot-crt-line.is-firing {
    animation: crtLine 0.55s ease-in forwards;
}

@keyframes crtLine {
    0%   { opacity: 1; transform: translateY(-50%) scaleX(1); }
    55%  { opacity: 1; transform: translateY(-50%) scaleX(0.75); }
    100% { opacity: 0; transform: translateY(-50%) scaleX(0); }
}

/* --- 모바일 --- */
@media (max-width: 900px) {
    #boot-floppy { width: 128px; height: 128px; }
    #boot-drive-face { width: 230px; }
    #boot-slot { width: 168px; }
    #boot-term { left: 6vw; font-size: 0.68rem; line-height: 1.9; }
}
