/*
 * MR. MOON - Game Styles
 * © 2026 PsychoPookah Studios. All rights reserved.
 * Made by: NastyCat, Clover, and Sable
 *
 * 640x480 game world, CSS-scaled to fill window
 * Text/UI at native resolution
 */

:root {
  --game-w: 640px;
  --game-h: 480px;
  --text-scale: 1;
  --ui-font: 'Segoe UI', system-ui, sans-serif;
  --game-font: 'Courier New', monospace;
}

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

body {
  background: #000;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ui-font);
}

/* ---- GAME CONTAINER (scaled) ---- */
#game-container {
  width: var(--game-w);
  height: var(--game-h);
  position: relative;
  transform-origin: center center;
  /* bilinear scaling for soft edutainment look */
  image-rendering: auto;
}

/* use this class for crispy pixel mode instead */
#game-container.pixel-mode {
  image-rendering: pixelated;
}

/* ---- MAIN MENU ---- */
#main-menu {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0a0812;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: opacity 1s ease;
}

#main-menu.hidden {
  opacity: 0;
  pointer-events: none;
}

#main-menu.gone {
  display: none;
}

.menu-title {
  font-family: var(--game-font);
  font-size: 48px;
  color: #e8e0d0;
  letter-spacing: 0.15em;
  margin-bottom: 4px;
  text-shadow: 0 0 30px rgba(200, 190, 170, 0.15);
}

.menu-subtitle {
  font-family: var(--game-font);
  font-size: 14px;
  color: #444;
  letter-spacing: 0.2em;
  margin-bottom: 48px;
}

.menu-copyright {
  font-family: var(--game-font);
  font-size: 10px;
  color: #333;
  letter-spacing: 0.08em;
  margin-bottom: 36px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.menu-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #999;
  font-family: var(--game-font);
  font-size: 18px;
  padding: 10px 40px;
  min-width: 200px;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.menu-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

.menu-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---- CURTAIN ---- */
#curtain {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 400;
  pointer-events: none;
  overflow: hidden;
}

#curtain.curtain-hidden {
  display: none;
}

.curtain-left, .curtain-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #8b1a1a;
  /* fabric texture with CSS */
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(0,0,0,0.08) 0px,
      rgba(0,0,0,0.08) 2px,
      transparent 2px,
      transparent 12px
    ),
    repeating-linear-gradient(
      180deg,
      rgba(0,0,0,0.03) 0px,
      rgba(0,0,0,0.03) 1px,
      transparent 1px,
      transparent 8px
    );
  box-shadow: inset 0 0 60px rgba(0,0,0,0.5);
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.curtain-left {
  left: 0;
  transform: translateX(0);
  border-right: 3px solid #5a0f0f;
}

.curtain-right {
  right: 0;
  transform: translateX(0);
  border-left: 3px solid #5a0f0f;
}

/* drape effect at top */
.curtain-left::before, .curtain-right::before {
  content: '';
  position: absolute;
  top: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(
    180deg,
    #6b1515 0%,
    #8b1a1a 60%,
    transparent 100%
  );
  z-index: 1;
}

.curtain-left::before { left: 0; }
.curtain-right::before { right: 0; }

/* fold highlights */
.curtain-left::after, .curtain-right::after {
  content: '';
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 20px,
    rgba(255,255,255,0.03) 20px,
    rgba(255,255,255,0.03) 22px,
    transparent 22px,
    transparent 40px
  );
}

/* open state */
#curtain.curtain-open .curtain-left {
  transform: translateX(-105%);
}
#curtain.curtain-open .curtain-right {
  transform: translateX(105%);
}

/* closed state (default when visible) */
#curtain.curtain-closed .curtain-left {
  transform: translateX(0);
}
#curtain.curtain-closed .curtain-right {
  transform: translateX(0);
}

.curtain-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--game-font);
  font-size: 32px;
  color: #e8d5b0;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.6s ease;
  text-align: center;
  line-height: 1.6;
}

.curtain-text.visible {
  opacity: 1;
}

/* ---- GAME WORLD (640x480) ---- */
#game-world {
  width: var(--game-w);
  height: var(--game-h);
  position: relative;
  overflow: hidden;
  background: #000;
  transition: opacity 0.4s ease;
}

#game-world.fade-out { opacity: 0; }
#game-world.fade-in { opacity: 1; }
#game-world.glitch-out {
  animation: glitch-anim 0.3s steps(2) forwards;
}

@keyframes glitch-anim {
  0% { transform: translate(0); filter: none; }
  25% { transform: translate(-3px, 2px); filter: hue-rotate(90deg); }
  50% { transform: translate(2px, -1px); filter: saturate(3); }
  75% { transform: translate(-1px, 3px); filter: hue-rotate(-90deg); }
  100% { transform: translate(0); filter: none; }
}

/* ---- SCENE BACKGROUND ---- */
#scene-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ---- SPRITE LAYER ---- */
#sprite-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.sprite {
  position: absolute;
  pointer-events: none;
}

.sprite img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- HOTSPOT LAYER ---- */
#hotspot-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.hotspot {
  position: absolute;
  cursor: pointer;
  /* invisible by default */
  background: transparent;
}

/* debug mode: show hotspot boundaries */
.debug .hotspot,
.hotspot.debug-visible {
  background: rgba(255, 0, 255, 0.25);
  border: 1px solid rgba(255, 0, 255, 0.6);
}

