/* ═══════════════════════════════════════════════════════════
   PHOTOSLOP — Style
   Aesthetic: carnival booth meets broken vending machine
═══════════════════════════════════════════════════════════ */

/* ─── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #080608;
  --bg-2:        #110e12;
  --accent:      #e8ff00;       /* electric yellow */
  --accent-2:    #ff2d78;       /* hot magenta */
  --accent-3:    #00f0c8;       /* cyan-mint */
  --text:        #f0ead6;
  --text-dim:    #7a6f6a;
  --font-display: 'Bebas Neue', 'Impact', sans-serif;
  --font-mono:   'Share Tech Mono', 'Courier New', monospace;
  --history-h:   88px;
  --border:      1px solid rgba(232, 255, 0, 0.18);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
}

/* ─── SCREENS ───────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  bottom: var(--history-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
}

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

/* ─── SHARED HEADER ─────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  background: var(--bg);
  border-bottom: var(--border);
  flex-shrink: 0;
  gap: 10px;
  flex-wrap: wrap;
}

.app-title {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(232, 255, 0, 0.5), 2px 2px 0 var(--accent-2);
  line-height: 1;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── VIEWFINDER SCREEN ─────────────────────────────────── */
.viewfinder-frame {
  aspect-ratio: 1 / 1;
  width: min(100%, calc(100vh - 220px));
  align-self: center;
  position: relative;
  overflow: hidden;
  background: #000;
  flex-shrink: 1;
  min-height: 0;
}

#camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: blur(20px) saturate(1.5) brightness(0.9);
  transform: scale(1.05); /* hide blur edge artifacts */
}

.viewfinder-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Corner brackets */
.corner {
  position: absolute;
  width: 28px;
  height: 28px;
}
.corner.tl { top: 16px; left: 16px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.corner.tr { top: 16px; right: 16px; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.corner.bl { bottom: 16px; left: 16px; border-bottom: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.corner.br { bottom: 16px; right: 16px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); }

.face-status {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.capture-zone {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-top: var(--border);
  flex-shrink: 0;
}

/* ─── WELCOME PANEL ─────────────────────────────────────── */
.welcome-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px 32px;
  text-align: center;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(232, 255, 0, 0.4), 2px 2px 0 var(--accent-2);
  line-height: 1.1;
}

.welcome-steps {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 2;
  list-style: none;
  padding: 0;
  counter-reset: steps;
}

.welcome-steps li {
  counter-increment: steps;
}

.welcome-steps li::before {
  content: counter(steps) ". ";
  color: var(--accent-3);
  font-weight: bold;
}

.welcome-steps em {
  font-style: normal;
  color: var(--text-dim);
}

/* ─── CAPTURE BUTTON ────────────────────────────────────── */
.btn-capture {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 14px 48px;
  cursor: pointer;
  position: relative;
  clip-path: polygon(6px 0%, calc(100% - 6px) 0%, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0% calc(100% - 6px), 0% 6px);
  transition: background 0.1s, transform 0.1s;
  min-height: 64px;
  touch-action: manipulation;
}
.btn-capture:hover {
  background: #fff;
}
.btn-capture:active {
  transform: scale(0.96);
  background: var(--accent-2);
  color: #fff;
}

/* ─── PRIVACY NOTICE ────────────────────────────────────── */
.privacy-notice {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.04em;
  line-height: 1.5;
  max-width: 420px;
}

/* ─── CAMERA PICKER ─────────────────────────────────────── */
.camera-picker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg-2);
  color: var(--text);
  border: var(--border);
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
  max-width: 160px;
}
.camera-picker:focus {
  border-color: var(--accent);
}

/* ─── DEBUG CONTROLS ────────────────────────────────────── */
.debug-select {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: #1a0a00;
  color: #ff9500;
  border: 1px solid #ff9500;
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
  width: 100%;
  max-width: 420px;
  margin-top: 6px;
}
.debug-select:focus {
  border-color: #ffb84d;
}

/* ─── PROCESSING SCREEN ─────────────────────────────────── */
.processing-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-2);
  letter-spacing: 0.12em;
  animation: blink 1.1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.processing-frame {
  aspect-ratio: 1 / 1;
  width: min(100%, calc(100vh - 220px));
  align-self: center;
  position: relative;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.blurred-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: blur(22px) saturate(1.3) brightness(0.8);
  transform: scale(1.06);
}

.processing-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.effect-reveal {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-align: center;
  padding: 10px 20px;
  background: rgba(8, 6, 8, 0.65);
  border: 1px solid rgba(232, 255, 0, 0.3);
  text-shadow: 0 0 12px rgba(232, 255, 0, 0.6);
  max-width: 80vw;
  word-break: break-word;
  opacity: 0;
  transition: opacity 0.5s ease 0.3s;
}
.effect-reveal.visible {
  opacity: 1;
}

.loading-zone {
  padding: 14px 20px 18px;
  background: var(--bg);
  border-top: var(--border);
  flex-shrink: 0;
}

.loading-bar-track {
  width: 100%;
  height: 26px;
  background: var(--bg-2);
  border: 1px solid rgba(232, 255, 0, 0.25);
  position: relative;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 60%, #fff 100%);
  position: relative;
  box-shadow: 0 0 14px rgba(232, 255, 0, 0.6);
  transition: none; /* JS drives width directly; finish() overrides this */
}

.loading-bar-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  pointer-events: none;
}

.loading-status-text {
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

/* ─── RESULT SCREEN ─────────────────────────────────────── */
.result-image-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

.result-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.result-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  pointer-events: none;
}

