/* style.css - MIKA-07 Heart Simulation UI */
/* Lighter clinical sci-fi aesthetic */

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

:root {
  --bg-primary: #1a2030;
  --bg-panel: rgba(0, 0, 0, 0.45);
  --bg-panel-solid: rgba(20, 30, 45, 0.85);
  --border-color: rgba(100, 180, 220, 0.25);
  --border-glow: rgba(100, 180, 220, 0.5);
  --text-primary: #e8eff4;
  --text-secondary: rgba(180, 200, 220, 0.75);
  --text-dim: rgba(140, 170, 195, 0.5);
  --ecg-green: #78f542;
  --vital-normal: #78f542;
  --vital-warn: #f5a623;
  --vital-danger: #f54242;
  --vital-cyan: #42d4f5;
  --accent-blue: rgba(80, 170, 220, 0.5);
  --burden-low: #42d4f5;
  --burden-mid: #f5a623;
  --burden-high: #f54242;
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-hover: rgba(255, 255, 255, 0.12);
  --btn-active: rgba(100, 180, 220, 0.2);
  --dialogue-bg: rgba(180, 215, 240, 0.85);
  --dialogue-text: #1a2030;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Noto Sans SC', 'Segoe UI', sans-serif;
  overflow: hidden;
  height: 100vh; width: 100vw;
}

/* ===========================
   SCREEN SYSTEM
   =========================== */
.screen { display: none; height: 100vh; width: 100vw; position: absolute; top: 0; left: 0; }
.screen.active { display: flex; }

/* ===========================
   MAIN MENU
   =========================== */
#main-menu {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: url('assets/bg/bg_base.png') center/cover no-repeat;
}
/* Base background might not exist, fallback gradient */
.menu-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(40, 80, 130, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(20, 60, 110, 0.25) 0%, transparent 50%),
    linear-gradient(180deg, #0d1520 0%, #152030 40%, #1a2840 100%);
}
.menu-bg::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 25%, rgba(200,220,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 60%, rgba(200,220,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 15%, rgba(200,220,255,0.3) 0%, transparent 100%),
    radial-gradient(2px 2px at 55% 35%, rgba(180,210,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 70%, rgba(200,220,255,0.25) 0%, transparent 100%);
}

.menu-content { position: relative; z-index: 1; text-align: center; max-width: 900px; width: 90%; }
.menu-header { margin-bottom: 36px; }
.menu-title {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 38px; font-weight: 300;
  letter-spacing: 6px;
  color: var(--text-primary);
  margin: 8px 0;
}
.menu-title-sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; color: var(--text-dim);
  letter-spacing: 4px;
}

.subject-cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.subject-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  width: 240px;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}
.subject-card:hover:not(.subject-locked) {
  border-color: var(--border-glow);
  box-shadow: 0 0 24px rgba(80, 170, 220, 0.12);
  transform: translateY(-3px);
}
.subject-locked { opacity: 0.3; cursor: not-allowed; }
.subject-portrait {
  width: 100%; height: 130px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(100,180,220,0.1);
  overflow: hidden;
}
.subject-portrait img { width: 100%; height: 100%; object-fit: cover; }
.subject-portrait-placeholder { font-family: 'Share Tech Mono', monospace; font-size: 36px; color: var(--text-dim); }
.subject-name { font-size: 16px; font-weight: 700; letter-spacing: 2px; margin-bottom: 2px; }
.subject-type { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.subject-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 10px; }
.subject-status {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 3px;
  padding: 3px 10px; border-radius: 3px; display: inline-block;
}
.status-ready { background: rgba(120,245,66,0.12); color: var(--ecg-green); border: 1px solid rgba(120,245,66,0.25); }
.status-locked { background: rgba(100,100,100,0.12); color: var(--text-dim); border: 1px solid rgba(100,100,100,0.15); }
.menu-footer { margin-top: 36px; }
.footer-text { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--text-dim); letter-spacing: 3px; }

/* ===========================
   GAME SCREEN
   =========================== */
#game-screen { flex-direction: column; }
/* Grid: scene fills left, vitals on right */
.game-layout { display: grid; grid-template-columns: 1fr 220px; flex: 1; min-height: 0; }
@media (min-width: 900px) { .game-layout { grid-template-columns: 1fr 250px; } }

/* LEFT: Menu Column - floating over the scene, NO background strip */
#menu-column {
  position: absolute;
  top: 40px; left: 6px;
  z-index: 20;
  background: transparent;
  border: none;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 140px);
}

