:root {
	/* Fallback defaults (Windows 95 look) */
	--font: "MS Sans Serif", sans-serif;
	--bg-body: #008080;
	--bg-window: #c0c0c0;
	--bg-taskbar: silver;
	--bg-title: navy;
	--fg-title: white;
	--bg-button: silver;
	--fg-button: black;
	--bg-startmenu: #c0c0c0;
	--fg-startmenu: black;
	--bg-hover: navy;
	--fg-hover: white;
	--border-light: #fff;
	--border-dark: #808080;
	--shadow-dark: #404040;
}

/* === Core Structure === */
body {
	margin: 0;
	font-family: var(--font);
	color: var(--fg-startmenu, black);
	background: var(--bg-body, #008080);
	overflow: hidden;
	transition: background 0.4s ease, color 0.4s ease;
}

body, .window, #taskbar, #start-menu {
    transition: background 0.4s ease, box-shadow 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

button { cursor: pointer; }
iframe { border: none; }

button:active {
    background: linear-gradient(to bottom, #ccc, #aaa);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.4);
}


/* === Boot Screen === */
#boot-screen {
	position: fixed;
	inset: 0;
	background: #000;
	color: white;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	z-index: 1000;
}

#boot-logo {
	font-size: 48px;
	font-weight: bold;
	color: #00a;
	text-shadow: 2px 2px #fff;
}

#boot-progress {
	width: 220px;
	height: 14px;
	border: 2px inset #aaa;
	margin-top: 20px;
	background: #222;
}
#boot-bar {
	height: 100%;
	width: 0%;
	background: #0f0;
	transition: width 1.2s linear;
}
#boot-text {
	margin-top: 20px;
	font-size: 14px;
	color: #ccc;
}

/* === Desktop === */
#desktop {
	position: relative;
	width: 100vw;
	height: calc(100vh - 30px);
	background: var(--bg-body) center/cover no-repeat;
	display: none;
	opacity: 0;
	transition: opacity 1.2s ease, background 0.4s ease;
}
#desktop.visible { opacity: 1; }

.icon {
	width: 70px;
	text-align: center;
	position: absolute;
	color: var(--fg-hover, white);
	cursor: pointer;
	user-select: none;
	text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}
.icon img {
	width: 48px;
	height: 48px;
	filter: 
	    drop-shadow( 1px 0px 0px white) 
	    drop-shadow(-1px 0px 0px white) 
	    drop-shadow( 0px 1px 0px white) 
	    drop-shadow( 0px -1px 0px white) 
	    drop-shadow(0px 6px 6px #00000070);
}

/* === Taskbar Classic === */
#taskbar {
    height: 30px;
    background: var(--bg-taskbar);
    border-top: 2px solid var(--border-light);
    border-bottom: 2px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    position: absolute;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
}
#start-button {
    background: var(--bg-button);
    border: 2px outset var(--border-light);
    padding: 3px 10px;
    font-weight: bold;
    cursor:pointer;
}
#start-button:hover {
    background: linear-gradient(to bottom, #fff, #ccc);
    box-shadow: inset 1px 1px 0 #fff;
}

body[data-theme="xp"] #start-menu {
    width: 280px;
    display: flex;
    flex-direction: row;
    background: linear-gradient(to bottom, #f3f3f3, #e3e1d9);
    border-radius: 6px 6px 0 0;
    overflow: hidden;
    border: 1px solid #31509b;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
}

/* Left pane: program list */
body[data-theme="xp"] #start-menu .menu-left {
    width: 60%;
    background: #ffffff;
    border-right: 1px solid #d0d0c8;
    padding: 6px;
    display: flex;
    flex-direction: column;
}

