/* Prime Founders' Day — Photo Finder
   Design tokens mirror portfolio.primevp.in:
   cream + ink + orange, Fraunces serif headlines, Geist sans body. */
:root {
  --bg: #FAF6EF;
  --bg-2: #F1EBDF;
  --ink: #0E0E0E;
  --ink-2: #2A2A2A;
  --muted: #6B6258;
  --line: #E3DACA;
  --line-2: #D6CBB6;
  --orange: #FF5A1F;
  --orange-2: #E8480F;
  --orange-soft: #FFE9DD;

  --font-display: "Fraunces", "Tiempos Headline", Georgia, serif;
  --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
/* Honour the HTML hidden attribute even when an element also has display: grid/flex. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(255,90,31,0.06), transparent 60%),
    var(--bg);
}

/* ── Brand mark ─────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}
.brand-text {
  display: flex; flex-direction: column; line-height: 1;
}
.brand-text .b1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.012em;
}
.brand-text .b2 {
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
}

/* ── Login card ─────────────────────────────────────── */
.gate-card {
  width: min(460px, calc(100% - 32px));
  padding: 40px 38px 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(14,14,14,0.06);
  position: relative;
}
.gate-logo {
  width: 60px;
  height: auto;
  display: block;
  margin: 0 0 18px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.gate-card h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 38px;
  letter-spacing: -0.028em;
  line-height: 1.04;
  margin: 0 0 12px;
}
.gate-card h1 em { font-style: italic; color: var(--orange); }
.gate-card .lead {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 26px;
}
.gate-card form { display: grid; gap: 12px; }
.input-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.gate-card input[type=password] {
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
}
.gate-card input[type=password]:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
  background: #fff;
}
.btn-block { width: 100%; }
.err {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--orange-soft);
  border: 1px solid var(--orange);
  border-radius: 10px;
  color: var(--orange-2);
  font-size: 13px;
}
.footnote {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Buttons ────────────────────────────────────────── */
.btn-orange,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-orange {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.btn-orange:hover:not(:disabled) {
  background: var(--orange-2);
  border-color: var(--orange-2);
}
.btn-orange:disabled,
.btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ── Top bar ────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 246, 239, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.topbar form { margin: 0; }

/* ── Container & hero ────────────────────────────────── */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 28px 60px;
  text-align: center;
}
.hero { margin-bottom: 36px; }
.hero .eyebrow { margin-bottom: 14px; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(36px, 4.6vw, 60px);
  letter-spacing: -0.032em;
  line-height: 1.04;
  margin: 0 auto 18px;
  max-width: 880px;
}
.hero h1 em { font-style: italic; color: var(--orange); }
.hero .sub {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  max-width: 620px;
  margin: 0 auto;
}

/* ── Uploader ───────────────────────────────────────── */
.uploader {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-width: 620px;
  margin: 0 auto;
  justify-items: center;
}
.upload-tabs {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  margin: 0 auto 4px;
}
.upload-tabs button {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
}
.upload-tabs button.active {
  background: var(--ink);
  color: #fff;
}
.tab-panel { display: none; width: 100%; }
.tab-panel.active { display: block; }

.drop {
  display: block;
  border: 2px dashed var(--line-2);
  border-radius: 18px;
  background: #fff;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.drop:hover, .drop.is-dragover {
  border-color: var(--orange);
  background: #fff8f4;
  transform: translateY(-1px);
}
.drop strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
}
.drop small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 12.5px;
}
.drop-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--orange-soft);
  color: var(--orange);
  display: grid; place-items: center;
  margin: 0 auto 12px;
}

.camera-stage {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.camera-stage video,
.camera-stage canvas {
  width: 100%;
  border-radius: 14px;
  background: #111;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.camera-stage canvas { display: none; }
/* Mirror only when a live stream is attached (added by JS once getUserMedia
   resolves). This prevents any browser-default play overlay from showing up
   flipped on the idle <video> element. */
.camera-stage video.is-mirrored,
.camera-stage canvas.is-mirrored {
  transform: scaleX(-1);
}
.camera-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.camera-stage .hint {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  margin: 2px 0 0;
}

.preview {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.preview img {
  width: 56px; height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-2);
}
.preview .meta { font-size: 13px; color: var(--ink-2); }
.preview .meta b { font-weight: 500; display: block; }
.preview .meta small { color: var(--muted); }

/* ── Selfie chip strip + mode toggle ─────────────────── */
.selfie-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.selfie-list-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.selfie-list-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.selfie-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.selfie-chip {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.selfie-chip img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.selfie-chip-x {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(14, 14, 14, 0.78);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background .15s ease;
}
.selfie-chip-x:hover { background: var(--orange); }

.mode-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.mode-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.mode-toggle {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.mode-toggle .mode-btn {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.mode-toggle .mode-btn.active {
  background: var(--ink);
  color: #fff;
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

/* ── Privacy note ───────────────────────────────────── */
.privacy-note {
  margin: 18px auto 0;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 620px;
  text-align: left;
}
.privacy-note svg { flex-shrink: 0; color: var(--orange); margin-top: 1px; }
.privacy-note b { color: var(--ink-2); font-weight: 600; }

/* ── Status / spinner ───────────────────────────────── */
.status {
  margin: 28px auto 0;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 620px;
}
.status .spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line-2);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ────────────────────────────────────────── */
.results { margin-top: 44px; }
.results-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  text-align: center;
}
.count-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0;
}
.count-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
  margin: 6px 0 0;
}
.count-title em { font-style: italic; color: var(--orange); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  transition: border-color .15s, transform .15s, box-shadow .15s;
  text-decoration: none;
  color: inherit;
}
.tile:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(14,14,14,0.08);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .dl-btn {
  position: absolute;
  top: 9px; right: 9px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(14,14,14,0.72);
  color: #fff;
  border: none;
  cursor: pointer;
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.tile:hover .dl-btn,
.tile:focus-within .dl-btn { opacity: 1; }
.tile .dl-btn:hover { background: var(--orange); }
.tile .dl-btn:focus { opacity: 1; outline: 2px solid var(--orange); outline-offset: 2px; }
.tile .score {
  position: absolute;
  left: 9px; bottom: 9px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(14,14,14,0.72);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.empty-state {
  margin: 32px 0;
  padding: 36px 28px;
  background: #fff;
  border: 1px dashed var(--line-2);
  border-radius: 18px;
  text-align: center;
}
.empty-state h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.018em;
  margin: 0 0 8px;
}
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 460px;
  margin-inline: auto;
}

.footnote-bar {
  border-top: 1px solid var(--line);
  padding: 22px 28px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .brand-logo { height: 30px; }
  .brand-text .b1 { font-size: 14px; }
  .brand-text .b2 { font-size: 9px; }
}
@media (max-width: 600px) {
  .container { padding: 28px 16px 60px; }
  .gate-card { padding: 30px 24px 24px; border-radius: 18px; }
  .gate-card h1 { font-size: 30px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .tile .dl-btn { opacity: 1; width: 30px; height: 30px; top: 6px; right: 6px; }
  .tile .score { font-size: 9.5px; bottom: 6px; left: 6px; }
}
