@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/IBMPlexMono-Regular.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #1a1714;
  --cream: #ede4d0;
  --orange: #c8703a;
  --teal: #5a9ea0;
  --gold: #c9a453;
  --text: #e8dcc8;
}

* {
  box-sizing: border-box;
}

html {
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'IBM Plex Mono', monospace;
  background-color: var(--bg);
  color: var(--text);
  background-image: url('assets/background.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Film grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Flash overlay */
#flash-overlay {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 600;
}

/* Screens — position:fixed + opacity for crossfade transitions */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 10;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  z-index: 11;
}


/* ========================
   IDLE / CAMERA SCREEN
======================== */
#idle-screen {
  cursor: pointer;
  padding: 2vh 2vw;
}

.camera-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#camera-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 1000px;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(201, 164, 83, 0.3),
    0 0 50px rgba(201, 164, 83, 0.1),
    0 16px 48px rgba(0, 0, 0, 0.7);
}

/* Camera overlay (HTML elements positioned over canvas) */
.camera-overlay {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  pointer-events: none;
  overflow: hidden;
}

/* Shot counter pill */
.shot-counter {
  position: absolute;
  top: 18px;
  left: 18px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(232, 220, 200, 0.95);
  background: rgba(20, 17, 14, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(201, 164, 83, 0.35);
  border-radius: 999px;
  padding: 6px 20px;
}

.shot-counter:empty {
  display: none;
}

/* Countdown overlay */
.countdown-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(80px, 20vmin, 200px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
}

.countdown-overlay.show {
  animation: countPop 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.countdown-overlay.smile {
  font-size: clamp(60px, 14vmin, 150px);
  color: var(--gold);
  text-shadow:
    0 0 60px rgba(201, 164, 83, 0.7),
    0 4px 20px rgba(0, 0, 0, 0.6);
}

@keyframes countPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  50%  { opacity: 1; transform: translate(-50%, -50%) scale(0.92); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Press hint */
.press-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(1.1rem, 2.5vmin, 1.6rem);
  letter-spacing: 0.1em;
  color: rgba(232, 220, 200, 0.7);
  white-space: nowrap;
  animation: breathe 3s ease-in-out infinite;
}

.press-hint.hidden {
  display: none;
}

@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 0.9; }
}

/* Peace sign progress ring */
#peace-progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  z-index: 20;
  display: none;
  pointer-events: none;
}

#peace-progress.visible {
  display: block;
}

#peace-ring {
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.1s linear;
}

/* Static idle text (shown before camera starts) */
#idle-text {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(2rem, 5vmin, 4rem);
  letter-spacing: 0.1em;
  opacity: 0.7;
  text-align: center;
  pointer-events: none;
  animation: breathe 3s ease-in-out infinite;
  margin: 0;
  white-space: nowrap;
}

/* ========================
   TEMPLATE SELECTION SCREEN
======================== */
#template-screen {
  flex-direction: column;
  padding-bottom: 8vh;
  gap: 20px;
}

.template-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.template-layout h2 {
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 600;
  letter-spacing: 0.05em;
  margin: 0;
  color: var(--cream);
  text-transform: uppercase;
}

.template-layout h2 span {
  display: block;
  font-size: 0.52em;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.05em;
  opacity: 0.55;
  margin-top: 6px;
  text-transform: none;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  justify-content: center;
  gap: 28px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px;
}

.template-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.template-item-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.template-item:hover .template-item-card {
  transform: scale(1.04);
  box-shadow: 0 8px 32px rgba(201, 164, 83, 0.2), 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: rgba(201, 164, 83, 0.3);
}

.template-item-card canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.template-number {
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: rgba(232, 220, 200, 0.7);
  font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap;
  text-align: center;
}

.template-item.selected .template-item-card {
  transform: scale(1.06);
  box-shadow:
    0 0 0 2px var(--gold),
    0 12px 40px rgba(201, 164, 83, 0.3);
  border-color: var(--gold);
}