.menu-tabs { display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
.menu-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px;
  border: none; border-radius: 4px;
  background: rgba(0,0,0,0.35);
  color: var(--text-secondary);
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.menu-tab:hover { color: var(--text-primary); background: rgba(0,0,0,0.5); }
.menu-tab-active { color: var(--vital-cyan); background: rgba(40,80,120,0.5); }
.menu-tab-locked { opacity: 0.2; pointer-events: none; }
.tab-icon { font-size: 12px; }
.tab-name { letter-spacing: 0; font-size: 11px; }

.ops-area { display: flex; flex-direction: column; gap: 2px; }
.op-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 3px;
  background: rgba(0,0,0,0.3);
  color: var(--text-primary);
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; font-weight: 400;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
  text-align: left;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.op-btn:hover:not(:disabled) { background: rgba(0,0,0,0.5); color: var(--vital-cyan); }
.op-btn:active:not(:disabled) { background: rgba(40,80,120,0.4); }
.op-btn-disabled, .op-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.op-btn-submenu { color: var(--text-secondary); }
.op-btn-back { color: var(--text-dim); font-size: 10px; }
.op-btn-active-toggle {
  color: var(--ecg-green);
  background: rgba(120,245,66,0.1);
}
.op-badge {
  position: absolute; top: -3px; right: -3px;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--vital-warn); border-radius: 3px;
  padding: 0 4px;
  font-size: 9px; color: var(--vital-warn);
  font-family: 'Share Tech Mono', monospace;
}

/* CENTER: Scene Area */
#scene-area { position: relative; overflow: hidden; }
#scene-bg {
  position: absolute; inset: 0;
  background: url('/assets/bg/lab1.png') center/cover no-repeat;
  filter: brightness(0.7) saturate(0.8);
  transition: background-image 0.5s ease;
}
#scene-bg.scene-lying {
  background-image: url('/assets/bg/bed1.png');
}
#character-container {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
#scene-indicator {
  position: absolute; top: 8px; left: 12px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: rgba(255,255,255,0.4);
  letter-spacing: 2px; z-index: 5;
  background: rgba(0,0,0,0.3);
  padding: 2px 8px; border-radius: 3px;
}

/* Cursor modes */
.cursor-stethoscope { cursor: url('/assets/cursor/stethoscope64.png') 16 50, crosshair; }
.cursor-syringe { cursor: url('/assets/cursor/syringe64.png') 10 10, crosshair; }
/* SVG hand cursor */
.cursor-hand {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M16 4c-.8 0-1.5.3-2 .8-.3.3-.5.6-.6 1-.4-.3-.9-.5-1.4-.5-1.1 0-2 .9-2 2v.5c-.4-.3-.9-.5-1.5-.5-1.1 0-2 .9-2 2v8c0 4.4 3.6 8 8 8h2c4.4 0 8-3.6 8-8v-6c0-1.1-.9-2-2-2-.5 0-1 .2-1.4.5V8c0-1.1-.9-2-2-2-.5 0-1 .2-1.4.5V6c0-1.1-.9-2-2-2z' fill='%23e8ddd0' stroke='%23887766' stroke-width='1'/%3E%3C/svg%3E") 16 4, pointer;
}

/* RIGHT: Vitals Column */
#vitals-column {
  background: var(--bg-panel-solid);
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  backdrop-filter: blur(6px);
}
.vitals-hidden { display: none !important; }
.vitals-visible { display: block !important; }

#ecg-panel {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 4px;
}
.panel-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px; color: var(--text-dim);
  letter-spacing: 2px; margin-bottom: 2px;
}
#ecg-canvas { width: 100%; height: 90px; display: block; border-radius: 3px; }

#vital-panel { flex: 1; }
.vital-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 6px; }
.vital-item {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px; text-align: center;
}
.vital-label { display: block; font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--text-dim); letter-spacing: 2px; }
.vital-value { display: block; font-family: 'Share Tech Mono', monospace; font-size: 22px; font-weight: 700; color: var(--vital-normal); line-height: 1.1; }
.vital-value.vital-warn { color: var(--vital-warn); }
.vital-value.vital-danger { color: var(--vital-danger); animation: pulse-danger 0.5s ease-in-out infinite alternate; }
.vital-unit { display: block; font-size: 9px; color: var(--text-dim); }

