/* =====================================================
   LIBRARYDOOR KIOSK — State-based UI
   ===================================================== */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-midnight);
  color: var(--color-cream);
  font-family: var(--font-body);
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== State Container ===== */
#kiosk {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ===== State Screens ===== */
.state-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-default);
  z-index: var(--z-base);
}

.state-screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: var(--z-above);
}

/* ===== STARTUP — Tap to Begin ===== */
#screen-startup {
  background: var(--color-midnight);
  flex-direction: column;
  cursor: pointer;
}

.startup-content {
  text-align: center;
}

.startup-title {
  font-family: var(--font-accent);
  font-size: var(--text-5xl);
  color: var(--color-gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: var(--space-6);
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

.startup-tap {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--color-parchment);
  letter-spacing: 0.1em;
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ===== IDLE — Black Screen ===== */
#screen-idle {
  background: #000;
}

/* ===== ATTRACT — Video ===== */
#screen-attract {
  background: #000;
}

#attract-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== SCAN PROMPT ===== */
#screen-scan {
  background: var(--color-midnight);
  flex-direction: column;
  gap: var(--space-8);
}

.scan-content {
  text-align: center;
  animation: fadeInUp 0.6s var(--ease-out) both;
}

.scan-title {
  font-family: var(--font-accent);
  font-size: var(--text-4xl);
  color: var(--color-gold);
  letter-spacing: var(--tracking-widest, 0.2em);
  text-transform: uppercase;
  margin-bottom: var(--space-4);
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

.scan-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--color-parchment);
  letter-spacing: 0.1em;
}

.scan-divider {
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-copper), transparent);
  margin: var(--space-6) auto;
}

.scan-hint {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--color-muted);
  margin-top: var(--space-8);
  letter-spacing: 0.05em;
}

.scan-hint strong {
  color: var(--color-copper);
}

/* Pulsing scanner icon */
.scan-icon {
  width: 80px;
  height: 80px;
  border: 3px solid var(--color-gold);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-6);
  animation: pulse 2s ease-in-out infinite;
}

.scan-icon-bar {
  width: 50px;
  height: 3px;
  background: var(--color-copper);
  animation: scanLine 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.3); }
  50% { box-shadow: 0 0 0 15px rgba(212, 175, 55, 0); }
}

@keyframes scanLine {
  0%, 100% { transform: translateY(-10px); }
  50% { transform: translateY(10px); }
}

/* ===== VERIFYING — Spinner ===== */
#screen-verifying {
  background: var(--color-midnight);
  flex-direction: column;
  gap: var(--space-6);
}

.spinner {
  width: 60px;
  height: 60px;
  border: 3px solid var(--color-charcoal);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.verifying-text {
  font-family: var(--font-accent);
  font-size: var(--text-xl);
  color: var(--color-parchment);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ===== ACCESS GRANTED ===== */
#screen-granted {
  background: var(--color-midnight);
  flex-direction: column;
  gap: var(--space-6);
}

#screen-granted.active {
  animation: glowGreen 0.6s var(--ease-out) both;
}

@keyframes glowGreen {
  0% { box-shadow: inset 0 0 0 rgba(46, 204, 113, 0); }
  50% { box-shadow: inset 0 0 100px rgba(46, 204, 113, 0.15); }
  100% { box-shadow: inset 0 0 60px rgba(46, 204, 113, 0.08); }
}

.granted-checkmark {
  width: 80px;
  height: 80px;
  border: 3px solid var(--color-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.4s var(--ease-bounce) both;
  box-shadow: var(--shadow-glow-success);
}

.granted-checkmark svg {
  width: 40px;
  height: 40px;
  stroke: var(--color-success);
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: drawCheck 0.4s 0.3s var(--ease-out) forwards;
}

@keyframes scaleIn {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.granted-welcome {
  font-family: var(--font-accent);
  font-size: var(--text-2xl);
  color: var(--color-gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.granted-name {
  font-family: var(--font-display);
  font-size: var(--text-5xl);
  color: var(--color-cream);
  animation: fadeInUp 0.5s 0.2s var(--ease-out) both;
}

/* ===== ACCESS DENIED ===== */
#screen-denied {
  background: var(--color-midnight);
  flex-direction: column;
  gap: var(--space-6);
}

#screen-denied.active {
  animation: glowRed 0.6s var(--ease-out) both;
}

@keyframes glowRed {
  0% { box-shadow: inset 0 0 0 rgba(192, 57, 43, 0); }
  50% { box-shadow: inset 0 0 100px rgba(192, 57, 43, 0.15); }
  100% { box-shadow: inset 0 0 60px rgba(192, 57, 43, 0.08); }
}

.denied-icon {
  width: 80px;
  height: 80px;
  border: 3px solid var(--color-error);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.4s var(--ease-bounce) both;
  box-shadow: var(--shadow-glow-error);
}

.denied-icon svg {
  width: 36px;
  height: 36px;
  stroke: var(--color-error);
  stroke-width: 3;
  fill: none;
}

.denied-title {
  font-family: var(--font-accent);
  font-size: var(--text-2xl);
  color: var(--color-error);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.denied-hint {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--color-parchment);
  letter-spacing: 0.05em;
}

.denied-hint strong {
  color: var(--color-copper);
}

/* ===== ERROR ===== */
#screen-error {
  background: var(--color-midnight);
  flex-direction: column;
  gap: var(--space-6);
}

.error-title {
  font-family: var(--font-accent);
  font-size: var(--text-2xl);
  color: var(--color-error);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.error-hint {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--color-parchment);
}

/* ===== Hidden Webcam ===== */
#motion-video {
  position: absolute;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
}

#motion-canvas {
  display: none;
}

/* ===== Common Animations ===== */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
