/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    color: #3d3632;
    background: #c4a882;
    overflow-x: hidden;
}

/* === TYPOGRAPHY === */
h1, h2, .dial-text, .meter-label, .teletype-label {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 1.0;
    text-transform: uppercase;
}

.drawer-title, .peg-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.05em;
    color: #6b8f7b;
    margin-bottom: 0.75rem;
}

.teletype-screen, .teletype-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: #8a7e74;
}

/* === BUBBLES CONTAINER === */
#bubbles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), rgba(137,180,200,0.2) 40%, rgba(212,200,232,0.15) 70%, rgba(232,168,76,0.1) 90%, transparent);
    border: 1px solid rgba(255,255,255,0.3);
    animation: floatUp var(--duration) cubic-bezier(0.37, 0, 0.63, 1) infinite;
    animation-delay: var(--delay);
    opacity: var(--opacity);
    left: var(--left);
    bottom: -200px;
}

.bubble::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) translateX(0);
        opacity: var(--opacity);
    }
    25% {
        transform: translateY(-30vh) translateX(var(--drift));
    }
    50% {
        transform: translateY(-60vh) translateX(calc(var(--drift) * -0.5));
    }
    75% {
        transform: translateY(-90vh) translateX(var(--drift));
    }
    100% {
        transform: translateY(-120vh) translateX(0);
        opacity: 0;
    }
}

/* === SECTION 1: WORKBENCH === */
.section-workbench {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.desk-surface {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(139,90,43,0.05) 40px,
            rgba(139,90,43,0.05) 41px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 120px,
            rgba(139,90,43,0.08) 120px,
            rgba(139,90,43,0.08) 122px
        ),
        linear-gradient(180deg, #c4a882 0%, #b89b72 100%);
    z-index: 0;
}

.instruments {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
    padding: 2rem;
}

/* === SCREWS === */
.screw {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #d4c090, #8a7040);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
    z-index: 5;
}
.screw::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 1px;
    background: rgba(0,0,0,0.4);
    transform: translate(-50%, -50%) rotate(45deg);
}
.screw-tl { top: 8px; left: 8px; }
.screw-tr { top: 8px; right: 8px; }
.screw-bl { bottom: 8px; left: 8px; }
.screw-br { bottom: 8px; right: 8px; }

/* === GLASS OVERLAY === */
.glass-overlay {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%, rgba(0,0,0,0.05) 100%);
    pointer-events: none;
    transition: background-position 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.instrument:hover .glass-overlay {
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.1) 30%, transparent 60%, rgba(0,0,0,0.05) 100%);
}

