/* Visual Novel custom styles for Night Museum: The Unfinished Promise */

/* Import Outfit font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Noto+Serif+TC:wght@400;600;700&display=swap');

:root {
  --bg-dark: #070913;
  --bg-medium: #111424;
  --accent-gold: #c5a880;
  --accent-bronze: #8c6d48;
  --accent-blue: #3d6afe;
  --text-light: #e6e8f4;
  --text-dim: #a0a5c0;
  --glass-bg: rgba(13, 17, 33, 0.7);
  --glass-border: rgba(197, 168, 128, 0.25);
  --glow-shadow: 0 0 15px rgba(197, 168, 128, 0.4);
  --font-serif: 'Noto Serif TC', serif;
  --font-title: 'Cinzel', 'Noto Serif TC', serif;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-serif);
  color: var(--text-light);
}

/* Base Stage Layout */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background-color: #000;
}

.stage-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 16/9;
  max-width: 177.78vh; /* Limit width for ultra-wide screens */
  max-height: 56.25vw; /* Limit height for tall screens */
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
  overflow: hidden;
}

/* Background layer */
#background-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.8s ease-in-out;
  z-index: 1;
}

/* Dark mask for atmospheric feel */
#background-layer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
}

/* Characters layer */
#character-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 2;
  pointer-events: none;
  padding-bottom: 80px; /* Leave space for text box */
}

.character-sprite {
  height: 80%;
  max-height: 700px;
  object-fit: contain;
  transition: all 0.5s ease-in-out;
  position: absolute;
  bottom: 0;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.7));
}

.character-sprite.center {
  left: 50%;
  transform: translateX(-50%);
}

.character-sprite.left {
  left: 20%;
  transform: translateX(-50%);
}

.character-sprite.right {
  left: 80%;
  transform: translateX(-50%);
}

/* Character entry transitions */
.sprite-enter-active {
  animation: spriteFadeIn 0.5s forwards;
}

@keyframes spriteFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

/* Idle breathing animation for characters */
.character-sprite.active-speaker {
  animation: characterIdle 4s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 10px rgba(197, 168, 128, 0.4)) drop-shadow(0 10px 20px rgba(0,0,0,0.7));
}

@keyframes characterIdle {
  0% {
    transform: translateX(-50%) translateY(0);
  }
  100% {
    transform: translateX(-50%) translateY(-6px);
  }
}

/* CG overlay */
#cg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-color: transparent;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
}

#cg-layer.active {
  opacity: 1;
  pointer-events: auto;
}

/* HUD System */
#hud-overlay {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: auto;
}

.hud-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  gap: 20px;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.stat-label {
  color: var(--accent-gold);
  font-weight: bold;
}

.stat-value-container {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-bronze), var(--accent-gold));
  transition: width 0.5s ease-out;
  box-shadow: 0 0 5px var(--accent-gold);
}

/* Inventory HUD */
.inventory-list {
  display: flex;
  gap: 10px;
}

.inventory-item {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--accent-gold);
  background: rgba(197, 168, 128, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
}

.inventory-item:hover {
  background: rgba(197, 168, 128, 0.3);
  box-shadow: var(--glow-shadow);
}

.inventory-item svg {
  width: 18px;
  height: 18px;
  fill: var(--accent-gold);
}

.inventory-item::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  border: 1px solid var(--accent-gold);
}

.inventory-item:hover::after {
  opacity: 1;
}

/* Audio & System Controls */
.system-controls {
  display: flex;
  gap: 10px;
}

.control-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--accent-gold);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.3s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.control-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
  box-shadow: var(--glow-shadow);
}

/* Dialogue Box Layer */
#dialogue-layer {
  position: absolute;
  bottom: 25px;
  left: 20px;
  right: 20px;
  z-index: 5;
  pointer-events: auto;
}

.dialogue-box {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 24px 32px;
  min-height: 150px;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  cursor: pointer;
}

.dialogue-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(197, 168, 128, 0.05), transparent);
  pointer-events: none;
}

