/* Galeri Momen: tampilan "kamera sekali pakai".
   Satu elemen yang menonjol (panel kamera dengan tombol rana), sisanya dibuat tenang. */

:root {
  --ink: #17231e;
  --paper: #e7ebe4;
  --surface: #f6f8f4;
  --muted: #55645b;
  --line: #c9d2c7;
  --flash: #f3b53f;        /* ditimpa EVENT_ACCENT dari .env */
  --flash-ink: #17231e;    /* ditimpa EVENT_ACCENT_INK dari .env */
  --panel: #17231e;
  --panel-soft: #22332b;
  --panel-text: #e9efe6;
  --panel-muted: #a3b5a9;
  --danger: #b3342b;
  --font: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img, video { max-width: 100%; }
h1, h2, p { margin: 0; }
.ic { width: 1em; height: 1em; display: block; }
.muted { color: var(--muted); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.cam :focus-visible, .lb :focus-visible { outline-color: #fff; }

.wrap { width: min(100% - 32px, 64rem); margin-inline: auto; }

/* ---------- Judul acara ---------- */
.hero { padding-top: max(26px, env(safe-area-inset-top)); padding-bottom: 18px; }

.viewfinder { position: relative; padding: 36px 26px 32px; }
.viewfinder::before {
  --c: var(--ink); --len: 24px; --w: 3px;
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--len) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top left / var(--w) var(--len) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--len) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--w) var(--len) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--len) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--w) var(--len) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--len) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--w) var(--len) no-repeat;
  animation: focus-in 1.1s cubic-bezier(.2, .8, .2, 1) both;   /* satu-satunya animasi otomatis: "fokus" kamera */
}
@keyframes focus-in { from { transform: scale(1.1); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.viewfinder h1 {
  font-size: clamp(2.2rem, 9vw, 3.6rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}
.viewfinder .lead { margin-top: 12px; font-size: 1.1rem; color: var(--muted); max-width: 36ch; }
.viewfinder .when { margin-top: 10px; font-weight: 600; }

/* ---------- Panel kamera ---------- */
.cam {
  background: var(--panel);
  color: var(--panel-text);
  border-radius: 28px;
  padding: 22px 18px 20px;
}
.field { display: block; margin-bottom: 24px; }
.field span { display: block; margin-bottom: 7px; font-size: .9rem; color: var(--panel-muted); }
.field input {
  width: 100%; height: 50px; padding: 0 14px;
  border-radius: 12px; border: 1px solid #365044;
  background: var(--panel-soft); color: var(--panel-text);
  font: inherit;
}
.field input::placeholder { color: #7f9488; }
.field.light { margin-bottom: 18px; }
.field.light span { color: var(--muted); }
.field.light input { background: var(--surface); border-color: var(--line); color: var(--ink); }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.ctl {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--panel-text); font: 500 .9rem/1.2 var(--font); text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.ctl .ring {
  width: 60px; height: 60px; border-radius: 50%;
  border: 2px solid #4a6457; display: grid; place-items: center;
  transition: background-color .15s, transform .1s;
}
.ctl .ic { width: 26px; height: 26px; }
.ctl:hover .ring { background: var(--panel-soft); }
.ctl:active .ring { transform: scale(.94); }

.ctl.shutter { font-weight: 600; font-size: 1rem; }
.ctl.shutter .ring {
  width: 92px; height: 92px; border: 0;
  background: var(--flash); color: var(--flash-ink);
  box-shadow: 0 0 0 5px var(--panel), 0 0 0 8px var(--flash);   /* cincin ganda ala tombol rana */
  margin: 8px;
}
.ctl.shutter:hover .ring { background: var(--flash); filter: brightness(1.05); }
.ctl.shutter .ic { width: 38px; height: 38px; }

/* ---------- Daftar unggahan ---------- */
.uploads { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 8px; }
.uploads:empty { display: none; }
.up {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 8px; border-radius: 14px; background: var(--panel-soft);
  transition: opacity .4s, transform .4s;
}
.up.leaving { opacity: 0; transform: translateY(-6px); }
.up-thumb {
  width: 48px; height: 48px; border-radius: 9px; overflow: hidden;
  display: grid; place-items: center; background: #2d4136; color: var(--panel-muted);
}
.up-thumb img { width: 100%; height: 100%; object-fit: cover; }
.up-thumb .ic { width: 22px; height: 22px; }
.up-name { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-status { font-size: .82rem; color: var(--panel-muted); }
.bar { height: 4px; margin-top: 6px; border-radius: 2px; background: #365044; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--flash); transition: width .2s; }
.up[data-state="done"] .up-status { color: #8fd6a8; }
.up[data-state="done"] .bar i { background: #8fd6a8; }
.up[data-state="retry"] .up-status { color: var(--flash); }
.up[data-state="error"] .up-status { color: #ff9d92; }
.up[data-state="error"] .bar i { background: #ff9d92; }
.up-retry {
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 2px solid var(--panel-text); background: none; color: var(--panel-text);
  font: 600 .85rem var(--font); cursor: pointer;
}

/* ---------- Galeri ---------- */
.gallery { padding: 36px 0 72px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.sec-head h2 { font-size: 1.7rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.015em; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 6px; } }

.tile {
  position: relative; display: block; aspect-ratio: 1;
  margin: 0; padding: 0; border: 0; border-radius: 6px; overflow: hidden;
  background: #cdd6ca; cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.no-thumb { background: var(--panel); }
.tile .badge {
  position: absolute; left: 6px; bottom: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(23, 35, 30, .85); color: #fff; display: grid; place-items: center;
}
.tile .badge svg { width: 12px; height: 12px; margin-left: 1px; }

.empty { padding: 36px 0; text-align: center; color: var(--muted); font-size: 1.05rem; }
.more-wrap { display: flex; justify-content: center; margin-top: 20px; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: 999px;
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
  font: 600 .95rem/1 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: rgba(23, 35, 30, .07); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #22332b; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(10, 16, 13, .96); }
.lb-bar { display: flex; justify-content: space-between; align-items: center; padding: max(10px, env(safe-area-inset-top)) 12px 10px; }
.lb-stage { position: relative; min-height: 0; margin: 0 8px; }
.lb-stage img, .lb-stage video {
  position: absolute; inset: 0; margin: auto;
  max-width: 100%; max-height: 100%; border-radius: 4px; background: #000;
}
.lb-cap { min-height: 44px; padding: 10px 16px max(14px, env(safe-area-inset-bottom)); text-align: center; color: #cdd9d0; }
.lb-btn {
  display: grid; place-items: center; width: 46px; height: 46px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff;
  text-decoration: none; cursor: pointer;
}
.lb-btn:hover { background: rgba(255, 255, 255, .24); }
.lb-btn .ic { width: 22px; height: 22px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
body.lb-open { overflow: hidden; }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 80;
  transform: translateX(-50%); max-width: min(92vw, 420px);
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: #fff; font-size: .92rem;
}

/* ---------- Halaman PIN & login ---------- */
.gate { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(100%, 380px); }
.gate-card h1 { font-size: 2rem; font-weight: 700; line-height: 1.08; letter-spacing: -0.02em; margin-bottom: 8px; }
.gate-card .muted { margin-bottom: 24px; }
.err { margin: -6px 0 16px; color: var(--danger); font-weight: 500; }

/* ---------- Admin ---------- */
.admin-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; padding: 26px 0 18px; }
.admin-head h1 { font-size: 2rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-actions form { margin: 0; }

.notice { margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.notice.bad { border-color: var(--danger); color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { padding: 14px 16px; border-radius: 14px; background: var(--surface); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.15; letter-spacing: -0.01em; }
.stat span { font-size: .88rem; color: var(--muted); }

.qr-card { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; margin-bottom: 22px; padding: 16px; border-radius: 18px; background: var(--surface); }
.qr-card img { border-radius: 8px; background: #fff; }
.qr-card h2 { font-size: 1.25rem; margin-bottom: 6px; }
.qr-card p { max-width: 46ch; margin-bottom: 12px; }

.bulkbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; background: var(--paper); }
.bulkbar .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.admin-grid { margin-top: 6px; }
.tile.sel input { position: absolute; top: 8px; left: 8px; z-index: 2; width: 22px; height: 22px; accent-color: var(--ink); }
.tile.is-hidden img { opacity: .3; }
.tile .tag { position: absolute; top: 8px; right: 8px; padding: 2px 8px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .72rem; font-weight: 600; }
.tile .open { position: absolute; right: 6px; bottom: 6px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--ink); font-size: .75rem; font-weight: 600; text-decoration: none; }
.tile .by { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px 40px; font-size: .72rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); pointer-events: none; }
.tile.sel .badge { left: auto; right: 6px; bottom: auto; top: 34px; }
.tile.sel:has(input:checked) { outline: 4px solid var(--flash); outline-offset: -4px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 22px 0 60px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
