/* ==========================================================================
   Event Gallery — design tokens (Vietnamese & Low-Tech Accessible)
   ========================================================================== */
:root {
  --bg: hsl(228 18% 5%);
  --bg-2: hsl(228 16% 8%);
  --surface: hsl(228 14% 13% / 0.85);
  --surface-solid: hsl(228 14% 12%);
  --border: hsl(228 20% 90% / 0.11);
  --text: hsl(40 20% 97%);
  --muted: hsl(228 10% 72%);
  --accent: hsl(36 92% 66%);
  --accent-2: hsl(340 82% 70%);
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --radius: 14px;
  --gap: 4px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Be Vietnam Pro", var(--font);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  min-height: 28vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
}
.hero-bg {
  position: absolute; inset: -20px;
  background: radial-gradient(120% 90% at 20% 10%, hsl(36 60% 30% / .55), transparent 60%),
              radial-gradient(90% 90% at 90% 20%, hsl(340 55% 30% / .5), transparent 60%), var(--bg-2);
  background-size: cover; background-position: center;
  filter: saturate(1.1);
  transform: scale(1.06);
  transition: opacity .8s var(--ease), transform 8s var(--ease);
  z-index: -2;
}
.hero-bg.has-img { filter: blur(2px) saturate(1.15) brightness(.58); transform: scale(1.02); }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 15%, hsl(228 18% 5% / .78) 70%, var(--bg) 100%);
}
.hero-inner { padding: 26px 20px 16px; width: 100%; max-width: 1400px; margin: 0 auto; animation: rise .7s var(--ease) both; }
.eyebrow {
  margin: 0 0 6px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero h1 {
  margin: 0; font: 700 clamp(26px, 6.5vw, 50px)/1.12 var(--display); letter-spacing: -.01em;
}
.hero-desc { margin: 6px 0 0; font-size: 15px; color: var(--text); opacity: .92; }
.hero-meta { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ==========================================================================
   Face bar & Folder Tabs
   ========================================================================== */
.faces {
  position: sticky; top: 0; z-index: 20;
  padding: 12px 0 10px;
  background: hsl(228 18% 5% / .88);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.faces-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 0 16px 8px; max-width: 1400px; margin: 0 auto;
}
.faces-head h2 { margin: 0; font: 600 15px var(--display); }
.faces-actions { display: flex; align-items: center; gap: 10px; }

.selfie-pill-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700;
  background: var(--grad); color: #1a1206;
  box-shadow: 0 4px 16px hsl(340 80% 60% / .3);
  transition: transform .15s var(--ease), filter .2s;
}
.selfie-pill-btn svg { width: 17px; height: 17px; stroke-width: 2.2; }
.selfie-pill-btn:hover { filter: brightness(1.06); }
.selfie-pill-btn:active { transform: scale(.96); }

.faces-strip {
  display: flex; gap: 12px; overflow-x: auto; overscroll-behavior-x: contain;
  padding: 4px 16px 6px; max-width: 1400px; margin: 0 auto;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.faces-strip::-webkit-scrollbar { display: none; }
.faces.expanded .faces-strip {
  flex-wrap: wrap; max-height: 48vh; overflow-y: auto; justify-content: flex-start;
}
.face {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 72px; scroll-snap-align: start;
  animation: pop .4s var(--ease) both;
}
.face-ring {
  position: relative; width: 66px; height: 66px; border-radius: 50%;
  padding: 2.5px; background: var(--border);
  transition: transform .22s var(--ease), background .22s;
}
.face img, .face .all-icon {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  border: 2px solid var(--bg); background: var(--surface-solid);
}
.face .all-icon { display: grid; place-items: center; color: var(--text); }
.face-count {
  font-size: 12px; color: var(--muted); font-weight: 500;
  max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.face:hover .face-ring { transform: translateY(-2px); }
.face:active .face-ring { transform: scale(.94); }
.face[aria-selected="true"] .face-ring {
  background: var(--grad);
  box-shadow: 0 6px 22px hsl(340 80% 60% / .4);
  transform: scale(1.05);
}
.face[aria-selected="true"] .face-count { color: var(--accent); font-weight: 700; }

.faces-expand-wrap {
  display: flex; justify-content: center;
  padding: 4px 16px 2px; max-width: 1400px; margin: 0 auto;
}
.faces-expand-btn {
  padding: 6px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--accent);
  background: hsl(36 92% 66% / .12); border: 1px solid hsl(36 92% 66% / .28);
  transition: background .15s;
}
.faces-expand-btn:hover { background: hsl(36 92% 66% / .2); }

/* Folder / Album Filter Tabs */
.folders-bar {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.folders-strip {
  display: flex; align-items: center; gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 2px 16px 2px; max-width: 1400px; margin: 0 auto;
  scrollbar-width: none;
}
.folders-strip::-webkit-scrollbar { display: none; }
.folder-tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  background: var(--surface-solid); color: var(--muted);
  border: 1px solid var(--border);
  transition: background .18s, color .18s, border-color .18s, transform .15s;
}
.folder-tab:hover { color: var(--text); border-color: hsl(228 20% 90% / .22); }
.folder-tab:active { transform: scale(.96); }
.folder-tab[aria-selected="true"] {
  background: var(--grad); color: #1a1206; border-color: transparent;
  font-weight: 700; box-shadow: 0 4px 14px hsl(36 90% 55% / .25);
}
.folder-tab.empty-folder { opacity: .42; }
.folder-tab-cnt {
  font-size: 12px; opacity: .82; font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Toolbar & Grid
   ========================================================================== */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px 10px; max-width: 1400px; margin: 0 auto;
}
.toolbar-left {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.result-label { margin: 0; color: var(--muted); font-size: 14.5px; }
.result-label b { color: var(--text); font-weight: 700; }

.clear-filter-btn {
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: hsl(340 82% 70% / .18); color: var(--accent-2);
  border: 1px solid hsl(340 82% 70% / .4);
}
.clear-filter-btn:hover { background: hsl(340 82% 70% / .28); }

.chip-btn {
  padding: 8px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border);
  transition: background .2s, transform .15s;
}
.chip-btn:hover { background: hsl(228 14% 18%); }
.chip-btn:active { transform: scale(.96); }
.chip-btn.active { background: var(--text); color: var(--bg); font-weight: 700; }

main { max-width: 1400px; margin: 0 auto; padding: 0 var(--gap) calc(110px + var(--safe-b)); }
.grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(3, 1fr);
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); --gap: 6px; }
  main { padding-inline: 16px; }
}
.tile {
  position: relative; aspect-ratio: 1; padding: 0; overflow: hidden;
  background: var(--bg-2); border-radius: 3px;
  content-visibility: auto; contain-intrinsic-size: 200px;
}
@media (min-width: 640px) { .tile { border-radius: 10px; } }
.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transform: scale(1.03);
  transition: opacity .45s var(--ease), transform .5s var(--ease);
}
.tile img.loaded { opacity: 1; transform: none; }
@media (hover: hover) { .tile:hover img.loaded { transform: scale(1.03); } }
.tile .check {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid #fff; background: hsl(0 0% 0% / .38);
  display: none; place-items: center; transition: transform .2s var(--ease);
}
.tile .check svg { width: 16px; height: 16px; stroke-width: 3; opacity: 0; }
.selecting .tile .check { display: grid; }
.tile.selected img { transform: scale(.88); border-radius: 8px; }
.tile.selected .check { background: var(--grad); border-color: transparent; transform: scale(1.08); }
.tile.selected .check svg { opacity: 1; color: #1a1206; }

.tile-badge {
  position: absolute; left: 6px; bottom: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: hsl(228 20% 6% / .82); color: var(--accent);
  border: 1px solid hsl(36 92% 66% / .3);
  pointer-events: none;
}

.empty { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty-title { font-size: 16px; margin: 0 0 16px; }

/* ==========================================================================
   Selection action bar
   ========================================================================== */
.action-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 30;
  display: flex; align-items: center; gap: 10px;
  max-width: 580px; margin: 0 auto; padding: 10px 12px;
  background: hsl(228 14% 12% / .92); border: 1px solid var(--border); border-radius: 18px;
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 18px 50px hsl(0 0% 0% / .6);
  animation: slide-up .35s var(--ease) both;
}
.sel-count { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; font-weight: 700; font-size: 14.5px;
  background: var(--grad); color: #1a1206;
  box-shadow: 0 8px 24px hsl(20 90% 60% / .3);
  transition: transform .15s var(--ease), filter .2s, opacity .2s;
}
.btn-lg { padding: 13px 22px; font-size: 15.5px; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.96); }
.btn-primary:disabled { opacity: .45; box-shadow: none; cursor: default; }
.btn-primary.busy { pointer-events: none; opacity: .8; }
.btn-primary.ready { animation: pulse 1.4s ease-in-out infinite; }
.link-btn { color: var(--accent); font-size: 13.5px; font-weight: 600; padding: 4px 0; }

