:root {
    /* Color Tokens */
    --base-grey: #C0C0C0;
    --light-grey: #F0F0F0;
    --dark-grey: #808080;
    --white: #FFFFFF;
    --title-blue: #000080;
    --black: #000000;
    --neon-green: #00FF00;
    --desktop-teal: #008080;
    --sunken-grey: #DCDCDC;
    
    /* Font */
    --font-pixel: 'Pixelify Sans', 'MS Sans Serif', 'Courier New', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--desktop-teal); /* fallback */
    font-family: var(--font-pixel);
    font-size: 14px;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

/* Background Noise and Scanlines Layer */
#desktop-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-color: var(--desktop-teal);
    /* Simple geometric dot grid matching the reference image */
    background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='2' height='2' fill='rgba(0,0,0,0.15)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    transition: filter 0.3s cubic-bezier(0.4, 0, 1, 1);
}

#desktop {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#desktop.learn-mode-active ~ #desktop-bg,
body.learn-mode-active #desktop-bg {
    filter: brightness(0.85) desaturate(0.5);
}

/* Era Label */
.era-label {
    position: absolute;
    top: 32px;
    left: 32px; /* ~32px padding for alignment */
    color: var(--light-grey);
    font-size: 1.5rem;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 var(--black);
}

/* Mode Toggle */
.mode-toggle {
    position: absolute;
    top: 32px;
    right: 32px;
    display: flex;
    z-index: 100;
}

.toggle-btn {
    background-color: var(--base-grey);
    border-top: 3px solid var(--white);
    border-left: 3px solid var(--white);
    border-right: 3px solid var(--black);
    border-bottom: 3px solid var(--black);
    padding: 8px 18px;
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: inset -2px -2px 0 var(--dark-grey), inset 2px 2px 0 var(--light-grey);
    outline: none;
}

.toggle-btn.active {
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    box-shadow: inset 2px 2px 0 var(--dark-grey);
    background-color: var(--sunken-grey);
    padding-top: 10px;
    padding-left: 20px;
    padding-bottom: 6px;
    padding-right: 16px;
}

.toggle-btn:active:not(.active) {
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    box-shadow: inset 2px 2px 0 var(--dark-grey);
    padding-top: 10px;
    padding-left: 20px;
    padding-bottom: 6px;
    padding-right: 16px;
}

/* Layout Wrapper - Perfectly Center Aligned horizontally, 45% vertically */
#layout-wrapper {
    position: absolute;
    top: 45%; 
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 1100px;
    display: flex;
    justify-content: center;
    /* Removed gap and fixed flex bias so player naturally sits at true center */
}

/* Base Window Style */
.window {
    background-color: var(--base-grey);
    border-top: 3px solid var(--white);
    border-left: 3px solid var(--white);
    border-right: 3px solid var(--black);
    border-bottom: 3px solid var(--black);
    box-shadow: inset -1px -1px 0 var(--dark-grey), inset 1px 1px 0 var(--light-grey);
    display: flex;
    flex-direction: column;
    padding: 4px;
}

/* Title Bar */
.title-bar {
    background-color: var(--title-blue);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 5px;
    height: 32px;
    user-select: none;
}

.title-icon {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    background-color: var(--white);
    border-right: 2px solid var(--dark-grey);
    border-bottom: 2px solid var(--dark-grey);
    position: relative;
    background-image: linear-gradient(45deg, var(--black) 25%, transparent 25%, transparent 75%, var(--black) 75%, var(--black)), 
                      linear-gradient(45deg, var(--black) 25%, transparent 25%, transparent 75%, var(--black) 75%, var(--black));
    background-size: 4px 4px;
    background-position: 0 0, 2px 2px;
}

.icon-info {
    background-color: var(--white);
    background-image: none;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--title-blue);
    font-weight: bold;
    font-size: 14px;
}
.icon-info::after { content: 'i'; }

.title-left {
    display: flex;
    align-items: center;
}

