/* ── Mipozy · Kawaii Beige Theme ────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --bg:          #f5ece0;          /* warm linen */
  --bg-check:    #e8d9c8;          /* checkerboard square */
  --surface:     #fdf6ee;          /* card surface */
  --surface-2:   #ecddc9;          /* slightly darker surface */
  --brown:       #b07d5a;          /* warm brown accent */
  --brown-dark:  #7a5440;          /* deep brown */
  --pink:        #e8918a;          /* soft coral pink */
  --pink-light:  #f7d5d0;
  --text:        #5c3d2e;          /* warm dark brown text */
  --text-muted:  #a07a65;
  --radius-card: 28px;
  --radius-btn:  999px;
  --shadow:      0 4px 20px rgba(120,80,50,.13);
  --shadow-sm:   0 2px 8px  rgba(120,80,50,.10);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* prevents display:flex/grid from overriding the hidden attribute */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  /* subtle checkerboard like the phone wallpaper */
  background-image:
    repeating-conic-gradient(var(--bg-check) 0% 25%, transparent 0% 50%);
  background-size: 40px 40px;
  color: var(--text);
  font-family: 'Nunito', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ────────────────────────────────────────────── */
.camera-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
}

/* ── Viewport / Viewfinder ────────────────────────────────── */
.viewport {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: calc(100vh - 200px);
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-card) - 3px);
}

/* flip button */
.overlay { position: absolute; top: 14px; right: 14px; }

.btn-icon {
  background: rgba(253,246,238,.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #fff;
  color: var(--brown-dark);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-icon:hover  { transform: scale(1.06); box-shadow: var(--shadow); }
.btn-icon:active { transform: scale(.96); }

/* ref overlay */
.ref-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

/* ── Bottom Bar ───────────────────────────────────────────── */
.bottom-bar {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: 18px 20px 30px;
  box-shadow: 0 -4px 24px rgba(120,80,50,.10);
  border-top: 3px solid #fff;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Controls ─────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

/* main capture button */
.btn-capture {
  background: var(--pink);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 16px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(232,145,138,.40);
  transition: transform .15s ease, box-shadow .15s ease;
  letter-spacing: .3px;
}
.btn-capture:hover  { transform: scale(1.05); box-shadow: 0 6px 20px rgba(232,145,138,.55); }
.btn-capture:active { transform: scale(.97); }

/* secondary button */
.btn-secondary {
  background: var(--surface-2);
  color: var(--brown-dark);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 22px;
  border: 2px solid #fff;
  border-radius: var(--radius-btn);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, background .15s ease;
}
.btn-secondary:hover  { background: var(--pink-light); transform: scale(1.04); }
.btn-secondary:active { transform: scale(.96); }

/* hidden download link styled if ever shown */
#downloadLink {
  display: inline-block;
  background: var(--brown);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
#downloadLink:hover { transform: scale(1.04); }

/* ── Reference Controls ───────────────────────────────────── */
.ref-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.btn-ref-upload {
  display: inline-block;
  background: var(--pink-light);
  border: 2px dashed var(--pink);
  color: var(--pink);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: 16px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.btn-ref-upload:hover { background: #f5c5c0; transform: scale(1.03); }

/* opacity row */
.opacity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  background: var(--surface-2);
  padding: 10px 16px;
  border-radius: 16px;
  border: 2px solid #fff;
}

.opacity-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.opacity-row input[type=range] {
  flex: 1;
  accent-color: var(--pink);
  height: 4px;
  cursor: pointer;
}

/* ghost / remove button */
.btn-ghost {
  background: none;
  border: 2px solid var(--brown);
  color: var(--brown);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: var(--brown); color: #fff; }

/* ── Desktop tweak ────────────────────────────────────────── */
@media (min-width: 700px) {
  .viewport {
    height: 60vh;
    width: 500px;
  }
}
/* ── Timer Selector Row ───────────────────────────────────── */
.timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  align-self: center;
  background: var(--surface-2);
  padding: 10px 16px;
  border-radius: 16px;
  border: 2px solid #fff;
}

.timer-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.timer-options {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}

.btn-timer {
  background: var(--surface);
  color: var(--brown-dark);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 13px;
  border: 2px solid transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
}
.btn-timer:hover {
  background: var(--pink-light);
  border-color: var(--pink);
  transform: scale(1.06);
}
.btn-timer.active {
  background: var(--pink);
  color: #fff;
  border-color: var(--pink);
  box-shadow: 0 3px 10px rgba(232,145,138,.45);
}

/* ── Countdown Overlay ────────────────────────────────────── */
/* NO backdrop-filter/blur — keeps the camera feed sharp */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* semi-transparent tint only, zero blur */
  background: rgba(92, 61, 46, 0.18);
  border-radius: calc(var(--radius-card) - 3px);
  z-index: 5;          /* below .overlay (z-index auto / stacking order) */
  pointer-events: none; /* clicks pass through to buttons beneath */
}

.countdown-number {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(80px, 22vw, 140px);
  color: #fff;
  text-shadow:
    0 0 40px rgba(232,145,138,.9),
    0 4px 20px rgba(92,61,46,.4);
}

/* ✕ button to cancel the countdown */
.btn-cancel-countdown {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(253,246,238,.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #fff;
  color: var(--brown-dark);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, background .15s ease;
  pointer-events: auto; /* The rest of the overlay has pointer-events: none */
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-cancel-countdown:hover  { transform: scale(1.1); background: var(--pink-light); }
.btn-cancel-countdown:active { transform: scale(.95); }

/* Each tick: number pops in then shrinks out */
@keyframes pop {
  0%   { transform: scale(1.5); opacity: 0; }
  25%  { transform: scale(1);   opacity: 1; }
  80%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.7); opacity: 0; }
}
.countdown-number.tick {
  animation: pop 0.95s ease forwards;
}

/* Gentle pink pulse on the viewport border while counting */
.viewport.counting {
  animation: pulse-border 1s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { box-shadow: var(--shadow); }
  50%       { box-shadow: var(--shadow), 0 0 0 5px rgba(232,145,138,.3); }
}

/* White flash on capture */
.viewport.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: calc(var(--radius-card) - 3px);
  opacity: 0;
  animation: shutter-flash .35s ease forwards;
  pointer-events: none;
  z-index: 20;
}
@keyframes shutter-flash {
  0%   { opacity: .8; }
  100% { opacity: 0;  }
}

/* Capture button disabled state during countdown */
.btn-capture:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

/* toast notification */
.pao-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-btn);
  border: 2px solid var(--pink-light);
  box-shadow: 0 8px 28px rgba(120,80,50,.18);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}

.pao-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}