/* BetterTours -- Mobile-first panorama capture UI */

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

:root {
  --primary: #2196f3;
  --primary-dark: #1769aa;
  --accent: #00e676;
  --danger: #ff5722;
  --bg: #0d1117;
  --surface: #161b22;
  --text: #f0f6fc;
  --text-muted: #8b949e;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}

/* --- Screens --- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.screen.active {
  display: flex;
}

.screen-content {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
}

.screen-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.screen-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* --- Instructions --- */

.instructions {
  text-align: left;
  margin: 0 auto 2rem;
  max-width: 280px;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
}

/* --- Buttons --- */

.btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
}

.btn-small {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

/* --- Camera layer (shared across calibrate & capture) --- */

.camera-layer {
  position: fixed;
  inset: 0;
  background: black;
  display: none;
  z-index: 0;
}

.camera-layer.visible {
  display: block;
}

.camera-layer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-layer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* --- Camera-visible screens (transparent background) --- */

#screen-calibrate,
#screen-capture {
  background: transparent;
}

/* --- Calibrate overlay --- */

.calibrate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  background: linear-gradient(transparent 40%, rgba(0,0,0,0.8) 100%);
}

.calibrate-box {
  text-align: center;
  padding: 1.5rem;
  max-width: 340px;
}

.calibrate-box h2 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.calibrate-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
  line-height: 1.4;
}

/* --- Camera lock status (calibrate screen) --- */

.camera-lock-status {
  margin-bottom: 1rem;
}

.camera-lock-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.lock-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  line-height: 1.3;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lock-ok {
  background: rgba(0, 230, 118, 0.18);
  border: 1px solid rgba(0, 230, 118, 0.35);
  color: #b9f6ca;
}

.lock-skip {
  background: rgba(255, 152, 0, 0.15);
  border: 1px solid rgba(255, 152, 0, 0.3);
  color: #ffe0b2;
}

.lock-auto {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  flex-direction: column;
  text-align: center;
  gap: 0.15rem;
  padding: 0.45rem 0.8rem;
}

.lock-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
}

.lock-label {
  font-weight: 600;
}

.lock-detail {
  color: inherit;
  opacity: 0.7;
  font-size: 0.7rem;
}

/* --- Capture HUD --- */

.capture-hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
  background: linear-gradient(rgba(0,0,0,0.6), transparent);
  z-index: 10;
}

.capture-hud {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 0.75rem 1.25rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  z-index: 10;
}

.hud-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
}

.sensor-ok {
  color: var(--accent);
}

.sensor-warn {
  color: #ff9800;
}

.capture-count-badge {
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  min-width: 50px;
  text-align: center;
}

.btn-finish {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  border-radius: 20px;
  padding: 0.5rem 1rem;
}

.btn-capture {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid white;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.btn-capture:active {
  transform: scale(0.9);
}

.btn-capture-inner {
  display: block;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: white;
}

/* --- Spinner --- */

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}

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

/* --- Icons --- */

.check-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.error-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

/* --- Resume banner --- */

.error-text {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  word-break: break-all;
}

.resume-banner {
  margin-top: 2rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 12px;
  display: none;
}

.resume-banner.visible {
  display: block;
}

.resume-banner p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.resume-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