.template-item.selected .template-number {
  color: var(--gold);
}

/* Confirm button */
#confirm-btn {
  display: none;
  padding: 12px 44px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: 999px;
  border: 2px solid var(--gold);
  background: rgba(201, 164, 83, 0.25);
  color: var(--cream);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  text-transform: uppercase;
  box-shadow: 0 0 20px rgba(201, 164, 83, 0.2), 0 4px 12px rgba(0, 0, 0, 0.3);
}

#confirm-btn:hover {
  background: rgba(201, 164, 83, 0.4);
  box-shadow: 0 0 32px rgba(201, 164, 83, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: scale(1.05);
}

#confirm-btn.visible {
  display: inline-block;
}

/* ========================
   RESULT SCREEN
======================== */
#result-screen {
  align-items: center;
  justify-content: center;
}

.result-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  max-width: 90vw;
}

.result-photo-wrap {
  max-height: 80vh;
}

#photo-canvas {
  max-height: 80vh;
  max-width: 38vw;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(201, 164, 83, 0.2),
    0 16px 48px rgba(0, 0, 0, 0.7);
}

/* Landscape template: constrain photo but keep side-by-side */
.result-layout.landscape #photo-canvas {
  max-width: 55vw;
  max-height: 75vh;
}

.result-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* QR card */
.qr-card {
  background: rgba(26, 23, 20, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(201, 164, 83, 0.2);
  border-radius: 20px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#scan-to-download-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  font-style: italic;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.7;
  margin: 0;
}

#qr-img {
  width: 220px;
  height: 220px;
  border-radius: 10px;
  display: block;
}

/* Start Over + countdown */
.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

/* Start Over button */
#back-btn {
  padding: 12px 40px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: 999px;
  border: 2px solid var(--orange);
  background: rgba(200, 112, 58, 0.25);
  color: var(--cream);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  text-transform: uppercase;
  box-shadow: 0 0 20px rgba(200, 112, 58, 0.2), 0 4px 12px rgba(0, 0, 0, 0.3);
}

#back-btn:hover {
  background: rgba(200, 112, 58, 0.4);
  box-shadow: 0 0 32px rgba(200, 112, 58, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: scale(1.05);
}

/* Reset countdown label + bar */
.reset-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#reset-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.4;
}

/* Auto-reset progress bar */
.reset-bar-wrap {
  width: 200px;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

#reset-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, var(--teal), var(--gold));
  border-radius: 999px;
  transform-origin: left;
}

/* ========================
   RESET SESSION BUTTON
======================== */
.reset-session-btn {
  padding: 10px 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 2px solid rgba(200, 112, 58, 0.6);
  background: rgba(200, 112, 58, 0.15);
  color: var(--cream);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 0 16px rgba(200, 112, 58, 0.15), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.reset-session-btn:hover {
  background: rgba(200, 112, 58, 0.35);
  box-shadow: 0 0 28px rgba(200, 112, 58, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: scale(1.05);
}

/* Reset button overlaid on camera screen (top-left) */
#reset-btn {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 20;
}

/* Template screen action row */
.template-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}

/* ========================
   INSTRUCTION POPUP
======================== */
.info-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(201, 164, 83, 0.35);
  background: rgba(20, 17, 14, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--cream);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
  font-style: italic;
  font-weight: 700;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
}

.info-btn:hover {
  background: rgba(201, 164, 83, 0.25);
  box-shadow: 0 0 16px rgba(201, 164, 83, 0.3);
}

/* Offline upload queue depth badge (bottom-left of idle screen) */
.queue-badge {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(201, 164, 83, 0.35);
  background: rgba(20, 17, 14, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--cream);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.queue-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}

.queue-badge.hidden {
  display: none;
}

.instruction-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.instruction-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.instruction-card {
  background: rgba(26, 23, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(201, 164, 83, 0.25);
  border-radius: 20px;
  padding: 36px 40px;
  max-width: 520px;
  width: 85%;
  text-align: left;
}

.instruction-card h2 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 20px 0;
  text-align: center;
}

