/* face-car-filter — style.css
 * Brand palette (SPEC §5): deep navy #0B0F2C, electric blue #1764FF,
 * cyan #00D4FF, hot pink #FF2D7A, amber #FFB800.
 * Mobile-portrait first (390x844), must also survive desktop 960x540.
 */

:root {
  --navy: #0B0F2C;
  --blue: #1764FF;
  --cyan: #00D4FF;
  --pink: #FF2D7A;
  --amber: #FFB800;
  --ink: #F4F7FF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--navy);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "PingFang TC", "PingFang SC", "Hiragino Sans", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.hidden { display: none !important; }

.app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.layer, .screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* ---------------- camera layer ---------------- */
.camera-layer { z-index: 1; background: #000; }
.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 1;
}
.bg-nocam { z-index: 1; }

/* ---------------- topbar (intro only) ---------------- */
.topbar {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 5;
}

.lang-switch { display: flex; gap: 6px; flex-wrap: wrap; }

.lang-chip {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(11,15,44,0.55);
  color: var(--ink);
  font-size: 12px;
  line-height: 1;
  padding: 7px 9px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.lang-chip.active {
  border-color: var(--cyan);
  color: var(--navy);
  background: var(--cyan);
  font-weight: 700;
}

.icon-btn {
  appearance: none;
  border: none;
  background: rgba(11,15,44,0.55);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.icon-btn img { width: 100%; height: 100%; object-fit: contain; }
.icon-btn.sound-off img { opacity: 0.35; filter: grayscale(1); }
.icon-btn.sound-on img { opacity: 1; }

/* ---------------- intro ---------------- */
.screen-intro { z-index: 3; }

.intro-center {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 86%;
  max-width: 480px;
  text-align: center;
  z-index: 2;
}

.emblem {
  width: 34vw;
  max-width: 160px;
  min-width: 88px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(0,212,255,0.55));
  opacity: 0;
  transform: scale(0.6);
  animation: emblem-in 0.6s cubic-bezier(.2,1.4,.4,1) forwards;
}

.title-text {
  margin: 14px 0 6px;
  font-size: clamp(24px, 7vw, 40px);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 0 18px rgba(23,100,255,0.6);
  opacity: 0;
  transform: translateY(14px) scale(0.92);
  animation: title-in 0.6s 0.15s cubic-bezier(.2,1.4,.4,1) forwards;
}

.question-text {
  margin: 0;
  font-size: clamp(14px, 4vw, 18px);
  color: rgba(244,247,255,0.85);
  opacity: 0;
  animation: fade-in 0.5s 0.35s forwards;
}

@keyframes emblem-in { to { opacity: 1; transform: scale(1); } }
@keyframes title-in { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fade-in { to { opacity: 1; } }

.screen-intro.intro-skip .emblem,
.screen-intro.intro-skip .title-text,
.screen-intro.intro-skip .question-text {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

.primary-btn {
  appearance: none;
  border: none;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62%;
  max-width: 320px;
  min-width: 200px;
  height: 56px;
  border-radius: 999px;
  overflow: hidden;
  z-index: 2;
}
.primary-btn .btn-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
.primary-btn .btn-label {
  position: relative;
  z-index: 1;
  font-size: 16px;
  font-weight: 800;
  color: #1A0B12;
  white-space: nowrap;
}
.primary-btn:disabled { opacity: 0.6; }

.start-btn {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 9%);
  transform: translateX(-50%);
}

/* ---------------- scanning ---------------- */
.screen-scanning { z-index: 4; pointer-events: none; }

.scanner-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}

.scan-line {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  animation: scan-move 1.8s ease-in-out infinite;
  z-index: 2;
}
@keyframes scan-move {
  0% { top: 12%; opacity: 0.2; }
  50% { top: 82%; opacity: 1; }
  100% { top: 12%; opacity: 0.2; }
}

.marquee {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: min(44vw, 240px);
  height: min(44vw, 240px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.marquee-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
}

.scan-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12%;
  text-align: center;
  z-index: 3;
}
.analyzing-text {
  margin: 0 0 4px;
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0,212,255,0.7);
}
.putface-text {
  margin: 0;
  font-size: clamp(12px, 3.4vw, 14px);
  color: rgba(244,247,255,0.8);
}

.nocam-hint {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 0;
  right: 0;
  text-align: center;
  margin: 0;
  font-size: 12px;
  color: rgba(244,247,255,0.75);
  z-index: 4;
}

/* ---------------- result ---------------- */
.screen-result { z-index: 4; }

/* top/width/height below are fallback defaults for the instant before
 * game.js's layoutResult() runs; layoutResult() sets all three inline
 * (per-vehicle, per-viewport) so the car+plate render as one connected
 * group in the upper part of the screen — see docs/HANDOFF.md
 * "2026-09-15 layout fix". */
.result-vehicle {
  position: absolute;
  top: 4%;
  left: 50%;
  width: min(78vw, 420px);
  transform: translateX(-50%) scale(0.4);
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,0.55));
  opacity: 0;
}
.result-vehicle.bounce-in {
  animation: vehicle-bounce 0.55s cubic-bezier(.22,1.6,.4,1) forwards;
}
@keyframes vehicle-bounce {
  0% { opacity: 0; transform: translateX(-50%) scale(0.35); }
  60% { opacity: 1; transform: translateX(-50%) scale(1.08); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}

.plate {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  width: 45vw;
  z-index: 3;
}
.plate-bg { width: 100%; display: block; }
.plate-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 12%;
  text-align: center;
}
.plate-line { margin: 0; }
.plate-line1 { font-size: clamp(11px, 2.6vw, 14px); color: rgba(244,247,255,0.85); }
.plate-line2 { font-size: clamp(16px, 4.4vw, 24px); font-weight: 800; color: #FFFFFF; text-shadow: 0 0 10px rgba(23,100,255,0.6); }

.confetti {
  position: absolute;
  top: 4%;
  left: 50%;
  width: 70vw;
  max-width: 360px;
  transform: translateX(-50%) scale(0.9);
  opacity: 0;
  z-index: 4;
  pointer-events: none;
}
.confetti.confetti-burst {
  animation: confetti-pop 1.5s ease-out forwards;
}
@keyframes confetti-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.7) translateY(0); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.05) translateY(10px); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.15) translateY(60px); }
}

.result-buttons {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 6%);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.result-btn { width: 42%; min-width: 130px; max-width: 180px; height: 50px; }

/* ---------------- flash + toast ---------------- */
.flash {
  position: absolute;
  inset: 0;
  background: #FFFFFF;
  opacity: 0;
  z-index: 10;
  pointer-events: none;
}
.flash.flash-active { opacity: 1; transition: opacity 0.15s ease-out; }

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22%);
  transform: translateX(-50%);
  background: rgba(11,15,44,0.92);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 80vw;
  text-align: center;
}
.toast.toast-visible { opacity: 1; }

.save-canvas { position: absolute; left: -9999px; top: -9999px; }

/* ---------------- small desktop / landscape safety (960x540 etc.) ---------------- */
@media (min-aspect-ratio: 4/3) {
  .intro-center { top: 30%; }
  .emblem { width: 14vw; max-width: 120px; }
  .start-btn { bottom: calc(env(safe-area-inset-bottom) + 6%); }
  .marquee { top: 8%; width: min(44vw, 240px); height: min(44vw, 240px); }
  /* .result-vehicle / .plate: no override here — game.js's layoutResult()
   * computes both dynamically for landscape too (car height capped via
   * vh, plate sized off the car box and clamped above the buttons). */
  .result-buttons { bottom: calc(env(safe-area-inset-bottom) + 5%); }
}
