@font-face {
  font-family: 'Presso Matcha';
  src: url('/public/fonts/Presso Matcha.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Add Chinese font face declaration */
@font-face {
  font-family: 'Free-HK-Kai';
  src: url('/public/fonts/Free-HK-Kai.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
  unicode-range: U+4E00-9FFF; /* Chinese characters range */
}

/* Reset some default browser styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Presso Matcha', 'Tahoma', sans-serif;
  background: #008080;
  color: #000;
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.desktop {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: calc(100vh - 40px);
  display: block;
  overflow: hidden;
  cursor: url('public/icon/claw.png'), auto; /* Custom cursor for desktop */
}

.desktop.touched {
  cursor: url('public/icon/claw_touched.png'), auto;
}

.icon {
  position: relative;
  z-index: 2;
  pointer-events: all;
  width: 80px;
  height: 80px;
  margin: 0;
  text-align: center;
  z-index: 50;
  user-select: none;
  /* Update cursor with both relative and absolute paths for better compatibility */
  cursor: url('public/icon/claw.png') 15 15, 
         url('/public/icon/claw.png') 15 15,
         pointer;
  display: inline-block;
  /* Make icons easier to tap on mobile */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  transition: background 0.2s;
  pointer-events: auto;
}

/* Ensure cursor persists during interactions */
.icon:hover,
.icon:active,
.icon:focus {
  cursor: url('public/icon/claw.png') 15 15, 
         url('/public/icon/claw.png') 15 15,
         pointer;
}

.icon img {
  width: 100%;
  height: auto;
}

.icon span {
  display: block;
  font-size: 0.8rem;
  color: #fff;
  margin-top: 5px;
  word-break: break-word;
  white-space: normal;
}

.window {
  position: absolute;
  top: clamp(64px, 12vh, 160px);
  min-width: 260px;
  min-height: 160px;
  max-width: calc(100vw - 64px);
  max-height: calc(100vh - 96px);
  background: #fff;
  border: 2px solid #004d4d;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  transition: box-shadow 0.2s;
  resize: none;
}

.window,
.window:focus,
.window *:focus,
.window-header:focus {
  outline: none !important;
  box-shadow: none !important;
}

.window.active-window {
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  border-color: #004d4d;
  /* Optionally highlight header */
}

.window-header {
  background: #004d4d;
  color: #fff;
  padding: 0.5rem 1rem;
  cursor: move;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.window-header .title {
  font-size: 1rem;
  font-weight: bold;
}

.window-header .controls {
  display: flex;
  gap: 0.5rem;
}

.window-header .close-btn {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #ff5f57;
  cursor: pointer;
  margin-left: 8px;
}

.window-header .close-btn:hover {
  opacity: 0.8;
}

.window-content {
  flex: 1 1 auto;
  padding: 1rem;
  overflow-y: auto;
  color: #000;
  background: #fff;
}

/* Updated window content styles */
.window-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.window-content * {
  color: inherit !important;
}

.window iframe {
  color: #000 !important;
}

/* Specific style for work window */
[data-window-id="workWindow"] .window-content,
[data-window-id="workWindow"] .window-content * {
    color: #fff !important;
}

#workWindow .window-content,
#workWindow .window-inner-content,
#workWindow .work-content {
    color: #fff !important;
}

#workWindow .window-content *,
#workWindow .window-inner-content *,
#workWindow .work-content * {
    color: inherit !important;
}

.taskbar {
  position: relative;
  z-index: 3;
  height: 40px;
  background: #004d4d;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  color: #fff;
  font-size: 0.9rem;
  opacity: 1;
  transition: opacity 0.5s ease;
  position: relative;
  cursor: url('public/icon/claw.png'), auto; /* Custom cursor for desktop */
}

/* Reset cursor inheritance */
.taskbar * {
    cursor: inherit;
}

/* Apply touched cursor only to clickable elements */
.start-button:hover,
.taskbar-icon:hover,
.taskbar-windows .taskbar-item:hover {
    cursor: url('public/icon/claw_touched.png'), auto !important;
}

.taskbar-center,
.taskbar-right,
.taskbar-snail,
.time,
.date {
    cursor: url('public/icon/claw.png'), auto;
}

.taskbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: inherit;
}

.taskbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: inherit;
}

.taskbar-icon {
  display: flex;
  align-items: center;
  margin-left: 0.5rem;
  margin-right: 0.2rem;
  height: 28px;
  width: 28px;
  border-radius: 4px;
  background: transparent;
  transition: background 0.2s;
}

.taskbar-icon img {
  width: 22px;
  height: 22px;
  display: block;
  margin: auto;
}

/* Apply hover state cursor to taskbar elements */
.taskbar-item:hover,
.taskbar-item:hover *,
.taskbar-icon:hover,
.taskbar-icon:hover *,
.start-button:hover {
  cursor: url('/public/icon/claw_touched.png') 15 15, pointer !important;
}

.taskbar-icon:hover {
  background: #0073e6;
}

.taskbar .time {
  margin-left: 1rem;
  margin-right: 0.5rem;
}

.taskbar .date {
  margin-left: 0.5rem;
  font-size: 0.9rem;
  color: #fff;
  opacity: 0.85;
}

.taskbar-windows {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin-left: 1rem;
  cursor: pointer;
}

.taskbar-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 4px;
  background: transparent;
  border: none;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.taskbar-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  opacity: 1;
}

.taskbar-item img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Intro Screen Styles */
#intro-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  overflow: hidden;
}

.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #382727;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 2em 2em 1.5em 2em;
  margin-bottom: 1.5em;
  min-width: 260px;
  max-width: 90vw;
}

.user-profile {
  margin: 1rem 0;
}

.user-avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin-bottom: 1.5rem;
  border: 4px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.user-profile h3 {
  font-size: 1.4rem;
  color: #fff;
  margin-bottom: 1rem;
}

.login-button {
  background: #0073e6;
  color: #fff;
  border: none;
  padding: 1rem 3rem;
  border-radius: 25px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  /* Apply the default cursor to the login button */
  cursor: url('/public/icon/claw.png') 15 15, pointer !important; /* Default claw cursor */
}

.login-button:hover {
  background: #005bb7;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  /* Change cursor to claw_touched.png when hovering over the login button */
  cursor: url('/public/icon/claw_touched.png') 15 15, pointer !important; /* Hover state cursor */
}

.login-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hidden {
  display: none !important;
}

.start-menu {
  position: absolute;
  bottom: 40px;
  left: 10px;
  background: #004d4d;
  color: #fff;
  border: 1px solid #0073e6;
  border-radius: 5px;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  z-index: 1000;
}

.start-menu.hidden {
  display: none;
}

.start-menu .icon {
  width: 60px;
  height: 60px;
  text-align: center;
  cursor: url('public/icon/claw.png') 15 15, 
         url('/public/icon/claw.png') 15 15,
         pointer;
}

.start-menu .icon img {
  width: 100%;
  height: auto;
}

.start-menu .icon span {
  display: block;
  font-size: 0.7rem;
  color: #fff;
  margin-top: 5px;
}

.bg-matrix-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  perspective: 1200px;
  z-index: 0;
  overflow: hidden;
  pointer-events: auto;  /* Changed from none to auto */
}

.bg-matrix {
  width: 100vw;
  height: 100vh;
  position: relative;
  transform-style: preserve-3d;
}

.bg-tile {
  position: absolute;
  background-image: url('public/user/bg.jpg');
  background-size: 100vw 100vh;
  will-change: transform, background-image, opacity;
  pointer-events: none;
  transition: transform 0.15s cubic-bezier(.4,2,.6,1), opacity 0.7s cubic-bezier(.4,2,.6,1);
  opacity: 1;
}

#snail-img {
  transition: filter 0.2s;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
  pointer-events: none;
}

#lsys-canvas {
  display: block;
  margin: 0 auto;
  width: 100vw;
  max-width: 400px;
  height: 140px;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
}

/* Responsive: make canvas fill under login-container */
@media (max-width: 600px) {
  .login-container {
    max-width: 98vw;
    padding: 1.2em 0.5em 1em 0.5em;
  }
  #lsys-canvas {
    max-width: 98vw;
    height: 100px;
  }
}

@media (max-width: 768px) {
  .window {
    width: 90%;
    height: 70%;
  }

  .taskbar {
    font-size: 0.8rem;
  }

  .icon {
    width: 60px;
    height: 60px;
  }

  .icon span {
    font-size: 0.7rem;
  }
}