/* === INSTRUMENT BASE === */
.instrument {
    position: relative;
    background: #2e2420;
    border: 3px solid;
    border-image: linear-gradient(180deg, #b8963e, #8a7040, #b8963e) 1;
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 4px 12px rgba(0,0,0,0.4);
    opacity: 0;
    animation: fadeInInstrument 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.instrument:nth-child(1) { animation-delay: 0s; }
.instrument:nth-child(2) { animation-delay: 0.5s; }
.instrument:nth-child(3) { animation-delay: 1s; }

@keyframes fadeInInstrument {
    to { opacity: 1; }
}

/* === DIAL INSTRUMENT === */
.instrument-dial {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    order: 2;
}

.dial-face {
    position: relative;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, #f2ead8 60%, #e8d5c0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dial-text {
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: #4a3728;
    letter-spacing: 0.3em;
}

.dial-needle {
    position: absolute;
    width: 3px;
    height: 90px;
    background: linear-gradient(to top, #b8963e, #e8a84c);
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    animation: needleSpin 30s linear infinite;
    border-radius: 2px;
}

.dial-center {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #d4c090, #8a7040);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

@keyframes needleSpin {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

/* === METER INSTRUMENT === */
.instrument-meter {
    width: 200px;
    height: 260px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    order: 1;
}

.meter-label {
    color: #e8d5c0;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
}

.meter-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 1rem 0;
}

.meter-bar {
    width: 14px;
    background: linear-gradient(to top, #6b8f7b, #e8a84c);
    border-radius: 2px;
    animation: meterPulse 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

.meter-bar:nth-child(1) { animation-delay: 0s; height: 40%; }
.meter-bar:nth-child(2) { animation-delay: 0.15s; height: 65%; }
.meter-bar:nth-child(3) { animation-delay: 0.3s; height: 50%; }
.meter-bar:nth-child(4) { animation-delay: 0.45s; height: 80%; }
.meter-bar:nth-child(5) { animation-delay: 0.6s; height: 55%; }
.meter-bar:nth-child(6) { animation-delay: 0.75s; height: 90%; }
.meter-bar:nth-child(7) { animation-delay: 0.9s; height: 45%; }
.meter-bar:nth-child(8) { animation-delay: 1.05s; height: 70%; }

@keyframes meterPulse {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.6); }
}

/* === TELETYPE INSTRUMENT === */
.instrument-teletype {
    width: 220px;
    height: 260px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    order: 3;
}

.teletype-label {
    color: #e8d5c0;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    text-align: center;
}

.teletype-screen {
    background: #1a1412;
    border-radius: 4px;
    padding: 0.75rem;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.teletype-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: scrollTeletype 12s linear infinite;
    color: #6b8f7b;
}

.teletype-text span {
    display: block;
    white-space: nowrap;
    font-size: 0.75rem;
}

@keyframes scrollTeletype {
    0% { transform: translateY(100%); }
    100% { transform: translateY(-100%); }
}

/* === SECTION 2: DRAWERS === */
.section-drawers {
    position: relative;
    min-height: 200vh;
    background: linear-gradient(180deg, #c4a882 0%, #2e2420 5%, #2e2420 100%);
    padding: 6rem 5vw;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5vw;
    align-content: start;
}

.drawer {
    position: relative;
    background: #f2ead8;
    border-radius: 4px;
    padding: 2.5rem 2rem 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
}

.drawer.visible {
    opacity: 1;
    transform: translateY(0);
}

.drawer:hover {
    box-shadow: 0 12px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.drawer-half {
    grid-column: span 1;
}

.drawer-full {
    grid-column: span 2;
}

.drawer-handle {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(180deg, #b8963e, #8a7040, #b8963e);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.drawer-content p {
    color: #3d3632;
}

/* === SECTION 3: PEGBOARD === */
.section-pegboard {
    position: relative;
    min-height: 200vh;
    padding: 6rem 5vw;
    background:
        radial-gradient(circle, rgba(74,55,40,0.3) 3px, transparent 3px),
        #c4a882;
    background-size: 30px 30px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    align-content: start;
}

.hangul-stamp {
    position: absolute;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 8rem;
    color: #b8963e;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}
.stamp-1 { top: 5%; left: 10%; transform: rotate(-8deg); }
.stamp-2 { top: 20%; right: 8%; transform: rotate(5deg); }
.stamp-3 { bottom: 30%; left: 5%; transform: rotate(3deg); }
.stamp-4 { bottom: 10%; right: 15%; transform: rotate(-4deg); }

.pegboard-module {
    position: relative;
    background: #f2ead8;
    border-radius: 4px;
    padding: 2.5rem 1.5rem 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
}

.pegboard-module.module-left {
    transform: translateX(-60px);
    grid-column: 1 / 3;
}
.pegboard-module.module-right {
    transform: translateX(60px);
    grid-column: 2 / 4;
}
.pegboard-module.module-center {
    transform: translateY(40px);
    grid-column: 1 / 4;
    max-width: 700px;
    justify-self: center;
}

.pegboard-module.visible {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

.pegboard-module:nth-child(odd) {
    margin-top: 10px;
}
.pegboard-module:nth-child(even) {
    margin-top: 20px;
}

.pin {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #e8a84c, #8a7040);
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
}

.peg-title {
    text-transform: uppercase;
}

/* === SECTION 4: BUBBLE BATH === */
.section-bubble-bath {
    position: relative;
    min-height: 100vh;
    background: #2a4a4e;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#bath-bubbles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.bath-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.35), rgba(137,180,200,0.25) 40%, rgba(212,200,232,0.15) 70%, rgba(232,168,76,0.08) 90%, transparent);
    border: 1px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bathFloat var(--duration) cubic-bezier(0.37, 0, 0.63, 1) infinite;
    animation-delay: var(--delay);
}

.bath-bubble .bubble-word {
    font-family: 'Bebas Neue', sans-serif;
    color: #f2ead8;
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: 0.1em;
    opacity: 0.9;
    text-align: center;
}

@keyframes bathFloat {
    0%, 100% {
        transform: translateY(0) translateX(0);
    }
    25% {
        transform: translateY(-20px) translateX(10px);
    }
    50% {
        transform: translateY(-5px) translateX(-8px);
    }
    75% {
        transform: translateY(-15px) translateX(5px);
    }
}

.closing-statement {
    position: relative;
    z-index: 2;
    max-width: 600px;
    text-align: center;
    padding: 2rem;
}

.closing-statement p {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 1.5vw, 1.3rem);
    line-height: 1.8;
    color: #f2ead8;
}

/* === COMPASS NAV === */
.compass-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid #b8963e;
    background: linear-gradient(135deg, #2e2420, #4a3728);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: transform 0.3s ease;
}

.compass-btn:hover {
    transform: scale(1.1);
}

.compass-menu {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.compass-menu.open {
    pointer-events: auto;
    opacity: 1;
}

.compass-link {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #b8963e;
    color: #2e2420;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.compass-menu.open .compass-link:nth-child(1) {
    transform: translate(-50%, -50%) rotate(0deg) translateY(-80px);
}
.compass-menu.open .compass-link:nth-child(2) {
    transform: translate(-50%, -50%) rotate(90deg) translateY(-80px);
}
.compass-menu.open .compass-link:nth-child(3) {
    transform: translate(-50%, -50%) rotate(180deg) translateY(-80px);
}
.compass-menu.open .compass-link:nth-child(4) {
    transform: translate(-50%, -50%) rotate(270deg) translateY(-80px);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .instruments {
        flex-direction: column;
        gap: 2rem;
    }

    .instrument-dial {
        width: 220px;
        height: 220px;
        order: 1;
    }

    .dial-face {
        width: 180px;
        height: 180px;
    }

    .dial-needle {
        height: 65px;
    }

    .instrument-meter, .instrument-teletype {
        width: 180px;
        height: 220px;
    }

    .section-drawers {
        grid-template-columns: 1fr;
    }

    .drawer-half, .drawer-full {
        grid-column: span 1;
    }

    .section-pegboard {
        grid-template-columns: 1fr;
    }

    .pegboard-module.module-left,
    .pegboard-module.module-right,
    .pegboard-module.module-center {
        grid-column: 1;
    }
}

/* Color references: #89b4c8 #d4c8e8 */

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .bubble, .bath-bubble {
        animation: none !important;
    }
    .dial-needle {
        animation: none !important;
    }
    .meter-bar {
        animation: none !important;
    }
    .teletype-text {
        animation: none !important;
    }
    .drawer {
        opacity: 1;
        transform: none;
    }
    .pegboard-module {
        opacity: 1;
        transform: none !important;
    }
}