.vital-hr .vital-value { color: var(--ecg-green); }
.vital-hr .vital-value.vital-warn { color: var(--vital-warn); }
.vital-hr .vital-value.vital-danger { color: var(--vital-danger); }
.vital-bp .vital-value { color: var(--vital-cyan); }
.vital-spo2 .vital-value { color: var(--vital-cyan); }
.vital-spo2 .vital-value.vital-warn { color: var(--vital-warn); }
.vital-spo2 .vital-value.vital-danger { color: var(--vital-danger); }
.vital-rr .vital-value { color: #b8e6ff; }

.rhythm-display {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px; margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.rhythm-label { font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--text-dim); letter-spacing: 2px; }
.rhythm-value { font-family: 'Share Tech Mono', monospace; font-size: 15px; font-weight: 700; color: var(--vital-normal); }
.rhythm-value.rhythm-warn { color: var(--vital-warn); }
.rhythm-value.rhythm-danger { color: var(--vital-danger); }
.rhythm-value.rhythm-critical { color: var(--vital-danger); animation: pulse-danger 0.3s ease-in-out infinite alternate; }

.burden-panel { display: flex; flex-direction: column; gap: 3px; }
.burden-bar-group { display: grid; grid-template-columns: 50px 1fr 24px; align-items: center; gap: 3px; }
.burden-label { font-family: 'Share Tech Mono', monospace; font-size: 8px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
.burden-track { height: 5px; background: rgba(0,0,0,0.35); border: 1px solid rgba(100,180,220,0.1); border-radius: 2px; overflow: hidden; }
.burden-fill { height: 100%; width: 0%; background: var(--burden-low); border-radius: 1px; transition: width 0.3s ease; }
.burden-fill.burden-warn { background: var(--burden-mid); }
.burden-fill.burden-danger { background: var(--burden-high); }
.burden-fill-o2 { background: var(--vital-cyan); }
.burden-fill-device { background: #a78bfa; }
.burden-val { font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--text-dim); text-align: right; }

/* BOTTOM: Dialogue Bar */
#dialogue-bar {
  min-height: 85px;
  background: url('/assets/ui/message_box.png') center/100% 100% no-repeat,
              linear-gradient(180deg, rgba(160,200,230,0.9) 0%, rgba(140,185,220,0.92) 100%);
  border-top: 1px solid rgba(100,180,220,0.3);
  padding: 12px 24px;
  display: flex; align-items: flex-start;
}
#dialogue-box {
  width: 100%;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#dialogue-box.dialogue-active { opacity: 1; cursor: pointer; }
.dialogue-speaker {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: #2060a0;
  letter-spacing: 2px;
  margin-bottom: 3px;
  font-weight: 700;
}
.dialogue-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--dialogue-text);
  max-height: 48px;
  overflow-y: auto;
}
.dialogue-text .dialogue-advance {
  display: inline-block;
  color: #4090c0;
  font-size: 12px;
  margin-left: 6px;
  animation: bounce-arrow 0.8s ease-in-out infinite;
  cursor: pointer;
}
.dialogue-mood {
  font-size: 10px;
  color: rgba(30,50,80,0.5);
  font-style: italic;
  margin-top: 2px;
}

/* Not connected placeholder */
.vitals-placeholder {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 2;
}

/* Animations */
@keyframes pulse-danger { from { opacity: 1; } to { opacity: 0.5; } }
@keyframes pulse-active { from { box-shadow: 0 0 4px rgba(120,245,66,0.15); } to { box-shadow: 0 0 14px rgba(120,245,66,0.3); } }
@keyframes bounce-arrow { 0%,100% { transform: translateY(0); } 50% { transform: translateY(3px); } }

/* === Faint Overlay === */
#faint-overlay {
  position: absolute; inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease;
  z-index: 50;
}
#faint-overlay.faint-active {
  opacity: 1;
  pointer-events: all;
}

/* === X-ray Window === */
#xray-window {
  position: absolute;
  left: 35%; top: 42%;
  width: 30%; height: 22%;
  border-radius: 50%;
  border: 2px solid rgba(80, 200, 255, 0.4);
  box-shadow: 0 0 20px rgba(80, 200, 255, 0.15), inset 0 0 20px rgba(80, 200, 255, 0.1);
  background: rgba(80, 200, 255, 0.03);
  display: none;
  z-index: 8;
  pointer-events: none;
}
#xray-window.xray-active {
  display: block;
  animation: xray-pulse 2s ease-in-out infinite alternate;
}
@keyframes xray-pulse {
  from { box-shadow: 0 0 20px rgba(80,200,255,0.15), inset 0 0 20px rgba(80,200,255,0.1); }
  to { box-shadow: 0 0 30px rgba(80,200,255,0.25), inset 0 0 30px rgba(80,200,255,0.15); }
}

