/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #e0e0e0;
  cursor: none;
}

/* ── Background blur fill ─────────────────────────────────────────────────── */
#scene-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  display: none; /* shown only when a slide is playing */
}

#video-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  /* taller than screen to cover blur edge bleeding at top/bottom */
  height: calc(100% + 80px);
  width: auto;
  min-width: 100%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  filter: blur(30px);
}

/* ── Scene: video + overlay, tutto trasformato insieme ────────────────────── */
#scene {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  transform-origin: center center;
  will-change: transform;
  z-index: 1;
}

#video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

#overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: none; /* shown only in settings */
}

/* ── Slide number placeholder (visible until real videos are ready) ───────── */
#slide-number {
  position: absolute;
  inset: 0;
  display: none; /* shown via JS when playing */
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 28vh;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: rgba(255, 210, 80, 0.18);
  letter-spacing: -0.05em;
  user-select: none;
}

/* ── Idle screen ──────────────────────────────────────────────────────────── */
#idle-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 10;
}

.idle-ring {
  position: relative;
  width: 100vh;
  height: 100vh;
  border-radius: 50%;
  border: 2px solid rgba(80, 180, 220, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: idle-pulse 3s ease-in-out infinite;
}

.idle-ring::before {
  content: '';
  position: absolute;
  width: calc(100% - 40px);
  height: calc(100% - 40px);
  border-radius: 50%;
  border: 1px solid rgba(80, 180, 220, 0.08);
}

@keyframes idle-pulse {
  0%, 100% { border-color: rgba(80, 180, 220, 0.12); }
  50%       { border-color: rgba(80, 180, 220, 0.30); }
}

.idle-message {
  text-align: center;
  color: rgba(80, 180, 220, 0.5);
  font-size: 1.1rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  line-height: 2;
}

.idle-key {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: rgba(80, 180, 220, 0.25);
  display: block;
  margin-top: 0.5rem;
}

/* ── Guide circle: visibile in modalità settings ──────────────────────────── */
#lens-guide {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 100vh;
  height: 100vh;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px dashed rgba(0, 220, 180, 0.5);
  pointer-events: none;
  z-index: 20;
  display: none;
}

/* ── Pannelli OSD ─────────────────────────────────────────────────────────── */
.panel {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(0, 200, 180, 0.35);
  box-shadow: 0 0 40px rgba(0, 200, 180, 0.12), inset 0 0 40px rgba(0,0,0,0.5);
  min-width: 420px;
  padding: 0;
  user-select: none;
}

/* .panel.hidden — covered by global .hidden rule above */

.panel-title {
  background: rgba(0, 180, 160, 0.25);
  border-bottom: 1px solid rgba(0, 220, 200, 0.4);
  text-align: center;
  padding: 14px 24px;
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgb(0, 240, 220);
}

/* ── Settings menu ────────────────────────────────────────────────────────── */
#settings-menu {
  padding: 12px 0 16px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px 10px 24px;
  font-size: 0.88rem;
  letter-spacing: 0.05em;
  color: rgba(220, 220, 220, 0.95);
  transition: background 0.08s;
  gap: 24px;
}

.menu-row.selected {
  background: rgba(0, 200, 180, 0.25);
  color: #fff;
}