/* Default cursor for the body and icons */
body, 
.icon, 
.icon *, 
.start-menu .icon, 
.start-menu .icon *, 
.icon.bouncing, 
.icon.bouncing * {
  cursor: url('/public/icon/claw.png') 15 15, pointer !important; /* Default claw cursor */
}

/* Change cursor to claw_touched.png when hovering over icons */
.icon:hover, 
.start-menu .icon:hover, 
.icon.bouncing:hover, 
.icon:hover *, 
.start-menu .icon:hover *, 
.icon.bouncing:hover * {
  cursor: url('/public/icon/claw_touched.png') 15 15, pointer !important; /* Hover state cursor */
}

/* Apply the default cursor to the background matrix and tiles */
.bg-matrix, 
.bg-tile {
  cursor: url('/public/icon/claw.png') 15 15, pointer !important; /* Default claw cursor */
}

/* Change cursor to claw_touched.png when hovering over background tiles */
.bg-tile:hover {
  cursor: url('/public/icon/claw_touched.png') 15 15, pointer !important; /* Hover state cursor */
}

.icon.bouncing {
  z-index: 50;
  position: absolute; /* Ensure position is absolute */
  pointer-events: auto;
  transition: none;
}

.icon.bouncing span {
  color: #000;
}

.login-snail {
    width: 120px;
    height: auto;
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
}

.desktop-snail {
    width: 48px;
    height: auto;
    cursor: pointer;
}

/* Override cursor for icons within the desktop to default */
.desktop .icon {
  cursor: default;
}

.bg-matrix-container, .bg-matrix, .bg-tile {
  pointer-events: none;
}

.taskbar-snail {
    height: 24px;
    width: auto;
}

.snail-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
}

.snail-info img,
.snail-avatar {
    width: 80px;
    height: auto;
    margin-bottom: 0.5em;
    display: block;
}

.start-button {
  background: none;
  border: none;
  color: white;
  padding: 0 15px;
  cursor: pointer;
  height: 100%;
  font-size: 1em;
  font-family: 'Presso Matcha', 'Tahoma', sans-serif;
}

.start-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Global font settings */
body,
.window-header .title,
.work-title,
.work-desc,
.taskbar,
.taskbar span,
.time,
.date,
.user-profile h3,
.login-button,
.start-menu,
.icon span,
.window-content,
.start-button {
  font-family: 'Presso Matcha', 'Free-HK-Kai', 'Tahoma', sans-serif;
}

.window .window-resize-handle {
  position: absolute;
  z-index: 4;
  background: transparent;
  pointer-events: auto;
}
.window .handle-top,
.window .handle-bottom {
  left: 0;
  width: 100%;
  height: 8px;
  cursor: ns-resize;
}
.window .handle-top { top: -4px; }
.window .handle-bottom { bottom: -4px; }
.window .handle-left,
.window .handle-right {
  top: 0;
  height: 100%;
  width: 8px;
  cursor: ew-resize;
}
.window .handle-left { left: -4px; }
.window .handle-right { right: -4px; }
.window .handle-top-left,
.window .handle-top-right,
.window .handle-bottom-left,
.window .handle-bottom-right {
  width: 14px;
  height: 14px;
}
.window .handle-top-left { top: -7px; left: -7px; cursor: nwse-resize; }
.window .handle-top-right { top: -7px; right: -7px; cursor: nesw-resize; }
.window .handle-bottom-left { bottom: -7px; left: -7px; cursor: nesw-resize; }
.window .handle-bottom-right { bottom: -7px; right: -7px; cursor: nwse-resize; }

body:not(.custom-cursor-active),
body:not(.custom-cursor-active) * {
  cursor: auto !important;
}

body:not(.custom-cursor-active) a,
body:not(.custom-cursor-active) button,
body:not(.custom-cursor-active) .icon,
body:not(.custom-cursor-active) .taskbar-item,
body:not(.custom-cursor-active) .taskbar-icon,
body:not(.custom-cursor-active) .start-button,
body:not(.custom-cursor-active) .login-button,
body:not(.custom-cursor-active) .taskbar-snail {
  cursor: pointer !important;
}
