/* ============================================================
   RESCUE QUEST — Game CSS
   Cinematic Noir / Emergency Medical Simulator
   Mobile Landscape Only
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;600;700&family=Share+Tech+Mono&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

:root {
  --red-alert:   #cc1111;
  --amber:       #f0a500;
  --white:       #e8e8e0;
  --dim:         #aaa;
  --black:       #000000;
  --overlay-red: rgba(180, 10, 10, 0.38);
  --font-hud:    'Rajdhani', sans-serif;
  --font-mono:   'Share Tech Mono', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-hud);
  touch-action: none;
}

/* ── Orientation Lock ─────────────────────────────────────── */
#orientation-wall {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--black);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 30px;
}

#orientation-wall .rotate-icon {
  font-size: 52px;
  animation: rotateHint 1.5s ease-in-out infinite;
}

#orientation-wall p {
  font-family: var(--font-hud);
  font-size: 18px;
  color: var(--amber);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.5;
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50%       { transform: rotate(90deg); }
}

@media (orientation: portrait) {
  #orientation-wall { display: flex; }
  #game-root        { display: none; }
}

/* ── Game Root ────────────────────────────────────────────── */
#game-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Scene Container ──────────────────────────────────────── */
.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.05s;
}

.scene.active {
  opacity: 1;
  pointer-events: all;
}

.scene.fade-in {
  animation: fadeIn var(--fade-duration, 1200ms) ease forwards;
}

.scene.fade-out {
  animation: fadeOut var(--fade-duration, 800ms) ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── SCENE: Intro (Black) ─────────────────────────────────── */
#scene-intro {
  background: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
}

.intro-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 48px;
  animation: introReveal 1.8s ease forwards;
  opacity: 0;
}

@keyframes introReveal {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

.intro-logo .logo-cross {
  font-size: 38px;
  color: var(--red-alert);
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(204,17,17,0.7));
}

.intro-logo .logo-title {
  font-family: var(--font-hud);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--white);
}

.intro-logo .logo-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--amber);
  text-transform: uppercase;
}

/* ── Test Button ──────────────────────────────────────────── */
#btn-test {
  position: relative;
  padding: 14px 52px;
  background: transparent;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: var(--font-hud);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  animation: introReveal 1.8s ease 0.6s forwards;
  opacity: 0;
  transition: color 0.25s, border-color 0.25s;
}

#btn-test::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--amber);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 0;
}

#btn-test:active::before,
#btn-test:hover::before {
  transform: scaleX(1);
}

#btn-test span {
  position: relative;
  z-index: 1;
}

#btn-test:active,
#btn-test:hover {
  color: var(--black);
}

/* corner decorations */
#btn-test::after {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 8px; height: 8px;
  border-top: 2px solid var(--red-alert);
  border-left: 2px solid var(--red-alert);
}

/* ── SCENE: Sede ──────────────────────────────────────────── */
#scene-sede {
  background: var(--black);
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Iris reveal: l'immagine si apre dal centro come un diaframma */
.scene-bg.iris-reveal {
  clip-path: circle(0% at 50% 50%);
  animation: irisOpen 3.2s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes irisOpen {
  0%   { clip-path: circle(0%   at 50% 50%); }
  100% { clip-path: circle(150% at 50% 50%); }
}

/* Cinematic vignette always on */
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 45%,
    rgba(0,0,0,0.72) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* Film grain overlay */
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 3;
  animation: grainShift 0.12s steps(1) infinite;
}

@keyframes grainShift {
  0%   { background-position: 0 0; }
  25%  { background-position: -30px 15px; }
  50%  { background-position: 20px -10px; }
  75%  { background-position: -10px 25px; }
  100% { background-position: 15px -20px; }
}

/* ── Hotspot Layer ────────────────────────────────────────── */
.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.hotspot {
  position: absolute;
  cursor: crosshair;
  border-radius: 4px;
  transition: background 0.2s;
}

/* Dev mode: visualize hotspots */
body.dev-mode .hotspot {
  background: rgba(255, 0, 0, 0.25);
  border: 1px dashed rgba(255, 80, 80, 0.8);
}

body.dev-mode .hotspot::after {
  content: attr(data-id);
  position: absolute;
  top: 4px;
  left: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #ff4444;
  text-shadow: 0 0 3px black;
}

