/* ============================================================
   Disky Fun — OS Shell
   데스크탑 + 작업표시줄 + 시작 메뉴 + 부팅 화면
   진짜 윈도98 픽셀 퍼펙트
   ============================================================ */


/* ─── OS 루트 ────────────────────────────────────────── */

.os-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: var(--z-desktop);
  
  /* 부팅 완료 전 = 숨김 */
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.os-root.is-ready {
  opacity: 1;
}


/* ─── 데스크탑 ──────────────────────────────────────── */

.desktop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--size-taskbar);
  overflow: hidden;
  background-color: var(--bg-color, var(--c-desktop));
  background-image: var(--bg-image, none);
  background-size: var(--bg-size, auto);
  background-position: var(--bg-position, center);
  background-repeat: var(--bg-repeat, no-repeat);
}


/* ─── 바탕화면 아이콘 그리드 ─────────────────────────── */

.desktop-icons {
  position: absolute;
  inset: 0;
  padding: var(--pad-5);
  pointer-events: none;  /* 자식 아이콘에서 허용 */
}

.desktop-icon {
  position: absolute;
  width: var(--size-desktop-cell);
  height: var(--size-desktop-cell);
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: auto;
  cursor: default;
  z-index: var(--z-icons);
  will-change: transform;
}

.desktop-icon.is-dragging {
  opacity: 0.75;
  z-index: var(--z-mouse-effects);
  pointer-events: none;
}

.desktop-icon__img {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
  margin-bottom: 2px;
  flex-shrink: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.desktop-icon__img svg {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
  display: block;
}

.desktop-icon__label {
  color: var(--c-white);
  font-size: var(--fs-sm);
  font-family: var(--font-system);
  line-height: 12px;
  padding: 1px 3px;
  max-width: 70px;
  word-break: break-all;
  pointer-events: none;
  
  /* Win98 텍스트 그림자 (8방향 1px) */
  text-shadow:
    1px 0 0 var(--c-black), -1px 0 0 var(--c-black),
    0 1px 0 var(--c-black), 0 -1px 0 var(--c-black),
    1px 1px 0 var(--c-black), -1px -1px 0 var(--c-black),
    1px -1px 0 var(--c-black), -1px 1px 0 var(--c-black);
  
  /* 2줄 자르기 */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: 26px;
}

/* 선택 상태 - 라벨 진청 + 점선 */
.desktop-icon.is-selected .desktop-icon__label {
  background: var(--c-accent);
  color: var(--c-accent-text);
  text-shadow: none;
  outline: 1px dotted var(--c-white);
}

/* 선택 시 아이콘 자체도 약간 어둡게 */
.desktop-icon.is-selected .desktop-icon__img {
  filter: brightness(0.75) sepia(1) hue-rotate(200deg) saturate(2.5);
}

/* 더블클릭 깜빡임 (Win98 메타포) */
.desktop-icon.is-flashing .desktop-icon__img {
  animation: icon-flash 180ms steps(2, end) 1;
}

@keyframes icon-flash {
  0% { filter: brightness(0.5); }
  50% { filter: brightness(1); }
  100% { filter: brightness(0.5); }
}

/* 드래그 선택 사각형 */
.drag-select {
  position: fixed;
  border: 1px dotted var(--c-black);
  background: rgba(0, 0, 128, 0.08);
  pointer-events: none;
  z-index: var(--z-drag-select);
}


/* ─── 작업표시줄 ────────────────────────────────────── */

.taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--size-taskbar);
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  box-shadow: inset 0 1px 0 var(--c-bg-light);
  display: flex;
  align-items: center;
  padding: var(--pad-2);
  gap: var(--pad-3);
  z-index: var(--z-taskbar);
}


/* ─── 시작 버튼 ─────────────────────────────────────── */