.speaker-tag {
  color: var(--accent-gold);
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 12px;
  text-shadow: 0 0 10px rgba(197, 168, 128, 0.4);
  letter-spacing: 2px;
  display: inline-block;
  min-height: 24px;
}

.dialogue-text {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-light);
  letter-spacing: 1px;
  min-height: 60px;
}

.dialogue-arrow {
  position: absolute;
  bottom: 15px;
  right: 20px;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--accent-gold);
  border-bottom: 2px solid var(--accent-gold);
  transform: rotate(45deg);
  animation: bounceArrow 1.2s infinite alternate;
  display: none;
}

@keyframes bounceArrow {
  0% {
    transform: translateY(0) rotate(45deg);
  }
  100% {
    transform: translateY(6px) rotate(45deg);
  }
}

.dialogue-box.waiting-input .dialogue-arrow {
  display: block;
}

/* Choices Panel */
#choices-container {
  position: absolute;
  bottom: 200px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 6;
  pointer-events: auto;
}

.choice-btn {
  background: rgba(13, 17, 33, 0.85);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 16px 24px;
  color: var(--text-light);
  font-family: var(--font-serif);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.choice-btn:hover {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--bg-dark);
  font-weight: 600;
  box-shadow: var(--glow-shadow);
  transform: translateY(-2px);
}

/* Screen Overlay system (Transitions) */
#transition-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9;
  pointer-events: none;
  background-color: transparent;
  transition: background-color 0.5s ease;
}

#transition-layer.fadeBlack {
  background-color: #000;
  pointer-events: auto;
}

#transition-layer.fade {
  background-color: rgba(0,0,0,0.6);
  pointer-events: auto;
}

#transition-layer.flash {
  animation: flashAnim 0.6s forwards;
  pointer-events: auto;
}

@keyframes flashAnim {
  0% { background-color: rgba(255, 255, 255, 1); }
  100% { background-color: rgba(255, 255, 255, 0); }
}

/* Start / Title Screen */
#title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #161b36 0%, #060814 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
  pointer-events: auto;
  transition: opacity 1s ease-in-out;
}

#title-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.title-header {
  text-align: center;
  margin-bottom: 50px;
}

.title-eng {
  font-family: var(--font-title);
  color: var(--accent-gold);
  font-size: 18px;
  letter-spacing: 6px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.title-main {
  font-family: var(--font-title);
  color: #fff;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 8px;
  text-shadow: 0 0 20px rgba(197, 168, 128, 0.6);
}

.title-sub {
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 4px;
  margin-top: 15px;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 250px;
}

.title-btn {
  background: rgba(197, 168, 128, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--accent-gold);
  padding: 15px 30px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.title-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
  box-shadow: var(--glow-shadow);
  transform: scale(1.03);
}

/* History Log overlay */
#history-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 8, 20, 0.95);
  backdrop-filter: blur(15px);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  display: flex;
  flex-direction: column;
}

#history-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.history-header {
  padding: 30px;
  border-bottom: 1px solid rgba(197, 168, 128, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-title {
  font-family: var(--font-title);
  color: var(--accent-gold);
  font-size: 20px;
  letter-spacing: 2px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 28px;
  cursor: pointer;
  transition: color 0.3s;
}

.close-btn:hover {
  color: var(--accent-gold);
}

.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Customize scrollbar */
.history-body::-webkit-scrollbar {
  width: 6px;
}
.history-body::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}
.history-body::-webkit-scrollbar-thumb {
  background: var(--accent-bronze);
  border-radius: 3px;
}

.history-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 2px solid rgba(197, 168, 128, 0.15);
  padding-left: 15px;
}

.history-speaker {
  font-weight: bold;
  color: var(--accent-gold);
  font-size: 14px;
}

.history-speaker.narrator {
  color: var(--text-dim);
  font-style: italic;
}

.history-text {
  font-size: 16px;
  line-height: 1.6;
}

/* Toast Message */
#toast {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(197, 168, 128, 0.95);
  color: #000;
  border-radius: 6px;
  padding: 10px 24px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* CG transition styles */
.cg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
