/* OpenPDF - desktop-first, min-width media queries only, tanpa dependensi. */
:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-soft: #f7fafd;
  --ink: #17222e;            /* teks utama di terang */
  --muted: #516073;          /* teks sekunder di terang */
  --border: #d4dbe5;
  --accent: #0b57a4;         /* biru tua Love The Documents (bukan biru iLovePDF) */
  --accent-strong: #093f75;  /* hover tombol primer */
  --accent-pop: #2563eb;     /* electric blue, momen focal saja: badge eksperimental,
                                border hover kartu alat, kartu donasi (putih di atasnya 5.17:1) */
  --accent-soft: #e7eff9;
  --on-accent: #ffffff;
  --header-bg: #122c47;
  --header-text: #f2f7fc;
  --header-muted: #b8cbde;   /* tagline di header gelap */
  --danger: #9c1c23;
  --danger-soft: #fbeaec;
  --ok: #1d6a34;
  --ok-soft: #e9f4ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 34, 46, .06), 0 8px 24px rgba(23, 34, 46, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

.wrap { max-width: 1080px; margin-inline: auto; padding-inline: 16px; }
.nowrap { white-space: nowrap; }
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--surface); color: var(--accent-strong);
  padding: 12px 18px; z-index: 10; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, var(--header-bg) 0%, #1a3a5c 100%);
  color: var(--header-text);
  padding: 40px 0 32px;
}
.header-inner { display: grid; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.tagline { margin: 0; color: var(--header-muted); font-size: 16px; max-width: 52ch; }

.page-title { font-size: clamp(28px, 5vw, 44px); line-height: 1.15; margin: 28px 0 8px; letter-spacing: -.02em; font-weight: 800; }
.page-sub { margin: 0 0 20px; color: var(--muted); max-width: 60ch; }

/* ---------- Donasi ---------- */
.donate-grid { display: grid; gap: 14px; }
.modal-grid { grid-template-columns: repeat(2, 1fr); }
.donate-card {
  font: inherit; text-decoration: none;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 16px; min-height: 44px;
  border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.donate-card .donate-qr {
  align-self: center; border-radius: 8px; background: #fff; padding: 6px;
  border: 1px solid var(--border); width: 140px; height: 140px; object-fit: contain;
}
.donate-card .donate-logo {
  border-radius: 6px; object-fit: contain;
}

/* ---------- Modal donasi ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(13, 20, 28, .62); }
.modal-card {
  position: relative; z-index: 1;
  background: var(--surface); color: var(--ink);
  border-radius: 14px; box-shadow: 0 18px 60px rgba(13, 20, 28, .35);
  width: min(560px, 100%); max-height: min(86vh, 720px); overflow: auto;
  padding: 24px;
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal-heart { color: var(--danger); flex: 0 0 auto; margin-top: 2px; }
.modal-title { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.modal-desc { margin: 0; color: var(--muted); font-size: 15px; }
.modal-close {
  margin-left: auto; flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Grid kartu alat ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.tool-card {
  appearance: none; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
  min-height: 44px;
  position: relative;
  transition: opacity .4s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--accent-pop); transform: translateY(-1px); }
.tool-card:active { transform: scale(.97); }

/* Scroll reveal: default TERLIHAT; kelas js-reveal dipasang oleh JS sebelum observe.
   Nol opacity:0 statis di CSS. */
.js-reveal { opacity: 0; transform: translateY(12px); }
.js-in { opacity: 1; transform: none; }

/* Skeleton shimmer saat postForm berjalan. Keyframes hanya opacity/transform.
   Muncul murni lewat CSS: .msg-loading.is-visible menyala bersamaan dgn pesan SR. */
.skeleton-wrap { display: none; margin-top: 14px; }
.msg-loading.is-visible ~ .skeleton-wrap { display: grid; gap: 8px; }
.skeleton-line {
  height: 44px; border-radius: var(--radius);
  background: #e6ebf2; overflow: hidden; position: relative;
}
.skeleton-line::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.tool-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-strong);
  display: inline-flex; align-items: center; justify-content: center;
}
.tool-name { display: block; font-weight: 700; font-size: 16px; line-height: 1.3; }
.tool-desc { display: block; color: var(--muted); font-size: 15px; margin-top: 2px; }
.badge-exp {
  display: inline-block; vertical-align: 1px;
  margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-pop); color: var(--on-accent);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