.start-button {
  height: 22px;
  padding: 0 6px 0 4px;
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  border-left: 2px solid var(--c-white);
  border-right: 2px solid var(--c-black);
  border-bottom: 2px solid var(--c-black);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-light),
    inset -1px -1px 0 var(--c-bg-dark);
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-bold);
  font-weight: bold;
  font-size: var(--fs-sm);
  cursor: default;
  flex-shrink: 0;
}

.start-button.is-active {
  border-top: 2px solid var(--c-black);
  border-left: 2px solid var(--c-black);
  border-right: 2px solid var(--c-white);
  border-bottom: 2px solid var(--c-white);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-dark),
    inset -1px -1px 0 var(--c-bg-light);
  padding: 1px 5px 0 5px;
}

.start-button__flag {
  width: 16px;
  height: 14px;
  flex-shrink: 0;
}

.start-button__label {
  font-family: var(--font-bold);
}

/* 단축키 밑줄 */
.start-button__label u {
  text-decoration: underline;
}


/* ─── 작업표시줄 - 창 목록 ──────────────────────────── */

.taskbar__windows {
  flex: 1;
  display: flex;
  gap: 2px;
  overflow: hidden;
  align-items: center;
  height: 22px;
}

.taskbar-window {
  height: 22px;
  padding: 0 6px;
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  border-left: 2px solid var(--c-white);
  border-right: 2px solid var(--c-black);
  border-bottom: 2px solid var(--c-black);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-light),
    inset -1px -1px 0 var(--c-bg-dark);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  cursor: default;
  max-width: 140px;
  min-width: 80px;
  flex-shrink: 0;
}

.taskbar-window__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.taskbar-window__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.taskbar-window.is-active {
  border-top: 2px solid var(--c-black);
  border-left: 2px solid var(--c-black);
  border-right: 2px solid var(--c-white);
  border-bottom: 2px solid var(--c-white);
  box-shadow: inset 1px 1px 0 var(--c-bg-dark);
  /* 점선 패턴 - 활성 표시 (Win98 정확) */
  background-image: repeating-linear-gradient(
    45deg, 
    var(--c-accent) 0 1px, 
    transparent 1px 3px
  );
  color: var(--c-content-text);
}


/* ─── 시스템 트레이 ──────────────────────────────────── */

.tray {
  height: 22px;
  padding: 0 var(--pad-5);
  background: var(--c-bg);
  border-top: 1px solid var(--c-bg-dark);
  border-left: 1px solid var(--c-bg-dark);
  border-right: 1px solid var(--c-white);
  border-bottom: 1px solid var(--c-white);
  display: flex;
  align-items: center;
  gap: var(--pad-4);
  font-size: var(--fs-sm);
  flex-shrink: 0;
}

.tray__icon {
  width: 16px;
  height: 16px;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tray__icon svg {
  width: 16px;
  height: 16px;
}

/* 시계 */
.tray__clock {
  font-family: var(--font-digital7);
  font-size: var(--fs-md);
  color: var(--c-accent);
  min-width: 48px;
  text-align: center;
  cursor: default;
  letter-spacing: 1px;
}

/* HDD LED */
.tray__led {
  width: 6px;
  height: 6px;
  background: #200;
  border: 1px solid var(--c-bg-darker);
  border-radius: 1px;
  flex-shrink: 0;
}

.tray__led.is-on {
  background: #f44;
  box-shadow: 0 0 4px #f44;
}


/* ─── 시작 메뉴 ─────────────────────────────────────── */

.start-menu {
  position: fixed;
  bottom: var(--size-taskbar);
  left: var(--pad-2);
  min-width: 200px;
  max-width: 280px;
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  border-left: 2px solid var(--c-white);
  border-right: 2px solid var(--c-black);
  border-bottom: 2px solid var(--c-black);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-light),
    inset -1px -1px 0 var(--c-bg-dark),
    1px 1px 0 var(--c-black);
  display: none;
  z-index: var(--z-startmenu);
  font-family: var(--font-system);
  font-size: var(--fs-sm);
}

