/* ═══════════════════════════════════════════════════════════
   Wedding Camera - Minimal Light Theme
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:          #faf8f5;
  --bg2:         #f4efe8;
  --surface:     #ffffff;
  --surface2:    #f7f2ec;
  --border:      #e7ded2;
  --border2:     #efe6dc;
  --gold:        #b98456;
  --gold-light:  #d29b6d;
  --text:        #2d2926;
  --text2:       #756b61;
  --text3:       #9c9186;
  --radius:      20px;
  --radius-sm:   12px;
  --font-body:   'Inter', system-ui, sans-serif;
  --font-serif:  'Inter', system-ui, sans-serif;
  --font-script: 'Great Vibes', cursive;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

body::before { content: none; }
body > * { position: relative; z-index: 1; }

.top-border {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.5;
}

/* ── Name modal ─────────────────────────────────────────── */
#name-modal {
  position: fixed;
  inset: 0;
  background: rgba(250,248,245,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.name-modal-card {
  background: var(--surface);
  border: 1px solid rgba(201,169,110,0.2);
  border-radius: 24px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(86,63,42,.10);
}

.nm-ornament {
  font-family: var(--font-body);
  font-size: 42px;
  color: var(--gold);
  opacity: 0.6;
  line-height: 1;
  margin-bottom: 20px;
  display: block;
}

.name-modal-card p {
  font-size: 17px;
  color: var(--text);
  margin-bottom: 26px;
  line-height: 1.65;
}

.name-input {
  width: 100%;
  padding: 15px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--text);
  outline: none;
  text-align: center;
  letter-spacing: 0.03em;
  margin-bottom: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.name-input::placeholder { color: var(--text3); }
.name-input:focus { border-color: rgba(201,169,110,0.5); box-shadow: 0 0 0 3px rgba(201,169,110,0.07); }

.name-submit-btn {
  width: 100%;
  padding: 15px;
  background: var(--gold);
  border: none;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.04em;
}
.name-submit-btn:hover { background: var(--gold-light); }
.name-submit-btn:active { transform: scale(0.97); }

/* ── Header ─────────────────────────────────────────────── */
.header {
  text-align: center;
  padding: 36px 24px 18px;
  width: 100%;
}

.header h1 {
  font-family: var(--font-script);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(38px, 9vw, 58px);
  letter-spacing: 0;
  color: var(--text);
  line-height: 1.08;
}

.header .event-date {
  font-size: 15px;
  color: var(--text3);
  margin-top: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.divider {
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 14px auto;
  opacity: 0.3;
}

/* ── Container ──────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 520px;
  padding: 0 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Camera ─────────────────────────────────────────────── */
.camera-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #ece5dc;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), 0 18px 60px rgba(86,63,42,.14);
}

#video { width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: center center; }
#qr-video { width: 100%; height: 100%; object-fit: cover; display: block; }

.scanner-wrapper { margin-top: 28px; }

.scanner-guide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
  color: rgba(255,255,255,0.92);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0,0,0,.42);
}

.scanner-box {
  width: min(68%, 260px);
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.88);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(45,41,38,.22), inset 0 0 0 1px rgba(185,132,86,.55);
}

.scanner-card { padding: 28px 24px; }
.scanner-card h2 { font-size: 21px; font-weight: 600; letter-spacing: 0; }
.scanner-note { margin-top: 12px; color: var(--gold) !important; }

.viewfinder-corner {
  position: absolute;
  width: 20px; height: 20px;
  border-color: rgba(201,169,110,0.45);
  border-style: solid; border-width: 0;
  pointer-events: none; z-index: 2;
}
.vc-tl { top:14px; left:14px; border-top-width:1px; border-left-width:1px; border-radius:2px 0 0 0; }
.vc-tr { top:14px; right:14px; border-top-width:1px; border-right-width:1px; border-radius:0 2px 0 0; }
.vc-bl { bottom:14px; left:14px; border-bottom-width:1px; border-left-width:1px; border-radius:0 0 0 2px; }

.counter-badge {
  position: absolute;
  top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text2);
  font-size: 11px; font-weight: 400;
  letter-spacing: 0.12em;
  padding: 4px 14px;
  border-radius: 20px; z-index: 3;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.counter-badge .count-num { color: var(--gold); font-weight: 500; }

#flash-overlay {
  position: absolute; inset: 0;
  background: white; opacity: 0;
  pointer-events: none; z-index: 10;
  transition: opacity 0.05s;
}

.shutter-curtain {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #181512;
  color: rgba(255,255,255,0.9);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.12s ease;
}
.shutter-curtain::before,
.shutter-curtain::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  background: #0f0d0b;
  transform: scaleY(0);
  transition: transform 0.22s cubic-bezier(.65,0,.35,1);
}
.shutter-curtain::before {
  top: 0;
  transform-origin: top;
}
.shutter-curtain::after {
  bottom: 0;
  transform-origin: bottom;
}
.shutter-status {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease 0.18s, transform 0.18s ease 0.18s;
}
.shutter-status span,
.shutter-status strong {
  display: block;
  line-height: 1.15;
}
.shutter-status strong {
  color: #fff;
  font-size: 17px;
  letter-spacing: 0.04em;
}
.shutter-status i {
  display: block;
  width: 74px;
  height: 2px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  overflow: hidden;
}
.shutter-status i::after {
  content: '';
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: rgba(255,255,255,0.82);
  animation: saving-line 1.15s ease-in-out infinite;
}
.camera-wrapper.is-saving #video {
  opacity: 0;
}
.camera-wrapper.is-saving .shutter-curtain {
  opacity: 1;
}
.camera-wrapper.is-saving .shutter-curtain::before,
.camera-wrapper.is-saving .shutter-curtain::after {
  transform: scaleY(1);
}
.camera-wrapper.is-saving .shutter-status {
  opacity: 1;
  transform: translateY(0);
}
@keyframes saving-line {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(270%); }
}