.instruction-card ol {
  list-style: none;
  counter-reset: rules;
  padding: 0;
  margin: 0 0 20px 0;
}

.instruction-card ol li {
  counter-increment: rules;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--cream);
  margin-bottom: 12px;
  padding-left: 32px;
  position: relative;
}

.instruction-card ol li::before {
  content: counter(rules) ".";
  position: absolute;
  left: 0;
  color: var(--gold);
  font-weight: 700;
}

.instruction-disclaimer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--orange);
  text-align: center;
  margin: 0 0 24px 0;
  opacity: 0.9;
}

.instruction-close-btn {
  display: block;
  margin: 0 auto;
  padding: 10px 36px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: 999px;
  border: 2px solid var(--gold);
  background: rgba(201, 164, 83, 0.25);
  color: var(--cream);
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s, box-shadow 0.2s;
}

.instruction-close-btn:hover {
  background: rgba(201, 164, 83, 0.4);
  box-shadow: 0 0 20px rgba(201, 164, 83, 0.3);
}

/* Error overlay (camera / config failures with auto-retry) */
.error-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 700; /* above flash-overlay (600) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.error-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.error-card {
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--cream);
  padding: 40px;
  max-width: 480px;
}

.error-icon {
  font-size: 56px;
  margin-bottom: 16px;
  color: var(--gold);
}

.error-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.error-msg {
  font-size: 0.9rem;
  color: rgba(247, 242, 213, 0.6);
  margin-bottom: 24px;
  line-height: 1.6;
}

.error-retry-label {
  font-size: 0.8rem;
  color: rgba(247, 242, 213, 0.4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Landscape tablet adjustments */
@media (max-height: 800px) and (orientation: landscape) {
  .template-layout h2 {
    font-size: 1.6rem;
  }
  .template-grid {
    gap: 12px;
  }
}

/* ========================
   LANDING SCREEN
======================== */
.landing-screen[hidden] {
  display: none;
}

.landing-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  overflow-y: auto;
  z-index: 20;
  padding: 40px 20px;
}

.landing-card {
  width: 100%;
  max-width: 520px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
}

.landing-heading {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--orange);
  margin: 0 0 12px;
  text-transform: uppercase;
}

.landing-tagline {
  font-size: 0.9rem;
  line-height: 1.6;
  opacity: 0.8;
  margin: 0 0 20px;
}

.landing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.landing-features li {
  font-size: 0.82rem;
  opacity: 0.7;
  padding-left: 1.2em;
  position: relative;
}

.landing-features li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--orange);
  opacity: 0.8;
}

.landing-demo-btn {
  display: inline-block;
  background: var(--orange);
  border-radius: 6px;
  color: var(--bg);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 28px;
  margin: 0 0 36px;
  text-decoration: none;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

.landing-demo-btn:hover {
  opacity: 0.85;
}

.landing-form-wrap {
  border-top: 1px solid rgba(200, 112, 58, 0.25);
  padding-top: 28px;
}

.landing-form-heading {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 18px;
}

#inquiry-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#inquiry-form input,
#inquiry-form textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(200, 112, 58, 0.3);
  border-radius: 6px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

#inquiry-form input:focus,
#inquiry-form textarea:focus {
  border-color: var(--orange);
}

#inquiry-form input::placeholder,
#inquiry-form textarea::placeholder {
  opacity: 0.45;
  color: var(--text);
}

#inquiry-form textarea {
  min-height: 120px;
  resize: vertical;
}

#inquiry-form button[type=submit] {
  align-self: flex-start;
  background: var(--orange);
  border: none;
  border-radius: 6px;
  color: var(--bg);
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 10px 24px;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

#inquiry-form button[type=submit]:hover {
  opacity: 0.85;
}

#inquiry-form button[type=submit]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#landing-form-status {
  margin-top: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.landing-form-success {
  color: var(--teal);
}

.landing-form-error {
  color: #e07060;
}