.start-menu.is-open {
  display: flex;
}

/* 좌측 사이드바 - "DISKY FUN" 세로 글자 */
.start-menu__sidebar {
  width: var(--size-startmenu-sidebar);
  background: linear-gradient(
    to bottom,
    var(--c-title-active-from),
    var(--c-title-active-to)
  );
  color: var(--c-title-active-text);
  display: flex;
  align-items: end;
  justify-content: center;
  padding: var(--pad-5) 0;
  font-family: var(--font-bold);
  font-weight: bold;
  font-size: var(--fs-md);
  writing-mode: vertical-rl;
  transform: rotate(180deg);  /* 글자 정방향 */
  letter-spacing: 2px;
  flex-shrink: 0;
  user-select: none;
}

.start-menu__sidebar-brand {
  white-space: nowrap;
}

.start-menu__sidebar-brand strong {
  color: var(--c-white);
}

/* 우측 메뉴 영역 */
.start-menu__items {
  flex: 1;
  padding: var(--pad-2);
  min-width: 0;
}

/* 메뉴 항목 */
.start-menu__item {
  display: flex;
  align-items: center;
  gap: var(--pad-5);
  padding: var(--pad-3) var(--pad-5);
  cursor: default;
  font-size: var(--fs-sm);
  color: var(--c-content-text);
  white-space: nowrap;
  position: relative;
}

.start-menu__item:hover:not(.is-disabled) {
  background: var(--c-accent);
  color: var(--c-accent-text);
}

.start-menu__item.is-disabled {
  color: var(--c-disabled);
  text-shadow: 1px 1px 0 var(--c-disabled-shadow);
  pointer-events: none;
}

.start-menu__item-icon {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-menu__item-icon svg {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
}

.start-menu__item-label {
  flex: 1;
}

.start-menu__item-label u {
  text-decoration: underline;
}

/* 하위 메뉴 화살표 */
.start-menu__item-arrow {
  font-size: var(--fs-xs);
  margin-left: var(--pad-5);
  opacity: 0.7;
}

.start-menu__item:hover:not(.is-disabled) .start-menu__item-arrow {
  opacity: 1;
}

/* 구분선 */
.start-menu__divider {
  height: 0;
  margin: var(--pad-2) var(--pad-2);
  border-top: 1px solid var(--c-bg-dark);
  border-bottom: 1px solid var(--c-white);
}


/* ─── 트레이 팝업 (시계, 볼륨) ──────────────────────── */

.tray-popup {
  position: fixed;
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  border-left: 2px solid var(--c-white);
  border-right: 2px solid var(--c-black);
  border-bottom: 2px solid var(--c-black);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-light),
    inset -1px -1px 0 var(--c-bg-dark),
    1px 1px 0 var(--c-black);
  padding: var(--pad-4);
  font-family: var(--font-system);
  font-size: var(--fs-sm);
  display: none;
  z-index: var(--z-dropdown);
}

.tray-popup.is-open {
  display: block;
}


/* ─── 부팅 화면 ─────────────────────────────────────── */

.boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  color: var(--c-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-boot);
  font-family: var(--font-system);
  transition: opacity var(--duration-slow) var(--ease-out);
}

.boot-screen.is-done {
  opacity: 0;
  pointer-events: none;
}

.boot-screen__logo {
  font-family: var(--font-bold);
  font-size: var(--fs-boot);
  letter-spacing: 6px;
  color: var(--c-title-active-to);
  text-shadow: 
    2px 2px 0 var(--c-title-active-from),
    0 0 16px rgba(16, 132, 208, 0.5);
  margin-bottom: var(--pad-6);
  animation: boot-pulse 2s ease-in-out infinite;
}

@keyframes boot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.boot-screen__tagline {
  font-family: var(--font-digital14);
  font-size: var(--fs-md);
  color: #666;
  margin-bottom: var(--pad-7);
  letter-spacing: 2px;
}

