/* ============================================================
   ANUSHOS — boot cutscene + fake desktop shown before the game starts.
   Sits above everything else in index.html (highest z-index) until the
   "Start Game" icon is double-clicked, at which point #os-layer hides
   and the game's own #blocker/Start screen underneath takes over.
   ============================================================ */

#os-layer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  font-family: -apple-system, "Segoe UI", "Trebuchet MS", sans-serif;
  color: #3a2233;
}
#os-layer.hidden { display: none; }

/* ---------------- Boot screen ---------------- */

#os-boot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #3a1740 0%, #180a20 75%);
  transition: opacity 0.8s ease;
}
#os-boot.hidden { display: none; }
#os-boot.fading { opacity: 0; }

/* Just the "AnushOS" name and the loading bar — nothing else shown. */
#os-boot-logo {
  font-size: 2.4em;
  font-weight: bold;
  color: #ffd9ec;
  text-shadow: 0 0 24px rgba(255,140,190,0.7);
  letter-spacing: 2px;
  margin-bottom: 30px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#os-boot-logo.show { opacity: 1; }

#os-boot-bar-track {
  width: 280px;
  height: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.15);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s ease;
}
#os-boot-bar-track.show { opacity: 1; }

#os-boot-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff8ac4, #ff5f9e);
  border-radius: 6px;
  transition: width 0.2s ease;
}

/* ---------------- Login screen ---------------- */

#os-login {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #3a1740 0%, #180a20 75%);
  opacity: 0;
  transition: opacity 0.7s ease;
}
#os-login.hidden { display: none; }
#os-login.show { opacity: 1; }

#os-login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 44px;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,180,220,0.25);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 40px rgba(255,120,180,0.2);
}
#os-login-card.shake { animation: os-login-shake 0.4s ease; }

@keyframes os-login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

#os-login-avatar {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8ac4, #a86bce);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1em;
  box-shadow: 0 0 24px rgba(255,140,190,0.6);
  margin-bottom: 14px;
  overflow: hidden;
}

.os-login-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#os-login-greeting {
  color: #ffd9ec;
  font-size: 1.1em;
  margin-bottom: 20px;
  text-align: center;
}

#os-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 240px;
}

#os-login-form input {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,180,220,0.35);
  background: rgba(255,255,255,0.9);
  /* 16px minimum keeps iOS Safari from auto-zooming the page on focus */
  font-size: 16px;
  color: #3a2233;
  outline: none;
}
#os-login-form input:focus {
  border-color: #ff5f9e;
  box-shadow: 0 0 0 2px rgba(255,95,158,0.3);
}

#os-login-submit {
  margin-top: 4px;
  padding: 10px 14px;
  border-radius: 22px;
  border: none;
  background: linear-gradient(135deg, #ff8ac4, #ff5f9e);
  color: #2a0018;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s ease;
}
#os-login-submit:hover { transform: scale(1.03); }

#os-login-error {
  margin-top: 14px;
  min-height: 1.2em;
  font-size: 0.85em;
  color: #ff9e9e;
  text-align: center;
  max-width: 260px;
}

/* ---------------- Desktop ---------------- */

#os-desktop {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #ffd6e8 0%, #e3c9f5 45%, #c7d8f7 100%);
  opacity: 0;
  transition: opacity 0.7s ease;
}
#os-desktop.hidden { display: none; }
#os-desktop.show { opacity: 1; }

/* Soft decorative blobs so the wallpaper doesn't feel flat */
#os-desktop::before,
#os-desktop::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.35;
}
#os-desktop::before {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, #fff2fa 0%, transparent 70%);
  top: -80px;
  right: -60px;
}
#os-desktop::after {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, #fff2fa 0%, transparent 70%);
  bottom: -60px;
  left: -40px;
}

/* Top menu bar */
#os-menubar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.85em;
  font-weight: 600;
  color: #6b3a5a;
  z-index: 5;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 1px 4px rgba(0,0,0,0.08);
}
#os-menubar-title { letter-spacing: 0.5px; }
#os-menubar-clock { font-weight: 400; opacity: 0.85; }