/* Right pane: system links */
body[data-theme="xp"] #start-menu .menu-right {
    width: 40%;
    background: linear-gradient(to bottom, #d8e4f8, #c0d8ff);
    color: #003366;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* XP Taskbar */
body[data-theme="xp"] #taskbar {
    background: linear-gradient(to top, #0c3fa9, #4a8cf7);
    border-top: 1px solid #fff;
    box-shadow: inset 0 2px 3px rgba(255,255,255,0.3);
    height: 34px;
}

body[data-theme="xp"] #start-button {
    background: linear-gradient(to bottom, #5bd75b, #3aaa3a);
    border: 1px solid #1b5d1b;
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    padding: 4px 12px;
}

body[data-theme="xp"] #start-button:hover {
    background: linear-gradient(to bottom, #70e470, #4ac94a);
    box-shadow: inset 0 0 3px rgba(255,255,255,0.4);
}

body[data-theme="xp"] #taskbar-apps .taskbar-icon {
    border-radius: 4px;
    background: linear-gradient(to bottom, #ffffff44, #ffffff11);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
}

#taskbar-apps {
	flex: 1;
	display: flex;
	gap: 4px;
	padding: 0 8px;
	overflow-x: auto;
}
.taskbar-icon {
	background: var(--bg-button);
	border: 2px outset var(--border-light);
	padding: 2px 6px;
	cursor: pointer;
	font-size: 12px;
	color: var(--fg-button);
}
.taskbar-icon.active {
	border: 2px inset var(--border-light);
	background: var(--bg-hover);
	color: var(--fg-hover);
}

#taskbar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255,255,255,0.3);
}

#clock {
	font-size: 12px;
	width: 60px;
	text-align: right;
	color: var(--fg-button);
}

/* === Desktop Menu === */
#desktop-menu {
	position: absolute;
	background: var(--bg-window);
	border: 2px outset var(--border-light);
	display: none;
	flex-direction: column;
	width: 160px;
	z-index: 999;
	box-shadow: 2px 2px var(--shadow-dark);
}
#desktop-menu .menu-item {
	padding: 4px 8px;
	cursor: pointer;
	font-size: 13px;
	color: var(--fg-startmenu);
}
#desktop-menu .menu-item:hover {
	background: var(--bg-hover);
	color: var(--fg-hover);
}
#desktop-menu hr {
	border: none;
	border-top: 1px solid var(--border-dark);
	margin: 3px 0;
}

/* === Windows === */
.window {
	position: absolute;
	width: 400px;
	background: var(--bg-window);
	border: 2px solid var(--border-dark);
	box-shadow: 2px 2px var(--shadow-dark);
	transition: all 0.3s ease;
	z-index: 1;
	resize: both;            
	overflow: hidden;        
	min-width: 200px;         
	min-height: 100px;
}
.window.active {
	box-shadow: 2px 2px #000, -1px -1px var(--border-light);
	z-index: 10;
}
body[data-theme="2000"] .window.active {
	box-shadow: 2px 2px #000, 0 0 var(--border-light);
}

.title-bar {
	background: var(--bg-title);
	color: var(--fg-title);
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 4px;
	cursor: move;
	transition: background 0.4s ease;
}
.window-controls button {
	background: var(--bg-button);
	color: var(--fg-button);
	border: 1px solid var(--border-dark);
	width: 20px;
	height: 20px;
	font-size: 12px;
	cursor: pointer;
}
.window-body {
	padding: 8px;
	background: var(--bg-window);
	height: calc(100% - 24px);
	overflow: auto;
	color: var(--fg-startmenu);
}

/* === Enhanced Window Depth === */
.window {
    border: 2px solid var(--border-dark);
    border-top-color: var(--border-light);
    border-left-color: var(--border-light);
    background: var(--bg-window);
    box-shadow: inset 1px 1px 0 var(--border-light),
              inset -1px -1px 0 var(--border-dark),
              3px 3px 6px var(--shadow-dark);
    border-radius: 3px;
}

/* === Title Bar Gradient & Active State === */
.title-bar {
    background: var(--bg-title);
    background-image: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
    border-bottom: 1px solid var(--border-dark);
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    letter-spacing: 0.2px;
}

.window.active .title-bar {
    filter: brightness(1.1);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}