/* ==========================================================================
   Lightbox (Accessible with clear Close & Prev/Next buttons)
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 50;
  background: hsl(228 20% 3% / .98);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fade .22s var(--ease) both;
}
.lb-top {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 6px;
}
.close-pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 700;
  background: hsl(0 0% 100% / .14); color: var(--text);
  border: 1px solid hsl(0 0% 100% / .18);
}
.close-pill-btn:hover { background: hsl(0 0% 100% / .22); }
.lb-counter { flex: 1; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-spacer { width: 82px; }

.lb-stage {
  position: relative;
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px 12px;
  touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none;
}
.lb-stage img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform .3s var(--ease), opacity .25s;
  -webkit-touch-callout: default;
}
.lb-stage img.dragging { transition: none; }
.lb-spinner {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid hsl(0 0% 100% / .15); border-top-color: var(--accent);
  animation: spin .8s linear infinite; opacity: 0; transition: opacity .2s;
}
.lb-stage.loading .lb-spinner { opacity: 1; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: hsl(228 20% 8% / .65); border: 1px solid hsl(0 0% 100% / .18);
  color: #fff; transition: background .2s; z-index: 2;
}
.lb-nav:hover { background: hsl(228 20% 14% / .85); }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-bottom {
  flex: 0 0 auto;
  display: flex; justify-content: center;
  padding: 8px 16px calc(14px + var(--safe-b));
}
.btn-save { min-width: 240px; padding: 12px 24px; font-size: 15.5px; }
.btn-save svg { width: 21px; height: 21px; }

/* ==========================================================================
   Selfie Search Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 55;
  background: hsl(228 22% 4% / .85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center; padding: 16px;
  animation: fade .2s var(--ease) both;
}
.modal-card {
  width: 100%; max-width: 480px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 20px;
  box-shadow: 0 24px 60px hsl(0 0% 0% / .65);
  animation: rise .25s var(--ease) both;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font: 700 19px var(--display); }
.modal-sub { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }

.selfie-dropzone {
  border: 1.5px dashed hsl(228 20% 90% / .22);
  border-radius: 16px; padding: 24px 16px;
  text-align: center; background: hsl(228 16% 8% / .65);
}
.selfie-icon-circle {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px;
  display: grid; place-items: center;
  background: hsl(36 92% 66% / .15); color: var(--accent);
}
.selfie-icon-circle svg { width: 26px; height: 26px; }
.selfie-drop-title { margin: 0; font-weight: 700; font-size: 15.5px; }
.selfie-drop-hint { margin: 6px 0 18px; font-size: 12.5px; color: var(--muted); }
.selfie-btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.selfie-cam-wrap {
  position: relative; border-radius: 14px; overflow: hidden;
  background: #000; margin-bottom: 12px;
}
.selfie-cam-wrap video {
  width: 100%; max-height: 320px; object-fit: cover; display: block;
  transform: scaleX(-1);
}
.selfie-cam-controls {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: hsl(228 16% 8%);
}

.selfie-detected {
  padding: 12px 14px; border-radius: 14px;
  background: hsl(228 16% 8%); border: 1px solid var(--border);
  margin-bottom: 12px;
}
.selfie-det-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; color: var(--muted); margin-bottom: 10px;
}
.selfie-faces-row {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px;
}
.selfie-face-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px; border-radius: 12px; border: 2px solid transparent;
}
.selfie-face-item.active {
  border-color: var(--accent); background: hsl(36 92% 66% / .14);
}
.selfie-face-item img {
  width: 62px; height: 62px; border-radius: 50%; object-fit: cover;
}
.selfie-face-item span { font-size: 12px; color: var(--text); font-weight: 600; }

.selfie-sensitivity {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13.5px; color: var(--muted);
}
.sens-pills {
  display: inline-flex; background: var(--bg-2); border-radius: 999px;
  padding: 3px; border: 1px solid var(--border);
}
.sens-pill {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); transition: background .2s, color .2s;
}
.sens-pill.active { background: var(--text); color: var(--bg); font-weight: 700; }

.selfie-status {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 0 4px; font-size: 14px; font-weight: 600; color: var(--accent);
}
.selfie-spin { position: static; opacity: 1; width: 22px; height: 22px; border-width: 2.5px; }

/* ==========================================================================
   Toast & Home
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; text-align: center;
  box-shadow: 0 12px 30px hsl(0 0% 0% / .5);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.home-head { padding: 64px 20px 20px; max-width: 1100px; margin: 0 auto; animation: rise .6s var(--ease) both; }
.home-head h1 {
  margin: 0; font: 700 clamp(32px, 8vw, 60px)/1.1 var(--display);
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-head p { color: var(--muted); margin: 12px 0 0; font-size: 16px; }
.events {
  display: grid; gap: 16px; padding: 20px; max-width: 1100px; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.event-card {
  display: block; color: inherit; text-decoration: none; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-solid); border: 1px solid var(--border);
  transition: transform .3s var(--ease), box-shadow .3s; animation: rise .6s var(--ease) both;
}
.event-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px hsl(0 0% 0% / .4); }
.event-cover { aspect-ratio: 16/10; background: var(--bg-2) center/cover; }
.event-body { padding: 14px 16px 16px; }
.event-body h2 { margin: 0; font: 700 18px var(--display); }
.event-body p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: scale(.8); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(24px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px hsl(36 92% 66% / .25), 0 8px 24px hsl(20 90% 60% / .3); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