/* ---- HOVER LABEL ---- */
#hover-label {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 4px 14px;
  font-size: calc(14px * var(--text-scale));
  font-family: var(--game-font);
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
}

/* ---- DIALOGUE ---- */
#dialogue-layer {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  pointer-events: auto;
}

.dialogue-box {
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 16px 20px;
  width: 100%;
  max-width: 580px;
  display: flex;
  gap: 14px;
  cursor: pointer;
  user-select: none;
}

.dialogue-portrait {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  object-fit: cover;
}

.dialogue-text-area {
  flex: 1;
  min-width: 0;
}

.dialogue-speaker {
  font-size: calc(13px * var(--text-scale));
  color: #aaa;
  font-family: var(--game-font);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dialogue-text {
  font-size: calc(16px * var(--text-scale));
  color: #fff;
  font-family: var(--game-font);
  line-height: 1.5;
  min-height: 1.5em;
}

.dialogue-hint {
  position: absolute;
  bottom: 4px;
  right: 12px;
  font-size: calc(10px * var(--text-scale));
  color: #555;
  font-family: var(--game-font);
}

/* ---- CHOICES ---- */
.choice-box {
  flex-direction: column;
  cursor: default;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.choice-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: var(--game-font);
  font-size: calc(15px * var(--text-scale));
  padding: 8px 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.choice-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.choice-btn:focus {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* ---- INVENTORY ---- */
#inventory {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  z-index: 80;
}

.inv-slot {
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.inv-slot:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.inv-slot.selected {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.inv-slot img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.inv-slot.text-item {
  font-size: 9px;
  color: #aaa;
  font-family: var(--game-font);
  text-align: center;
  word-break: break-all;
  padding: 2px;
}

/* item-use cursor */
#game-container.using-item .hotspot {
  cursor: crosshair;
}

/* ---- MENU BAR ---- */
#menu-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 80;
}

#menu-bar button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #999;
  font-family: var(--game-font);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#menu-bar button:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

/* ---- META OVERLAY ---- */
#meta-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 200;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s;
}

/* ---- FAKE POPUP (Win95 style) ---- */
.fake-popup {
  background: #c0c0c0;
  border: 3px solid;
  border-color: #fff #808080 #808080 #fff;
  box-shadow: 2px 2px 0 #000;
  min-width: 300px;
  max-width: 420px;
  font-family: 'MS Sans Serif', Arial, sans-serif;
  font-size: calc(14px * var(--text-scale));
  color: #000;
  user-select: none;
}

.fake-popup-title {
  background: linear-gradient(90deg, #000080, #1084d0);
  color: #fff;
  font-weight: bold;
  padding: 4px 8px;
  font-size: calc(13px * var(--text-scale));
}

.fake-popup-body {
  padding: 20px 16px;
  line-height: 1.5;
}

.fake-popup-buttons {
  padding: 8px 16px 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.fake-popup-buttons button {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  padding: 4px 24px;
  font-family: 'MS Sans Serif', Arial, sans-serif;
  font-size: calc(13px * var(--text-scale));
  cursor: pointer;
  min-width: 80px;
}

.fake-popup-buttons button:active {
  border-color: #808080 #fff #fff #808080;
}

/* ---- META GLITCH ---- */
#game-container.meta-glitch {
  animation: meta-glitch-anim 0.1s steps(2) infinite;
}

@keyframes meta-glitch-anim {
  0% { filter: none; transform-origin: center; }
  33% { filter: hue-rotate(90deg) saturate(2); transform: translate(-2px, 1px) scale(1); }
  66% { filter: hue-rotate(-60deg) brightness(1.5); transform: translate(1px, -2px) scale(1); }
  100% { filter: none; transform: none; }
}

/* ---- NOTIFICATION ---- */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  font-family: var(--game-font);
  font-size: 14px;
  padding: 8px 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
}

.notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- SETTINGS PANEL ---- */
#settings-panel {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

#settings-panel.settings-hidden {
  display: none;
}

.settings-box {
  background: #1a1a2e;
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 20px 28px;
  width: 420px;
  max-height: 90%;
  overflow-y: auto;
  font-family: var(--game-font);
  color: #ccc;
}

.settings-title {
  font-size: calc(18px * var(--text-scale));
  color: #fff;
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.settings-section {
  margin-bottom: 16px;
}

.settings-section h3 {
  font-size: calc(13px * var(--text-scale));
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.settings-hint {
  font-size: calc(11px * var(--text-scale));
  color: #555;
  margin-bottom: 8px;
}

.keybind-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: calc(13px * var(--text-scale));
}

.keybind-row .kb-label {
  color: #aaa;
}

.keybind-row .kb-key {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  cursor: pointer;
  color: #fff;
  font-family: var(--game-font);
  font-size: calc(12px * var(--text-scale));
  min-width: 60px;
  text-align: center;
  transition: border-color 0.15s;
}

.keybind-row .kb-key:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.keybind-row .kb-key.listening {
  border-color: #fff;
  color: #ff0;
  animation: pulse-border 0.8s ease infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: #fff; }
  50% { border-color: #ff0; }
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: calc(13px * var(--text-scale));
}

.settings-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #aaa;
  font-family: var(--game-font);
  font-size: calc(12px * var(--text-scale));
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.settings-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.settings-close {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  text-align: center;
  font-size: calc(14px * var(--text-scale));
}

#text-scale-display {
  display: inline-block;
  min-width: 40px;
  text-align: center;
}

/* ---- ACCESSIBILITY ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