/* Hotspot pulse on active */
.hotspot:active {
  background: rgba(240, 165, 0, 0.18) !important;
}

/* ── HUD Bar (bottom) ─────────────────────────────────────── */
#hud-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
}

#hud-bar.visible { opacity: 1; }

.hud-item {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--dim);
  text-transform: uppercase;
}

.hud-item.status-ok   { color: #44bb44; }
.hud-item.status-warn { color: var(--amber); }

/* ── Scene BG swap (img001 → img002) ─────────────────────── */
#scene-sede .scene-bg-alert {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1;
}

#scene-sede .scene-bg-alert.visible {
  opacity: 1;
}

/* ── Tablet Zoom System ───────────────────────────────────── */
#tablet-zoom {
  position: absolute;
  /* Posizione iniziale: sopra il tablet nella scena (% calibrate) */
  left: 36%;
  top: 70%;
  width: 22%;
  height: 16%;
  z-index: 50;
  background: #0d1117;
  border: 1.5px solid #2a2a2a;
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform-origin: center center;
  transition:
    left 0.85s cubic-bezier(0.4, 0, 0.2, 1),
    top 0.85s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.85s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.85s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.85s ease,
    opacity 0.3s ease;
}

#tablet-zoom.zoom-open {
  left: 5%;
  top: 5%;
  width: 90%;
  height: 90%;
  border-radius: 10px;
  opacity: 1;
  pointer-events: all;
}

/* ── ePCR Mission Interface ───────────────────────────────── */
.epcr-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0d1117;
  color: #c9d1d9;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
}

.epcr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
}

.epcr-header .logo-112 {
  font-family: var(--font-hud);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.1em;
}

.epcr-header .soreu-label {
  font-size: 9px;
  color: #8b949e;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.epcr-header .mission-time {
  font-size: 10px;
  color: var(--amber);
}

.epcr-body {
  flex: 1;
  padding: 10px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.epcr-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.epcr-label {
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8b949e;
  min-width: 80px;
  flex-shrink: 0;
}

.epcr-value {
  font-family: var(--font-hud);
  font-size: 13px;
  font-weight: 600;
  color: #e6edf3;
}

.epcr-value.codice-giallo {
  color: var(--amber);
  font-size: 15px;
  letter-spacing: 0.15em;
}

.epcr-value.codice-rosso { color: var(--red-alert); }

.epcr-divider {
  border: none;
  border-top: 1px solid #21262d;
  margin: 2px 0;
}

.epcr-note {
  background: #161b22;
  border-left: 2px solid var(--amber);
  padding: 6px 10px;
  font-size: 10px;
  color: #c9d1d9;
  line-height: 1.5;
  border-radius: 0 4px 4px 0;
}

.epcr-footer {
  padding: 8px 14px;
  background: #161b22;
  border-top: 1px solid #21262d;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#btn-accetta {
  flex: 1;
  padding: 10px;
  background: #1a7f37;
  border: 1px solid #2ea043;
  border-radius: 5px;
  color: #fff;
  font-family: var(--font-hud);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-accetta:active { background: #2ea043; }

#btn-rifiuta {
  padding: 10px 16px;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 5px;
  color: #8b949e;
  font-family: var(--font-hud);
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

/* ── Alert Overlay (luce rossa emergenza) ─────────────────── */
#alert-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: var(--overlay-red);
  pointer-events: none;
  opacity: 0;
  animation: none;
}

#alert-overlay.pulsing {
  animation: emergencyPulse 0.9s ease-in-out infinite;
}

@keyframes emergencyPulse {
  0%, 100% { opacity: 0; }
  50%       { opacity: 1; }
}

/* ── Tooltip ──────────────────────────────────────────────── */
#tooltip {
  position: absolute;
  z-index: 30;
  background: rgba(0,0,0,0.88);
  border: 1px solid var(--amber);
  color: var(--white);
  font-family: var(--font-hud);
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  max-width: 220px;
}

#tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Black Transition Screen ──────────────────────────────── */
#transition-black {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--black);
  pointer-events: none;
  opacity: 0;
}

#transition-black.covering {
  animation: coverBlack 600ms ease forwards;
}

#transition-black.revealing {
  animation: revealBlack 1000ms ease forwards;
}

@keyframes coverBlack {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes revealBlack {
  from { opacity: 1; }
  to   { opacity: 0; }
}