/* === Heart Container (inside chest, behind character) === */
#heart-container {
  position: absolute;
  left: 38%; top: 42%;
  width: 24%; height: 20%;
  z-index: 3;
  display: none;
  pointer-events: none;
}
#heart-container.heart-visible {
  display: block;
}
#heart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* === SVG Interaction Overlays === */
.interaction-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.interaction-overlay.show { opacity: 1; }

.svg-hand {
  width: 60px; height: 60px;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
}
.svg-stethoscope-head {
  width: 40px; height: 40px;
  filter: drop-shadow(0 0 4px rgba(100,200,255,0.3));
}

/* Scrollbar */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,180,220,0.2); border-radius: 2px; }

/* ===================================================
   MOBILE VITALS TOGGLE (only vitals needs toggle)
   =================================================== */
.mobile-toggle {
  display: none;
  position: fixed;
  z-index: 200;
  width: 32px; height: 32px;
  border: 1px solid rgba(100,180,220,0.3);
  border-radius: 50%;
  background: rgba(15,25,40,0.7);
  color: var(--text-secondary);
  font-size: 14px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  padding: 0; line-height: 32px; text-align: center;
}
#mobile-menu-toggle { display: none !important; } /* menu always visible, no toggle */
#mobile-vitals-toggle { top: 6px; right: 6px; }

/* ===================================================
   MOBILE: < 768px
   =================================================== */
@media (max-width: 768px) {
  #mobile-menu-toggle { display: none !important; }
  #mobile-vitals-toggle { display: block; }

  /* Main menu - stack cards */
  .menu-title { font-size: 24px; letter-spacing: 3px; }
  .subject-cards { flex-direction: column; align-items: center; }
  .subject-card { width: 85%; max-width: 300px; padding: 14px; }
  .subject-portrait { height: 100px; }
  .menu-header { margin-bottom: 20px; }
  .menu-footer { margin-top: 20px; }

  /* Grid: scene full width, vitals toggled separately */
  .game-layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr;
  }

  /* LEFT MENU: floating buttons over scene, same as desktop just smaller */
  #menu-column {
    position: absolute;
    top: 36px; left: 4px;
    max-height: calc(100vh - 140px);
  }
  .menu-tab { padding: 4px 6px; font-size: 11px; }
  .tab-icon { font-size: 11px; }
  .tab-name { font-size: 10px; }
  .op-btn { padding: 3px 6px; font-size: 10px; }

  /* RIGHT VITALS → floating overlay, toggled by ♡ */
  #vitals-column {
    position: fixed;
    top: -100vh; left: 0; right: 0;
    height: auto; max-height: 45vh;
    z-index: 140;
    transition: top 0.25s ease;
    background: rgba(12,20,35,0.92);
    border-bottom: 1px solid var(--border-color);
    border-left: none;
    padding: 36px 8px 8px 8px;
    flex-direction: column;
    overflow-y: auto;
  }
  #vitals-column.mobile-open { top: 0 !important; }

  /* Compact vitals */
  .vital-grid { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 3px; }
  .vital-item { padding: 3px 2px; }
  .vital-value { font-size: 15px; }
  .vital-label { font-size: 7px; }
  #ecg-canvas { height: 55px; }
  .burden-panel { display: none; }

  /* Scene full screen */
  #scene-area { grid-column: 1; width: 100vw; height: 100%; }

  /* Dialogue bar */
  #dialogue-bar { min-height: 58px; padding: 6px 12px; }
  .dialogue-text { font-size: 12px; max-height: 34px; }
  .dialogue-speaker { font-size: 10px; }

  /* Backdrop for vitals */
  .mobile-backdrop { display: none; position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,0.3); }
  .mobile-backdrop.show { display: block; }
}

/* Extra small */
@media (max-width: 400px) {
  .tab-name { display: none; }
  .tab-icon { font-size: 13px; }
  .menu-tab { padding: 4px 3px; justify-content: center; }
  .op-btn { font-size: 9px; padding: 3px 4px; }
}