.menu-row.selected::before {
  content: '▶';
  margin-right: 8px;
  color: rgba(0, 220, 200, 0.9);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.menu-row:not(.selected)::before {
  content: ' ';
  margin-right: 8px;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.menu-label {
  flex: 1;
  text-align: left;
}

.menu-label-action {
  flex: 1;
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.menu-row.selected .menu-label-action {
  color: rgba(0, 220, 200, 1);
}

.confirm-danger {
  color: rgba(255, 100, 80, 0.8) !important;
}

.menu-row.selected .confirm-danger {
  color: rgba(255, 120, 100, 1) !important;
}

.menu-value {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 110px;
  justify-content: flex-end;
}

.menu-value .arrow {
  color: rgba(0, 220, 200, 0.6);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.menu-row.selected .menu-value .arrow {
  color: rgb(0, 240, 220);
}

.menu-value .val {
  min-width: 60px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: bold;
  color: rgb(0, 240, 220);
}

.menu-divider {
  height: 1px;
  background: rgba(0, 200, 180, 0.15);
  margin: 8px 24px;
}

.panel-hint {
  text-align: center;
  padding: 10px 24px 14px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: rgba(180, 180, 180, 0.75);
  border-top: 1px solid rgba(100, 100, 100, 0.4);
}

/* ── RFID slot count in settings ─────────────────────────────────────────── */
.rfid-count .val {
  color: rgba(180, 180, 180, 0.7);
}
.rfid-count.partial .val {
  color: rgba(0, 220, 200, 0.8);
}
.rfid-count.full .val {
  color: rgba(80, 220, 80, 0.9);
}
.rfid-hint {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(150, 150, 150, 0.6);
  margin-left: 10px;
  white-space: nowrap;
}
.menu-row.selected .rfid-hint {
  color: rgba(0, 200, 180, 0.7);
}

/* ── RFID Learn panel ─────────────────────────────────────────────────────── */
.learn-slot {
  text-align: center;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgb(0, 240, 220);
  padding: 18px 28px 4px;
}
.learn-count {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(180, 180, 180, 0.7);
  letter-spacing: 0.12em;
  padding-bottom: 16px;
}
.learn-waiting {
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: rgba(220, 220, 220, 0.9);
  padding: 10px 28px 16px;
  animation: blink 1.4s ease-in-out infinite;
}
.learn-waiting.full {
  color: rgba(220, 80, 80, 0.85);
  animation: none;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.learn-list {
  padding: 0 28px 12px;
  border-top: 1px solid rgba(80, 80, 80, 0.3);
  padding-top: 10px;
}
.learn-uid {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(0, 200, 180, 0.7);
  padding: 3px 0;
}

/* ── Tracking panel ───────────────────────────────────────────────────────── */
#tracking-content {
  padding: 16px 28px 16px;
}

.tracking-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.track-label {
  min-width: 90px;
  color: rgba(220, 220, 220, 0.95);
  letter-spacing: 0.05em;
}

.track-bar-wrap {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(0, 200, 180, 0.15);
}

.track-bar {
  height: 100%;
  background: rgba(0, 200, 180, 0.6);
  transition: width 0.3s ease;
  min-width: 2px;
}

.track-count {
  min-width: 36px;
  text-align: right;
  font-weight: bold;
  color: rgba(0, 220, 200, 0.9);
}

.tracking-total {
  text-align: right;
  font-size: 0.8rem;
  color: rgba(200, 200, 200, 0.8);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(100, 100, 100, 0.4);
  letter-spacing: 0.1em;
}

.tracking-hint {
  text-align: center;
  margin-top: 14px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: rgba(180, 180, 180, 0.75);
}

/* ── Confirm panel ────────────────────────────────────────────────────────── */
#confirm-menu {
  padding: 16px 0 18px;
}

/* ── Cooldown message ─────────────────────────────────────────────────────── */
#cooldown-msg {
  position: fixed;
  top: 50%;
  left: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  letter-spacing: 0.15em;
  color: rgba(255, 200, 80, 0.95);
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 200, 80, 0.3);
  padding: 12px 28px;
  z-index: 90;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Serial status dot ────────────────────────────────────────────────────── */
#serial-status {
  position: fixed;
  top: 22px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  z-index: 150;
  transition: background 0.3s, box-shadow 0.3s, opacity 0.6s;
}

#serial-status[data-status="disconnected"] {
  background: rgb(220, 60, 60);
  box-shadow: 0 0 8px rgba(220, 60, 60, 0.5);
}

#serial-status[data-status="connected"] {
  background: rgb(0, 220, 100);
  box-shadow: 0 0 8px rgba(0, 220, 100, 0.7);
}

#serial-status[data-status="hidden"] {
  opacity: 0;
  pointer-events: none;
}

#serial-status[data-status="error"] {
  background: rgb(220, 60, 60);
  box-shadow: 0 0 8px rgba(220, 60, 60, 0.7);
}

/* ── Notifica flash ───────────────────────────────────────────────────────── */
#flash {
  position: fixed;
  bottom: 32px;
  left: 50%;
  background: rgba(0,0,0,0.85);
  border: 1px solid rgba(0,200,180,0.3);
  color: rgba(0,220,200,0.9);
  padding: 8px 24px;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#flash.show { opacity: 1; }