.camera-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #ece5dc;
  color: var(--text3);
  gap: 14px; font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
}

.spinner {
  width: 24px; height: 24px;
  border: 1px solid rgba(201,169,110,0.1);
  border-top-color: rgba(201,169,110,0.55);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.flip-btn {
  position: absolute; bottom: 14px; right: 14px;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 4;
  transition: background 0.15s, transform 0.28s cubic-bezier(.4,0,.2,1);
  outline: none;
}
.flip-btn:active { background: var(--surface2); transform: rotate(180deg); }
.flip-btn svg { width: 18px; height: 18px; stroke: var(--text2); fill: none; }

/* ── Shutter ─────────────────────────────────────────────── */
.shutter-area {
  display: flex; align-items: center; justify-content: center;
  padding: 22px 0;
}

.shutter-btn {
  width: 86px; height: 86px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--gold);
  cursor: pointer;
  position: relative; outline: none;
  box-shadow: 0 0 0 8px rgba(185,132,86,0.08), 0 8px 30px rgba(86,63,42,.14);
  transition: transform 0.12s, box-shadow 0.12s;
}
.shutter-btn::after {
  content: '';
  width: 66px; height: 66px;
  border-radius: 50%;
  background: var(--gold);
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
}
.shutter-btn:active {
  transform: scale(0.91);
  box-shadow: 0 0 0 8px rgba(185,132,86,0.06), 0 4px 15px rgba(86,63,42,.12);
}
.shutter-btn:active::after { background: var(--gold-light); }
.shutter-btn:disabled { opacity: 0.2; cursor: not-allowed; transform: none; }
.shutter-btn.is-uploading {
  opacity: 1;
  border-color: #cfc7bd;
  box-shadow: 0 0 0 8px rgba(120,112,104,0.08), 0 8px 26px rgba(86,63,42,.12);
  animation: shutter-upload-pulse 1.15s ease-in-out infinite;
}
.shutter-btn.is-uploading::after {
  background: #d7d1c9;
}
.upload-percent {
  position: relative;
  z-index: 2;
  display: none;
  color: #5f5851;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.shutter-btn.is-uploading .upload-percent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@keyframes shutter-upload-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.94); }
}

/* ── Thumbnails ──────────────────────────────────────────── */
.thumbnails {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-top: 12px;
}
.thumb-slot {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  border: 1px solid var(--border2);
  transition: border-color 0.3s;
  position: relative;
}
.thumb-slot.filled { border-color: rgba(201,169,110,0.25); }
.thumb-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-slot .thumb-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text3);
}

/* ── Status cards ────────────────────────────────────────── */
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 28px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(86,63,42,.10);
}
.status-card .icon { font-size: 34px; margin-bottom: 16px; display: block; }
.status-card h2 {
  font-family: var(--font-body);
  font-style: normal; font-weight: 700;
  font-size: 30px; margin-bottom: 10px;
  color: var(--text); letter-spacing: 0.02em;
}
.status-card p { color: var(--text2); font-size: 16px; line-height: 1.75; }
.status-card strong { color: var(--gold); font-weight: 500; }

/* ── Upload bar ──────────────────────────────────────────── */
.upload-indicator {
  display: none; position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px; background: var(--border2);
  z-index: 5; border-radius: 0 0 22px 22px; overflow: hidden;
}
.upload-indicator.active { display: block; }
.upload-indicator::after {
  content: ''; display: block; height: 100%; width: 38%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: upload-anim 1.2s ease-in-out infinite;
}
@keyframes upload-anim { 0%{transform:translateX(-100%)} 100%{transform:translateX(370%)} }

/* ── Error screen ────────────────────────────────────────── */
.error-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%;
  min-height: 48vh;
  text-align: center; padding: 64px 24px; gap: 14px;
}
.error-screen .icon { font-size: 44px; }
.error-screen h2 { font-family: var(--font-body); font-style: normal; font-weight: 700; font-size: 30px; }
.error-screen p { color: var(--text2); font-size: 18px; max-width: 340px; line-height: 1.6; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 22px; border-radius: 30px;
  font-size: 13px; letter-spacing: 0.02em;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
  pointer-events: none; z-index: 100; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Footer ──────────────────────────────────────────────── */
.footer { width: 100%; text-align: center; padding: 20px 0 32px; margin-top: 4px; }
.footer a {
  font-size: 11px; color: var(--text3);
  text-decoration: none; letter-spacing: 0.12em;
  text-transform: uppercase; transition: color 0.15s;
}
.footer a:hover { color: var(--gold); }

canvas { display: none; }