.title-text {
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.title-right {
    display: flex;
    gap: 2px;
}

.window-btn {
    width: 24px;
    height: 24px;
    background-color: var(--base-grey);
    border-top: 2px solid var(--white);
    border-left: 2px solid var(--white);
    border-right: 2px solid var(--black);
    border-bottom: 2px solid var(--black);
    font-family: var(--font-pixel);
    font-weight: bold;
    font-size: 16px;
    line-height: 16px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--black);
}

.window-btn:active {
    border-top: 2px solid var(--black);
    border-left: 2px solid var(--black);
    border-right: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    padding-top: 2px;
    padding-left: 2px;
}

.window-content {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* --- MUSIC PLAYER --- */
#player-window {
    width: 650px; /* Reduced by ~18% from 800px */
    transition: transform 0.25s linear, opacity 0.25s linear;
    transform-origin: center right;
    margin: 0 auto; /* Keep perfectly centered when alone */
    position: relative;
    z-index: 5;
}

/* Display Panel */
.display-panel {
    background-color: var(--black);
    border-top: 3px solid var(--dark-grey);
    border-left: 3px solid var(--dark-grey);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    color: var(--neon-green);
    padding: 12px 14px 18px 14px; /* Increased bottom padding for spacing */
    display: flex;
    justify-content: space-between;
    height: auto; /* Let content dictate height, removing hardcoded constraint */
    min-height: 120px;
    margin-bottom: 14px;
}

.display-main {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 75%;
}

.time-display {
    font-size: 4rem;
    line-height: 1;
    text-shadow: 0 0 6px rgba(0,255,0,0.5);
    font-variant-numeric: tabular-nums;
}

.track-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.metadata {
    font-size: 1rem;
    opacity: 0.8;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.song-title {
    font-size: 1.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
    padding-bottom: 4px; /* extra breathing room */
}

/* Equalizer */
.equalizer {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 100%;
    width: 22%;
    padding-bottom: 4px;
}

.bar {
    width: 10px;
    background-color: var(--dark-grey); /* off state */
    border-top: 2px solid var(--white); /* Subtle reflection */
}

.playing .bar {
    background-color: var(--neon-green);
}

/* Equalizer Animations */
@keyframes eq {
    0% { height: 10%; }
    20% { height: 40%; }
    40% { height: 90%; }
    60% { height: 60%; }
    80% { height: 30%; }
    100% { height: 10%; }
}
.playing .bar-1 { animation: eq 0.6s steps(4) infinite; }
.playing .bar-2 { animation: eq 0.4s steps(4) infinite; animation-delay: 0.1s;}
.playing .bar-3 { animation: eq 0.5s steps(4) infinite; animation-delay: 0.2s;}
.playing .bar-4 { animation: eq 0.7s steps(4) infinite; animation-delay: 0.3s;}
.playing .bar-5 { animation: eq 0.4s steps(4) infinite; animation-delay: 0.4s;}
.playing .bar-6 { animation: eq 0.8s steps(4) infinite; animation-delay: 0.5s;}

.bar-1 { height: 20%; }
.bar-2 { height: 40%; }
.bar-3 { height: 60%; }
.bar-4 { height: 30%; }
.bar-5 { height: 70%; }
.bar-6 { height: 50%; }

/* Progress Bar */
.progress-container {
    margin-bottom: 14px;
}

.progress-track {
    background-color: var(--sunken-grey);
    border-top: 3px solid var(--dark-grey);
    border-left: 3px solid var(--dark-grey);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    height: 20px;
    width: 100%;
}

.progress-fill {
    background-color: var(--dark-grey);
    height: 100%;
    width: 25%; /* dynamic based on JS */
    transition: width 1s linear;
}

/* Controls Row */
.controls-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-btn {
    width: 60px;
    height: 60px;
    background-color: var(--base-grey);
    border-top: 3px solid var(--white);
    border-left: 3px solid var(--white);
    border-right: 3px solid var(--black);
    border-bottom: 3px solid var(--black);
    box-shadow: inset -2px -2px 0 var(--dark-grey), inset 2px 2px 0 var(--light-grey);
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--black);
}

.control-btn:active {
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    box-shadow: inset 2px 2px 0 var(--dark-grey);
    padding-top: 4px;
    padding-left: 4px;
}

