/* ===== E-Polling Wapres — tampilan publik =====
   Mobile-first. Efek liquid glass penuh aktif di desktop (hover + lebar >= 1024px). */

:root {
  --bg: #0a1220;
  --ink: #f4f7ff;
  --muted: rgba(244, 247, 255, .72);
  --c1: #3ddbc0;           /* aksen kandidat 1 */
  --c2: #ffb547;           /* aksen kandidat 2 */
  --line: rgba(255, 255, 255, .2);
  --blur: 12px;
  --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ----- Latar aurora ----- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #14284a 0%, var(--bg) 60%); }
.aurora i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55;
  animation: drift 26s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 60vmax; height: 60vmax; left: -15vmax; top: -10vmax; background: var(--c1); opacity: .38; }
.aurora i:nth-child(2) { width: 55vmax; height: 55vmax; right: -18vmax; top: 18vmax; background: var(--c2); opacity: .34; animation-duration: 32s; }
.aurora i:nth-child(3) { width: 45vmax; height: 45vmax; left: 20vmax; bottom: -20vmax; background: #5b6cff; opacity: .4; animation-duration: 38s; }
@keyframes drift { to { transform: translate3d(6vmax, 5vmax, 0) scale(1.12); } }

/* ----- Permukaan kaca ----- */
.glass {
  position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
  border: 1px solid var(--line);
  border-radius: var(--r, 26px);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.5),
    inset 0 -1px 1px rgba(255,255,255,.08),
    inset 0 0 24px rgba(255,255,255,.05),
    0 24px 60px -24px rgba(0,0,0,.6);
}
.glass::before { /* kilau mengikuti kursor */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 0%), rgba(255,255,255,.2), transparent 45%);
  opacity: 0; transition: opacity .35s;
}