/* === Window Controls === */
.window-controls button {
    border: 1px solid var(--border-dark);
    background: linear-gradient(to bottom, var(--bg-button), #ccc);
    border-radius: 2px;
    box-shadow: inset 1px 1px 0 var(--border-light);
    transition: all 0.15s ease;
}
.window-controls button:hover {
    background: linear-gradient(to bottom, #fff, #ddd);
    box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #aaa;
}
.window-controls button:active {
    box-shadow: inset -1px -1px 1px #000;
    background: #ccc;
}

/* === CLASSIC Start Menu === */
#start-menu {
    width: 200px;
    background: var(--bg-startmenu);
    border: 2px outset var(--border-light);
    box-shadow: 2px 2px var(--shadow-dark);
    display: none;
    flex-direction: column;
    padding: 4px;
    position: absolute;   
    bottom: 32px;        
    left: 6px;
    z-index: 1000;  
}

#start-menu .menu-item {
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    border-radius: 2px;
    color: var(--fg-subMenu);
}
#start-menu .menu-item:hover {
	background: var(--bg-hover);
	color: var(--fg-hover);
}

/* === Start-Menu Submenu === */
.submenu {
	position: relative;
}
.submenu-panel {
	display: none;
	position: absolute;
	top: 0;
	left: 100%;
	width: 160px;
	background: var(--bg-startmenu);
	border: 2px outset var(--border-light);
	box-shadow: 2px 2px var(--shadow-dark);
	flex-direction: column;
}
.submenu:hover > .submenu-panel {
	display: flex;
}
.submenu-panel .menu-item {
	padding: 4px 8px;
	cursor: pointer;
	font-size: 13px;
	color: var(--fg-startmenu);
}
.submenu-panel .menu-item:hover {
	background: var(--bg-hover);
	color: var(--fg-hover);
}

.start-menu .menu-item,
.start-menu .submenu > .menu-item {
  position: relative;
}

.start-menu .has-submenu > span::after {
    content: "▶";
    position: absolute;
    right: 6px;
}

.start-menu .submenu {
  display: none;
  position: absolute;
  top: -3px;
  left: 100%;
  width: 220px;
  background: var(--bg-startmenu);
  border: 2px outset var(--border-light);
  box-shadow: 2px 2px var(--shadow-dark);
  padding: 2px;
  flex-direction: column;
  z-index: 1000;
  
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  pointer-events: none;
}

.start-menu .has-submenu:hover > .submenu,
.start-menu .submenu:hover {
  pointer-events: auto; 
  display: flex;
  opacity: 1;
  transform: translateX(0);
}

.start-menu hr {
    border: none;
    border-top: 1px solid var(--border-dark);
    margin: 4px 0;
}

/* === Control Panel === */
#cp-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 16px;
	padding: 8px;
	text-align: center;
	background: var(--bg-window);
	color: var(--fg-startmenu);
}
.cp-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	cursor: pointer;
}
.cp-item img {
	width: 48px;
	height: 48px;
	margin-bottom: 4px;
}
.cp-item span {
	font-size: 13px;
	color: var(--fg-startmenu);
}
.cp-item:hover {
	background: var(--bg-button);
	border: 1px inset var(--border-light);
}

/* === Animations & States === */
.minimized {
	opacity: 0;
	transform: scale(0.95) translateY(10px);
	transition: all 0.2s ease;
	pointer-events: none;
}

/* === Boot / Shutdown Animations === */
#boot-screen,
#shutdown {
	position: fixed;
	inset: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	background: #000;
	color: #fff;
	font-size: 22px;
	z-index: 2000;
	opacity: 1;
	transition: opacity 1.2s ease;
}
#shutdown { display: none; }
#boot-screen { flex-direction: column; }

#boot-screen.fade-out,
#shutdown.fade-out {
	opacity: 0;
	pointer-events: none;
}

/* === Boot Logo Glow === */
@keyframes bootGlow {
	0% { text-shadow: none; opacity: 0.2; }
	50% { text-shadow: 0 0 12px #0ff; opacity: 1; }
	100% { text-shadow: none; opacity: 0.9; }
}
#boot-logo { animation: bootGlow 2s ease-in-out infinite alternate; }