.control-btn.active.pressed {
    /* Persistent sunken state for Play actively */
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    box-shadow: inset 2px 2px 0 var(--dark-grey);
    padding-top: 4px;
    padding-left: 4px;
    background-color: var(--sunken-grey);
}

/* Status Bar */
.status-bar {
    background-color: var(--base-grey);
    border-top: 2px solid var(--dark-grey);
    border-left: 2px solid var(--dark-grey);
    border-right: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    padding: 5px 8px;
    margin-top: 4px;
    margin-left: 6px;
    margin-right: 20px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--black);
    letter-spacing: 0.5px;
}

/* --- LEARN PANEL --- */
#learn-panel {
    position: absolute;
    left: 0;
    width: 580px;
    height: 100%;
    min-height: 500px;
    transform: translateX(-50px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s linear;
    z-index: 10;
}

#layout-wrapper.learn-mode #learn-panel {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

#layout-wrapper.learn-mode #player-window {
    transform: scale(0.8) translateX(360px);
}

.learn-content {
    background-color: var(--base-grey);
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    color: var(--black);
    display: flex;
    flex-direction: column;
}

.learn-header {
    border-bottom: 2px solid rgba(0,0,0,0.2);
    margin-bottom: 20px;
    padding-bottom: 6px;
}

.learn-header h3 {
    font-size: 1.2rem;
    color: var(--title-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.principles-list {
    list-style: none;
    margin-bottom: 36px;
}

.principles-list li {
    display: flex;
    align-items: flex-start;
    margin-bottom: 24px;
    font-size: 1.15rem;
    line-height: 1.5;
}

.bullet {
    color: var(--title-blue);
    font-size: 1.4rem;
    margin-right: 12px;
    line-height: 0.9;
}

.context-text {
    font-size: 1.15rem;
    line-height: 1.5;
    margin-bottom: 36px;
}

.highlight-box {
    background-color: var(--white);
    padding: 20px;
    border-top: 2px solid var(--dark-grey);
    border-left: 2px solid var(--dark-grey);
    border-right: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    margin-bottom: 36px;
}

.highlight-label {
    font-size: 1rem;
    color: var(--dark-grey);
    font-weight: bold;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.highlight-text {
    font-size: 1.3rem;
    color: var(--black);
    font-weight: bold;
}

.learn-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
}

.next-btn {
    background-color: var(--base-grey);
    border-top: 3px solid var(--white);
    border-left: 3px solid var(--white);
    border-right: 3px solid var(--black);
    border-bottom: 3px solid var(--black);
    padding: 10px 20px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: var(--font-pixel);
    cursor: pointer;
    box-shadow: inset -1px -1px 0 var(--dark-grey), inset 1px 1px 0 var(--light-grey);
}

.next-btn:active {
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    box-shadow: inset 1px 1px 0 var(--dark-grey);
    padding-top: 12px;
    padding-left: 22px;
    padding-bottom: 8px;
    padding-right: 18px;
}

/* External Navigation */
.navigation-panel {
    position: absolute;
    bottom: 32px;  /* Margin locked across corners */
    right: 32px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.nav-buttons {
    display: flex;
    gap: 16px; /* Increased spacing */
}

.nav-btn {
    width: 48px;
    height: 48px;
    background-color: var(--base-grey);
    border-top: 3px solid var(--white);
    border-left: 3px solid var(--white);
    border-right: 3px solid var(--black);
    border-bottom: 3px solid var(--black);
    box-shadow: inset -1px -1px 0 var(--dark-grey), inset 1px 1px 0 var(--light-grey);
    font-size: 1.4rem;
    cursor: pointer;
}

.nav-btn:active {
    border-top: 3px solid var(--black);
    border-left: 3px solid var(--black);
    border-right: 3px solid var(--white);
    border-bottom: 3px solid var(--white);
    box-shadow: inset 1px 1px 0 var(--dark-grey);
    padding-top: 3px;
    padding-left: 3px;
}

.nav-text {
    color: var(--light-grey);
    font-size: 1.1rem;
    opacity: 0.9;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 var(--black);
}