.result-face-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-3);
  margin-top: 5px;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.result-effect-label {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  background: rgba(8, 6, 8, 0.7);
  padding: 5px 12px;
  border-left: 3px solid var(--accent);
  text-shadow: 0 0 10px rgba(232, 255, 0, 0.5);
  backdrop-filter: blur(4px);
}

.result-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-top: var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ─── ACTION BUTTONS ─────────────────────────────────────── */
.btn-action {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  flex: 1;
  min-width: 100px;
  min-height: 48px;
  touch-action: manipulation;
  transition: opacity 0.12s, transform 0.1s;
}
.btn-action:active {
  transform: scale(0.96);
  opacity: 0.8;
}

.btn-save {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.18);
}
.btn-save:hover { color: var(--text); border-color: rgba(255,255,255,0.4); }

.btn-reroll {
  background: var(--bg-2);
  color: var(--accent-3);
  border: 1px solid rgba(0, 240, 200, 0.3);
}
.btn-reroll:hover { border-color: var(--accent-3); }
.btn-reroll:disabled { opacity: 0.3; pointer-events: none; }

.btn-retake {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0 20px;
  cursor: pointer;
  flex-shrink: 0;
  height: 100%;
  min-width: 100px;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.1s;
  clip-path: polygon(4px 0%, calc(100% - 4px) 0%, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0% calc(100% - 4px), 0% 4px);
}
.btn-retake:hover { background: #fff; }
.btn-retake:active { transform: scale(0.96); background: var(--accent-2); color: #fff; }

.btn-thumbs {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  flex: 0;
  min-width: 52px;
  font-size: 1.4rem;
  padding: 8px 12px;
}
.btn-thumbs:hover { border-color: var(--accent); }
.btn-thumbs.selected {
  border-color: var(--accent-3);
  background: rgba(0, 240, 200, 0.1);
}
.btn-thumbs:disabled { opacity: 0.5; pointer-events: none; }

.btn-additional-feedback {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.12);
  flex: 1;
  min-width: 140px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
.btn-additional-feedback:hover { color: var(--accent-2); border-color: var(--accent-2); }
.btn-additional-feedback:disabled { opacity: 0.4; pointer-events: none; }

/* ─── GHOST BUTTON (header) ─────────────────────────────── */
.btn-ghost {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 6px 12px;
  cursor: pointer;
  min-height: 34px;
  touch-action: manipulation;
  transition: color 0.12s, border-color 0.12s;
}
.btn-ghost:hover { color: var(--accent-3); border-color: var(--accent-3); }

/* ─── HISTORY STRIP ─────────────────────────────────────── */
.history-strip {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--history-h);
  background: rgba(8, 6, 8, 0.92);
  border-top: var(--border);
  z-index: 100;
  backdrop-filter: blur(6px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.history-thumbs {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 8px 10px;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}

.history-thumbs::-webkit-scrollbar {
  height: 3px;
}
.history-thumbs::-webkit-scrollbar-thumb {
  background: var(--text-dim);
}

.history-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  scroll-snap-align: start;
  transition: border-color 0.15s, transform 0.12s;
  opacity: 0.8;
}
.history-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.06);
  opacity: 1;
}
.history-thumb.active {
  border-color: var(--accent-2);
  opacity: 1;
}

.history-empty {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  white-space: nowrap;
  padding: 0 8px;
}

/* ─── MODALS ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 8, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(6px);
  padding: 20px;
}
.modal.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-2);
  border: 1px solid rgba(232, 255, 0, 0.3);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  line-height: 1;
}

.modal-subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

.feedback-photo-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: #000;
  display: block;
}

.modal-privacy-notice {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  line-height: 1.5;
  border-left: 2px solid var(--accent-2);
  padding-left: 8px;
}

.modal-textarea {
  background: var(--bg);
  color: var(--text);
  border: var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.modal-textarea:focus {
  border-color: var(--accent);
}
.modal-textarea::placeholder {
  color: var(--text-dim);
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  flex: 1;
  min-height: 48px;
  touch-action: manipulation;
  transition: background 0.12s, transform 0.1s;
}
.btn-primary:hover { background: #fff; }
.btn-primary:active { transform: scale(0.96); }

.btn-ghost-modal {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.12);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 48px;
  touch-action: manipulation;
  transition: color 0.12s;
}
.btn-ghost-modal:hover { color: var(--text); }

/* ─── ERROR TOAST ─────────────────────────────────────────── */
.error-toast {
  position: fixed;
  bottom: calc(var(--history-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent-2);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 10px 20px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw;
  text-align: center;
  white-space: pre-wrap;
}
.error-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── SUCCESS TOAST ───────────────────────────────────────── */
.success-toast {
  position: fixed;
  bottom: calc(var(--history-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent-3);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 10px 20px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw;
  text-align: center;
}
.success-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── LOADING / INIT STATE ────────────────────────────────── */
.init-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 400;
  gap: 18px;
  transition: opacity 0.5s ease;
}
.init-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.init-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(232, 255, 0, 0.5), 3px 3px 0 var(--accent-2);
  letter-spacing: 0.1em;
}
.init-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: blink 1s step-end infinite;
}

/* ─── MOBILE / RESPONSIVE ────────────────────────────────── */
@media (max-width: 480px) {
  .app-title { font-size: 1.6rem; }
  .btn-capture { font-size: 1.8rem; padding: 12px 32px; }
  .result-actions { gap: 6px; }
  .btn-action { font-size: 0.95rem; padding: 8px 12px; }
  .modal-box { padding: 20px 16px 16px; }
}

@media (max-height: 600px) {
  .screen-header { padding: 6px 12px; }
  .app-title { font-size: 1.4rem; }
  .capture-zone { padding: 10px 16px; }
  .loading-zone { padding: 10px 16px 12px; }
}