/* ----- Tata letak ----- */
.wrap { width: min(1080px, 100%); margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

.hero { text-align: center; padding: 28px 0 26px; }
.status { --r: 999px; display: inline-flex; align-items: center; gap: .55rem; margin: 0 0 18px;
  padding: .45rem 1rem; font-size: .9rem; font-weight: 600; }
.status .dot { width: .6rem; height: .6rem; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 4px rgba(74,222,128,.25); }
.status.is-closed .dot { background: #f87171; box-shadow: 0 0 0 4px rgba(248,113,113,.25); }
.hero h1 { font: 800 clamp(2rem, 7.5vw, 4rem)/1.04 var(--font-head); letter-spacing: -.02em; margin: 0 auto; max-width: 16ch; text-wrap: balance; }
.hero .sub { color: var(--muted); max-width: 46ch; margin: 14px auto 0; text-wrap: balance; }
.total { --r: 20px; display: inline-flex; align-items: baseline; gap: .6rem; margin: 22px 0 0; padding: .7rem 1.4rem; }
.total strong { font: 800 1.9rem/1 var(--font-head); font-variant-numeric: tabular-nums; }
.total span { color: var(--muted); }

.duel { display: grid; gap: 18px; }

.cand { overflow: hidden; display: flex; flex-direction: column; padding: 10px; --r: 30px; }
.cand__photo { position: relative; border-radius: 22px; overflow: hidden; aspect-ratio: 4 / 4.6; background: rgba(255,255,255,.06); }
.cand__photo img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .5s ease; }
.cand__photo.is-in img { opacity: 1; }
.cand__photo::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(8,14,26,.55)); }
.cand__badge { position: absolute; z-index: 2; left: 12px; top: 12px; padding: .35rem .8rem; border-radius: 999px;
  background: var(--accent); color: #07131f; font-weight: 700; font-size: .85rem; }
.cand__body { padding: 18px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cand h2 { margin: 0; font: 800 1.7rem/1.1 var(--font-head); letter-spacing: -.01em; }
.meta { margin: 0; color: var(--muted); font-size: .95rem; }
.meta strong { color: var(--ink); font-weight: 600; }
.vision { margin: 8px 0 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; max-width: 60ch; }

.result { margin-top: 14px; }
.result__row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.result__pct { font: 800 2.4rem/1 var(--font-head); font-variant-numeric: tabular-nums; color: var(--accent); }
.result__n { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 12px; margin-top: 10px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width 1s cubic-bezier(.2,.8,.2,1); }

.btn { position: relative; appearance: none; border: 0; cursor: pointer; width: 100%; min-height: 52px; margin-top: 16px; padding: .85rem 1.4rem;
  border-radius: 16px; background: var(--accent, var(--c1)); color: #07131f; font: 700 1.05rem var(--font-body);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.6), 0 10px 24px -10px var(--accent, var(--c1));
  transition: transform .15s ease, filter .15s ease; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { .btn:hover { filter: brightness(1.08); } }
.btn:active { transform: scale(.98); }
.btn[hidden] { display: none; }
.btn--ghost { background: rgba(255,255,255,.12); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn:disabled { opacity: .6; cursor: progress; }

.note { text-align: center; color: var(--muted); min-height: 1.5em; margin: 22px 0 0; }
.foot { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .6rem 1.5rem;
  justify-content: space-between; color: var(--muted); font-size: .9rem; }
.foot p { margin: 0; }

/* ----- Dialog konfirmasi ----- */
.sheet { --r: 28px; --blur: 24px; color: var(--ink); width: min(420px, calc(100% - 32px)); padding: 26px; border: 1px solid var(--line); text-align: center; }
.sheet::backdrop { background: rgba(5,9,18,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet img { width: 96px; height: 96px; object-fit: cover; border-radius: 50%; margin: 0 auto 14px; border: 2px solid var(--line); }
.sheet h3 { margin: 0 0 6px; font: 800 1.5rem var(--font-head); }
.sheet p { margin: 0; color: var(--muted); }
.sheet p strong { color: var(--ink); }
.sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.sheet__actions .btn { margin: 0; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(440px, calc(100% - 32px)); padding: .85rem 1.2rem; border-radius: 16px; font-weight: 600;
  background: rgba(15,24,42,.92); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.toast.err { border-color: #f87171; }

/* ----- Layar lebih lebar ----- */
@media (min-width: 720px) {
  :root { --blur: 16px; }
  .duel { grid-template-columns: 1fr 1fr; gap: 26px; align-items: stretch; }
  .cand h2 { font-size: 2rem; }
}

/* ----- Desktop: liquid glass penuh ----- */
@media (hover: hover) and (min-width: 1024px) {
  :root { --blur: 22px; }
  .wrap { padding-top: 40px; }
  .hero { padding-top: 40px; }
  .glass:hover::before { opacity: 1; }
  .cand { transition: transform .5s cubic-bezier(.2,.8,.2,1), box-shadow .5s; }
  .cand:hover { transform: translateY(-8px); }
  .cand__photo img { transition: opacity .5s ease, transform .8s cubic-bezier(.2,.8,.2,1); }
  .cand:hover .cand__photo img { transform: scale(1.04); }
  /* Chromium: pembiasan tepi kaca lewat filter SVG (diaktifkan oleh app.js) */
  .lens-on .lens-surface { -webkit-backdrop-filter: blur(14px) saturate(180%) url(#lg-warp); backdrop-filter: blur(14px) saturate(180%) url(#lg-warp); }
}

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


/* ===== Skeleton loading ===== */
:root { --sk: linear-gradient(100deg, rgba(255,255,255,.07) 30%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.07) 70%); }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes skFade  { from { opacity: 0; } }
@keyframes spin    { to { transform: rotate(360deg); } }

/* Foto: kotak berkilau sampai gambar selesai dimuat */
.cand__photo { background: var(--sk) 0 0 / 200% 100%, rgba(255,255,255,.05); animation: shimmer 1.4s linear infinite; }
.cand__photo.is-in { animation: none; background: rgba(255,255,255,.06); }

/* Halaman: teks dan tombol jadi kerangka selama halaman/font belum selesai dimuat.
   Muncul setelah 0,2 detik supaya tidak berkedip saat koneksi cepat. */
.is-loading .sk {
  color: transparent !important; -webkit-text-fill-color: transparent;
  background: var(--sk) 0 0 / 200% 100%; border-radius: 10px; box-shadow: none;
  animation: shimmer 1.4s linear infinite, skFade .3s .2s backwards;
  pointer-events: none; user-select: none;
}
.is-loading .sk * { color: transparent !important; -webkit-text-fill-color: transparent; }

/* Hasil: kerangka saat suara sedang dikirim */
.result.is-pending .result__pct, .result.is-pending .result__n {
  display: inline-block; min-width: 5rem; color: transparent; border-radius: 8px;
  background: var(--sk) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite;
}
.result.is-pending .result__n { min-width: 6rem; }
.result.is-pending .bar i { width: 100% !important; background: var(--sk) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }

/* Tombol sedang mengirim */
.btn.is-busy { color: transparent; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(7,19,31,.25); border-top-color: #07131f; animation: spin .7s linear infinite; }

/* ===== Penyesuaian ukuran layar ===== */
/* Ponsel kecil */
@media (max-width: 380px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .hero { padding: 18px 0 20px; }
  .cand { padding: 8px; --r: 26px; }
  .cand__photo { border-radius: 18px; }
  .cand h2 { font-size: 1.45rem; }
  .result__pct { font-size: 2rem; }
  .total strong { font-size: 1.6rem; }
  .sheet { padding: 20px; }
}
/* Ponsel: foto sedikit lebih pendek, dialog menjadi lembar dari bawah */
@media (max-width: 719px) {
  .hero { padding-top: 12px; }
  .cand__photo { aspect-ratio: 4 / 4.2; }
  .sheet { margin: auto auto max(12px, env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .sheet[open] { animation: sheetUp .35s cubic-bezier(.2,.8,.2,1); }
  .foot { flex-direction: column; text-align: center; align-items: center; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
/* Ponsel posisi miring (layar pendek) */
@media (max-height: 520px) and (orientation: landscape) {
  .hero { padding: 14px 0 16px; }
  .hero h1 { font-size: 1.8rem; max-width: none; }
  .hero .sub { margin-top: 8px; }
  .duel { grid-template-columns: 1fr 1fr; }
  .cand__photo { aspect-ratio: 16 / 10; }
}
/* Tablet */
@media (min-width: 720px) and (max-width: 1023px) {
  .wrap { padding-left: 28px; padding-right: 28px; }
  .cand__photo { aspect-ratio: 4 / 4.4; }
}
/* Desktop besar */
@media (min-width: 1280px) {
  .wrap { width: min(1200px, 100%); }
  .duel { gap: 36px; }
  .cand { padding: 14px; }
  .cand__body { padding: 22px 14px 14px; }
  .cand h2 { font-size: 2.3rem; }
  .hero h1 { max-width: 18ch; }
}
