/* =====================================================================
   OLIMPIADE ONLINE - gaya bersama
   Bagian 1: TEMPLATE LATAR BELAKANG (ubah di sini)
   Bagian 2: komponen UI
   ===================================================================== */

:root {
  /* ---------- TEMPLATE LATAR BELAKANG ----------
     Ingin memakai foto/gambar sendiri? Taruh file di folder public/img/
     lalu ubah baris di bawah, contoh:
       --bg-image: url('/img/latar.jpg');
     Biarkan "none" untuk memakai pola bawaan. */
  --bg-image: none;

  --ink: #0f1b4d;
  --ink-2: #1b2b72;
  --gold: #e8b04a;
  --gold-d: #a8721a;
  --paper: #f1f3fa;
  --card: #ffffff;
  --text: #141c3a;
  --muted: #5d6788;
  --line: #dde2f0;
  --ok: #0f8a7e;
  --bad: #d23838;
  --warn: #b86e0c;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 77, .06), 0 8px 24px -12px rgba(15, 27, 77, .25);
}

/* latar gelap: halaman login */
body.bg-dark::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    var(--bg-image),
    radial-gradient(circle at 88% 8%, rgba(232, 176, 74, .28), transparent 38%),
    repeating-radial-gradient(circle at 0% 100%, rgba(255, 255, 255, .05) 0 1px, transparent 1px 46px),
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(155deg, #0a1238 0%, #14236b 60%, #1b2f86 100%);
  background-size: cover, auto, auto, auto, auto, auto;
  background-position: center;
}
/* latar terang: halaman ujian dan panitia */
body.bg-soft::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    var(--bg-image),
    radial-gradient(circle at 100% 0%, rgba(232, 176, 74, .16), transparent 34%),
    linear-gradient(rgba(15, 27, 77, .035) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, rgba(15, 27, 77, .035) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(180deg, #f6f7fc, #e9edf8);
  background-size: cover, auto, auto, auto, auto;
  background-position: center;
}

/* ---------------------------------------------------------------- dasar */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--paper); color: var(--text);
  font: 16px/1.5 var(--sans); overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.55rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }
a { color: var(--ink-2); }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ----------------------------------------------------------- komponen */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: clamp(16px, 3vw, 26px); }
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px; padding: .7em 1.15em; min-height: 44px;
  font: 600 .95rem/1.2 var(--sans); cursor: pointer; background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; text-decoration: none;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--ink-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: #2a1a00; }
.btn-gold:hover:not(:disabled) { background: #f0bd60; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: #eef1fa; }
.btn-danger { background: var(--bad); }
.btn-danger:hover:not(:disabled) { background: #b92c2c; }
.btn-sm { min-height: 36px; padding: .45em .85em; font-size: .85rem; }
.btn-block { width: 100%; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .lbl { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .82rem; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1.5px solid #c9d0e6; border-radius: 10px;
  padding: .65em .85em; min-height: 46px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(232, 176, 74, .45); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; padding: 6px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--ink); }

.badge { display: inline-block; padding: .15em .65em; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #e9edf8; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: #d9f3ee; color: #0a6a60; }
.badge.warn { background: #fdecc8; color: #8a5200; }
.badge.bad { background: #fbdcdc; color: #a21f1f; }
.badge.dark { background: var(--ink); color: #fff; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: .92rem; margin-bottom: 14px; border: 1px solid transparent; }
.alert.err { background: #fdeaea; color: #8e1f1f; border-color: #f4c2c2; }
.alert.ok { background: #e1f5f1; color: #0a5a51; border-color: #b7e3dc; }
.alert.info { background: #eaeffc; color: #1c2f7a; border-color: #cbd6f7; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: .92rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 9999; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--bad); }

.overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 14, 40, .62); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: min(100%, 560px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: clamp(18px, 4vw, 28px); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); }
.modal.wide { width: min(100%, 820px); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; min-height: 40px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; background: #f3f5fc; color: var(--muted); font-weight: 700; font-size: .8rem; padding: 10px 12px; white-space: nowrap; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #f8f9fe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.click { cursor: pointer; }

@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border-top: 1px solid var(--line); padding: 8px 4px; }
  .table.stack td { border: 0; padding: 4px 10px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; }
  .table.stack td.nolabel::before { content: none; }
  .table.stack td.nolabel { display: block; text-align: left; }
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #b9c0d8; margin-right: 6px; }
.dot.on { background: #20b486; box-shadow: 0 0 0 3px rgba(32, 180, 134, .2); }
.dot.off { background: var(--bad); }

.brandmark { font-family: var(--serif); font-weight: 700; letter-spacing: .01em; display: inline-flex; align-items: center; gap: 10px; }
.brandmark .mk { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }

@media print { body > * { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.hero-logo { width: clamp(96px, 16vw, 168px); height: auto; aspect-ratio: 1; border-radius: 18px; box-shadow: 0 0 0 3px rgba(255,255,255,.55), 0 18px 40px -16px rgba(0,0,0,.6); margin-bottom: 22px; display: block; }