/* ---------- Panel alat ---------- */
.panel-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 24px 0 14px; }
.panel-title { font-size: clamp(20px, 2.6vw, 26px); margin: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 40px;
}
.field { display: grid; gap: 6px; margin: 14px 0; }
.field > label { font-weight: 600; font-size: 16px; }
.field .hint { color: var(--muted); font-size: 15px; margin: 0; }
input[type="text"], input[type="password"], input[type="number"], select {
  font: inherit; font-size: 16px; color: var(--ink);
  min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 44px; }
fieldset.options {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin: 16px 0 0; padding: 12px 16px 4px;
}
fieldset.options legend { font-weight: 700; font-size: 15px; padding-inline: 6px; }
.subpanel + .subpanel { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.opt-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding-bottom: 10px; }
.opt-row > .field { flex: 1 1 180px; margin: 0; }
.radio-line { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 2px 0 10px; }
.radio-line label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }

/* ---------- Dropzone reusable ---------- */
.dropzone {
  border: 2px dashed #93a5ba; border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 36px 16px;
  text-align: center; cursor: pointer;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { color: var(--accent-strong); display: block; margin: 0 auto 10px; }
.dz-label { margin: 0 0 4px; font-weight: 600; font-size: 17px; }
.dz-hint { margin: 0; color: var(--muted); font-size: 16px; }

/* ---------- Daftar berkas terpilih / daftar urutan ---------- */
.file-list, .merge-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.file-item, .merge-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-soft); padding: 6px 8px 6px 14px;
}
.file-item-name, .merge-item-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.file-item-meta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.merge-item.dragging { opacity: .45; border-style: dashed; }
.merge-item.drop-target { border-color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.merge-item[draggable="true"] { cursor: grab; }
.order-num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Tombol ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.btn {
  appearance: none; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 22px;
  border-radius: var(--radius); border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--accent-strong); border-color: #b3c9e6; }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-danger {
  flex: 0 0 auto; width: 44px; height: 44px; padding: 0;
  border-radius: 8px; border: 0; background: transparent;
  color: var(--danger); font-size: 20px; line-height: 1;
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-back { margin-right: auto; }   /* dorong judul ke kanan saat membungkus */
.btn-icon {
  flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1;
  cursor: pointer;
}
.btn-icon:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.btn-icon:disabled { opacity: .35; cursor: not-allowed; }
.btn-icon:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-icon span[aria-hidden] { pointer-events: none; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Keadaan / pesan (.msg dipertahankan dari pola lama) ---------- */
.state-empty { color: var(--muted); margin-top: 14px; }
.state-empty p { margin: 4px 0; }
.msg { display: none; margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius); font-size: 16px; }
.msg.is-visible { display: block; }
.msg-loading { background: var(--accent-soft); color: var(--accent-strong); }
.msg-error { background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.msg-ok { background: var(--ok-soft); color: var(--ok); font-weight: 500; }

/* ---------- Hasil ---------- */
.results { margin-top: 20px; }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.result-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-soft);
  padding: 12px 16px;
}
.result-names { flex: 1 1 260px; min-width: 0; }
.result-original { display: block; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.result-pdf { font-weight: 600; overflow-wrap: anywhere; }
.result-meta { display: block; color: var(--muted); font-size: 14px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 8px; padding: 16px 0 40px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }
.site-footer a { color: var(--accent-strong); padding: 4px 2px; }

/* ================= md: tablet+ (hanya MENAMBAH) ================= */
@media (min-width: 768px) {
  .wrap { padding-inline: 24px; }
  .site-header { padding: 52px 0 44px; }
  .card { padding: 28px; }
  .dropzone { padding: 48px 24px; }
  .tool-grid { gap: 16px; }
  .donate-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  /* Gerak tambahan hanya tablet+: spotlight mouse-follow (kartu alat & donasi).
     --mx/--my diisi JS rAF-throttled. */
  .tool-card::after, .donate-card::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit;
    opacity: 0; pointer-events: none;
    background: radial-gradient(160px circle at var(--mx, 50%) var(--my, 50%),
      rgba(37, 99, 235, .10), transparent 70%);
    transition: opacity .2s ease;
  }
  .tool-card:hover::after, .donate-card:hover::after { opacity: 1; }
}

/* View Transitions API home <-> panel: cross-fade default cukup */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }

/* ================= lg: desktop ================= */
@media (min-width: 1024px) {
  .header-inner { grid-template-columns: 1fr auto; align-items: end; }
  .tagline { text-align: right; max-width: 40ch; justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
  .js-reveal { opacity: 1; transform: none; }
  .skeleton-line::after { animation: none; display: none; }
}

/* Ponsel: tombol primer full-width agar mudah disentuh */
.btn-primary { width: 100%; }
@media (min-width: 768px) {
  .btn-primary { width: auto; }
}

/* screen-reader-only text */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
