/* ── Reset ─────────────────────────────────────────── */

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

html, body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: border-color 0.15s ease;
  border: 4px solid transparent;
}

/* ══════════════════════════════════════════════════════
   LANDING PAGE (index.html)
   ══════════════════════════════════════════════════════ */

.landing-page {
  background: #0a0a0f;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Logo — top-left */
.logo {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 36px;
  height: 36px;
  object-fit: contain;
  z-index: 10;
}

/* Center content */
.landing-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.landing-title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffffff;
  line-height: 1.1;
}

.version-badge {
  font-size: 1rem;
  font-weight: 600;
  color: #00adb5;
  vertical-align: super;
  letter-spacing: 0.04em;
}

.landing-caption {
  font-size: 0.95rem;
  color: #777;
  margin-top: -0.25rem;
}

/* Loading section */
.loading-section {
  width: 100%;
  max-width: 280px;
  margin: 1rem 0;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: #1a1a2e;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: #00adb5;
  border-radius: 2px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(0, 173, 181, 0.4);
}

.loading-status {
  font-size: 0.8rem;
  color: #666;
  text-align: center;
  margin-top: 0.5rem;
}

.loading-section.complete .loading-status {
  color: #00adb5;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  height: 52px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-primary {
  background: #1a2a3a;
  color: #556;
}

.btn-primary.ready {
  background: #00adb5;
  color: #fff;
}

.btn-primary.ready:hover {
  background: #00959c;
}

.btn-outline {
  background: transparent;
  color: #00adb5;
  border: 1.5px solid #00adb5;
  height: 44px;
  min-width: 160px;
  font-size: 0.85rem;
}

.btn-outline:hover {
  background: rgba(0, 173, 181, 0.1);
}

/* ══════════════════════════════════════════════════════
   APP PAGE (app.html)
   ══════════════════════════════════════════════════════ */

.app-page {
  background: #000;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

/* App logo — top-left over video */
.app-logo {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  width: 28px;
  height: 28px;
  object-fit: contain;
  z-index: 20;
  opacity: 0.7;
  padding-top: env(safe-area-inset-top, 0);
}

/* Full-screen video */
#camera-feed {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 1;
  background: #000;
}

/* DETECT overlay — shown when camera is off */
#detect-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  background: #0a0a0f;
  transition: opacity 0.3s ease;
}

#detect-overlay span {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.08);
  user-select: none;
}

#detect-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* App status text (loading state) */
.app-status {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
  white-space: nowrap;
}

.app-status.hidden {
  display: none;
}

.app-status.error {
  color: #ff5555;
}

.app-status.ready {
  color: #44cc66;
}

/* Alert banner */
#alert-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  text-align: center;
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top, 0));
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  background: #cc2020;
  animation: banner-pulse 0.5s ease-in-out infinite alternate;
}

#alert-banner.visible {
  display: block;
}

@keyframes banner-pulse {
  from { background: #cc2020; }
  to   { background: #ff4040; }
}

/* Alert border flash */
body.alerting {
  border-color: #ff2020;
  animation: pulse-border 0.4s ease-in-out 3;
}

@keyframes pulse-border {
  0%, 100% { border-color: #ff2020; }
  50%      { border-color: #ff6060; box-shadow: inset 0 0 30px rgba(255, 32, 32, 0.15); }
}

/* Camera toggle button */
.camera-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 180px;
  height: 52px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.camera-toggle:active:not(:disabled) {
  transform: translateX(-50%) scale(0.97);
}

.camera-toggle:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.camera-toggle.active {
  background: rgba(220, 50, 50, 0.6);
  border-color: rgba(220, 50, 50, 0.5);
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Landscape
   ══════════════════════════════════════════════════════ */

@media (orientation: landscape) and (max-height: 500px) {
  /* Landing page — compact */
  .landing-title {
    font-size: 2.2rem;
  }

  .landing-center {
    gap: 0.5rem;
  }

  .loading-section {
    margin: 0.5rem 0;
  }

  .btn {
    height: 44px;
    min-width: 160px;
    font-size: 0.9rem;
  }

  /* App page — button to bottom-right */
  .camera-toggle {
    bottom: 0.75rem;
    left: auto;
    right: 1rem;
    transform: none;
    min-width: 150px;
    height: 44px;
    font-size: 0.9rem;
  }

  .camera-toggle:active:not(:disabled) {
    transform: scale(0.97);
  }

  .app-status {
    bottom: 4rem;
    right: 1rem;
    left: auto;
    transform: none;
  }

  #detect-overlay span {
    font-size: 3rem;
  }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Tablet / Desktop
   ══════════════════════════════════════════════════════ */

@media (min-width: 768px) {
  .landing-title {
    font-size: 4rem;
  }

  .version-badge {
    font-size: 1.2rem;
  }

  .landing-caption {
    font-size: 1.1rem;
  }

  #detect-overlay span {
    font-size: 5rem;
  }

  .camera-toggle {
    min-width: 220px;
    height: 56px;
    font-size: 1.05rem;
  }
}