/* Desktop icons grid, top-right like a real desktop */
#os-icons {
  position: absolute;
  top: 46px;
  right: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.os-icon {
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  padding: 6px 4px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.os-icon:hover { background: rgba(255,255,255,0.25); }
.os-icon.selected { background: rgba(255,120,180,0.3); }

.os-icon-glyph {
  font-size: 2.1em;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.2));
}

.os-icon-img {
  width: 1.9em;
  height: 1.9em;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);
}

.os-icon-label {
  font-size: 0.78em;
  text-align: center;
  color: #4a2b40;
  background: rgba(255,255,255,0.55);
  padding: 1px 6px;
  border-radius: 6px;
  line-height: 1.3em;
  word-break: break-word;
}

/* Dock */
#os-dock {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(16px);
  border-radius: 22px;
  box-shadow: 0 6px 24px rgba(120,40,90,0.25), 0 0 0 1px rgba(255,255,255,0.5) inset;
  z-index: 5;
}

.os-dock-icon {
  font-size: 2em;
  cursor: pointer;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.2));
}

.os-dock-icon-img {
  width: 1em;
  height: 1em;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.os-dock-icon:hover { transform: translateY(-8px) scale(1.15); }
.os-dock-icon.is-start-game {
  filter: drop-shadow(0 0 10px rgba(255,95,158,0.8));
}

/* Windows */
#os-windows {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.os-window {
  position: absolute;
  min-width: 300px;
  max-width: 90vw;
  min-height: 180px;
  max-height: 80vh;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(18px);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(80,20,60,0.35), 0 0 0 1px rgba(255,255,255,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
}

.os-window-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,235,245,0.7));
  cursor: grab;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  user-select: none;
  touch-action: none; /* dragging handles the gesture, not page scroll */
}
.os-window-titlebar:active { cursor: grabbing; }

.os-window-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.os-window-dot.close { background: #ff5f57; cursor: pointer; }
.os-window-dot.min { background: #ffbd2e; }
.os-window-dot.zoom { background: #28c840; }

.os-window-title {
  flex: 1;
  text-align: center;
  font-size: 0.85em;
  font-weight: 600;
  color: #6b3a5a;
  margin-right: 44px; /* balances the 3 dots so title reads centered */
}

.os-window-content {
  flex: 1;
  overflow: auto;
  padding: 18px 20px;
  font-size: 0.95em;
  line-height: 1.6em;
  color: #4a2b40;
  white-space: pre-wrap;
}

/* Notes/letters read like a scrollable page — narrower and taller instead
   of stretching wide and shrink-wrapping to the text. */
.os-window-note {
  width: 440px;
  height: 68vh;
}
.os-window-note .os-window-content {
  overflow-y: auto;
  overflow-x: hidden;
  word-break: break-word;
}

.os-window-content img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.os-window-folder-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  white-space: normal;
}

/* ============================================================
   MOBILE / NARROW-SCREEN RESPONSIVE PASS
   ============================================================ */
@media (max-width: 640px) {
  #os-boot-logo { font-size: 1.9em; }
  #os-boot-bar-track { width: 220px; }

  #os-login-card {
    padding: 30px 26px;
    max-width: 88vw;
  }
  #os-login-form { width: 78vw; max-width: 260px; }

  #os-menubar { height: 34px; font-size: 0.8em; padding: 0 10px; }

  #os-icons {
    top: 40px;
    right: 10px;
    gap: 12px;
  }
  .os-icon { width: 68px; }
  .os-icon-glyph { font-size: 1.7em; }
  .os-icon-label { font-size: 0.7em; }

  #os-dock {
    bottom: 10px;
    gap: 10px;
    padding: 8px 14px;
    max-width: 92vw;
  }
  .os-dock-icon { font-size: 1.6em; }

  .os-window {
    min-width: 82vw;
    max-width: 94vw;
  }
  .os-window-title { font-size: 0.8em; }
  .os-window-content { padding: 14px 16px; font-size: 0.9em; }

  .os-window-note {
    width: 88vw;
    height: 72vh;
  }
}