.boot-screen__progress {
  width: 240px;
  height: 16px;
  border-top: 1px solid var(--c-bg-darker);
  border-left: 1px solid var(--c-bg-darker);
  border-right: 1px solid #222;
  border-bottom: 1px solid #222;
  background: #0a0a0a;
  overflow: hidden;
  position: relative;
  margin-bottom: var(--pad-7);
}

.boot-screen__progress-fill {
  height: 100%;
  background: linear-gradient(
    90deg, 
    transparent, 
    var(--c-title-active-to) 50%, 
    transparent
  );
  background-size: 60px 100%;
  width: 100%;
  animation: boot-loading 1.5s linear infinite;
}

@keyframes boot-loading {
  from { background-position: -60px 0; }
  to { background-position: 100% 0; }
}

.boot-screen__start {
  padding: var(--pad-4) var(--pad-7);
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  border-left: 2px solid var(--c-white);
  border-right: 2px solid var(--c-black);
  border-bottom: 2px solid var(--c-black);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-light),
    inset -1px -1px 0 var(--c-bg-dark);
  font-family: var(--font-bold);
  font-size: var(--fs-md);
  color: var(--c-content-text);
  cursor: default;
  letter-spacing: 1px;
  position: relative;
}

/* 펄스는 별도 ::after 의사요소로 - 버튼 자체는 stable */
.boot-screen__start::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1px dashed rgba(16, 132, 208, 0.5);
  animation: btn-pulse 1.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes btn-pulse {
  0%, 100% { 
    opacity: 0.3; 
    transform: scale(1); 
  }
  50% { 
    opacity: 1; 
    transform: scale(1.05); 
  }
}

.boot-screen__start:active {
  border-top: 2px solid var(--c-black);
  border-left: 2px solid var(--c-black);
  border-right: 2px solid var(--c-white);
  border-bottom: 2px solid var(--c-white);
}

.boot-screen__hint {
  margin-top: var(--pad-6);
  font-size: var(--fs-sm);
  color: #555;
  font-family: var(--font-digital14);
}

.boot-screen__messages {
  position: absolute;
  bottom: var(--pad-7);
  left: var(--pad-7);
  font-family: var(--font-system);
  font-size: var(--fs-sm);
  color: #888;
  text-align: left;
  white-space: pre-line;
  line-height: 1.5;
  max-width: 400px;
}

.boot-screen__cursor::after {
  content: '_';
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}


/* ─── 토스트 알림 ───────────────────────────────────── */

.toast-stack {
  position: fixed;
  bottom: calc(var(--size-taskbar) + var(--pad-6));
  right: var(--pad-6);
  display: flex;
  flex-direction: column;
  gap: var(--pad-4);
  z-index: var(--z-toast);
  pointer-events: none;
  max-width: 320px;
}

.toast {
  min-width: 240px;
  padding: var(--pad-5);
  background: var(--c-bg);
  border-top: 2px solid var(--c-white);
  border-left: 2px solid var(--c-white);
  border-right: 2px solid var(--c-black);
  border-bottom: 2px solid var(--c-black);
  box-shadow: 
    inset 1px 1px 0 var(--c-bg-light),
    inset -1px -1px 0 var(--c-bg-dark),
    2px 2px 0 var(--c-black);
  display: flex;
  gap: var(--pad-4);
  align-items: flex-start;
  pointer-events: auto;
  animation: toast-in var(--duration-base) var(--ease-out);
  font-family: var(--font-system);
  font-size: var(--fs-sm);
}

.toast.is-leaving {
  animation: toast-out var(--duration-base) var(--ease-out) forwards;
}

@keyframes toast-in {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}

@keyframes toast-out {
  to { transform: translateX(120%); opacity: 0; }
}

.toast__icon {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-family: var(--font-bold);
  margin-bottom: 2px;
  color: var(--c-content-text);
}

.toast__message {
  color: var(--c-content-text);
  line-height: 1.4;
}
