/* TerjemahBuku v2 — "ink & paper" manuscript world.
 * Mode: Operate (tool). Dials: variance 5 / motion 3 / density 4.
 * Satu aksen (gold) dikunci di seluruh halaman. Serif display = Newsreader
 * (self-hosted) — dibenarkan karena keluarga estetika manuscript/publikasi
 * untuk sebuah perkakas buku.
 */

@font-face {
  font-family: 'Newsreader';
  src: url('../js/fonts/newsreader-v26-latin-regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../js/fonts/newsreader-v26-latin-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../js/fonts/newsreader-v26-latin-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../js/fonts/newsreader-v26-latin-600italic.woff2') format('woff2');
  font-weight: 600; font-style: italic; font-display: swap;
}

:root {
  --bg: #171310;
  --surface: #211b14;
  --surface2: #2a2318;
  --ink: #ede4d1;
  --muted: #a4967f;
  --accent: #d9a441;
  --accent-ink: #201503;
  --danger: #cf6a5b;
  --line: #38301f;
  --radius-card: 14px;
  --radius-ctl: 10px;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
/* Pengaman: atribut hidden harus selalu menyembunyikan, tak peduli aturan display lain */
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px 90px;
  caret-color: var(--accent);
}
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line); }

h1, h2, .brand span {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h1 { font-size: 1.75rem; line-height: 1.25; margin: 1.1em 0 0.45em; }
h2 { font-size: 1.2rem; margin: 1.8em 0 0.6em; }
a { color: var(--accent); text-underline-offset: 3px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.lead { font-size: 1.1rem; }
.center { text-align: center; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 68px; max-height: 80px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.brand span { font-size: 1.3rem; }
/* mark logo tunggal (icons/icon.svg) */
.brand img, .side-brand img { width: 28px; height: 28px; flex: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-email {
  font-size: 0.8rem; color: var(--muted);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: var(--radius-ctl);
  color: var(--muted); padding: 8px; cursor: pointer; display: inline-flex;
  transition: color 0.2s, border-color 0.2s, transform 0.1s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn[hidden] { display: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- views ---------- */
main > section[hidden] { display: none; }
main > section { animation: view-in 0.32s var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- auth / paywall ---------- */
.auth-wrap {
  min-height: calc(100dvh - 200px);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 32px 0; gap: 18px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 30px 26px;
}
.auth-card h1 { margin: 0.4em 0 0.2em; font-size: 1.9rem; }
.auth-sub { margin: 0 0 1.2em; }
.auth-mark {
  width: 56px; height: 56px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.auth-card.center { text-align: center; }
.auth-card.center .auth-mark { margin: 0 auto; }

/* ---------- type & form ---------- */
label { display: block; margin: 14px 0 2px; font-size: 0.92rem; }
input, select {
  width: 100%; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-ctl);
  padding: 11px 13px; font-size: 0.95rem; margin: 6px 0;
  font-family: var(--sans);
  appearance: none; -webkit-appearance: none;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.form-error {
  color: var(--danger); font-size: 0.88rem; margin: 8px 0 0;
  min-height: 1.4em;
}

/* Checklist syarat kata sandi (realtime, mode daftar) */
.pw-rules {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.pw-rules li {
  font-size: .83rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
  transition: color .2s var(--ease-out);
}
.pw-rules li::before {
  content: '';
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  flex: none;
  transition: all .2s var(--ease-out);
}
.pw-rules li.ok { color: var(--ink); }
.pw-rules li.ok::before {
  border-color: var(--accent);
  background: var(--accent);
}
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 0.92rem; cursor: pointer; padding: 6px;
  text-underline-offset: 3px;
}
.link-btn:hover { text-decoration: underline; }
/* Link "Lupa kata sandi?" rata kanan di bawah field password (form login) */
.forgot-row { margin: 4px 0 0; text-align: right; }
.forgot-row .link-btn { padding: 2px 0; font-size: 0.85rem; }

/* ---------- buttons ---------- */
.btn {
  background: var(--surface2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-ctl);
  padding: 10px 18px; font-size: 0.95rem; cursor: pointer;
  font-family: var(--sans);
  transition: border-color 0.2s, filter 0.2s, transform 0.08s;
  text-decoration: none; display: inline-block; text-align: center;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding: 8px 10px; }
.btn.ghost:hover { color: var(--ink); border-color: transparent; }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }
.btn.big { font-size: 1.05rem; padding: 13px 22px; }
.btn.full { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.loading { position: relative; color: transparent; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
  color: var(--accent-ink);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- home ---------- */
.hero { padding: 8px 0 4px; }
.hero h1 { font-size: 2rem; max-width: 22ch; }
.hero p { max-width: 58ch; }
.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--radius-card);
  padding: 46px 20px; text-align: center; cursor: pointer;
  background: var(--surface);
  transition: border-color 0.25s var(--ease-out), background 0.25s, transform 0.15s;
  color: var(--muted); margin: 18px 0 8px;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag {
  border-color: var(--accent); background: var(--surface2);
  transform: scale(1.01);
}
.dropzone strong { color: var(--ink); font-size: 1.05rem; font-family: var(--serif); font-weight: 600; }

.job-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 14px 16px; margin: 10px 0;
  transition: border-color 0.2s;
}
.job-row:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.job-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.job-info strong { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; }
.job-actions { display: flex; gap: 8px; flex-shrink: 0; }
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius-card);
  padding: 28px 20px; text-align: center; color: var(--muted);
}

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: flex; gap: 16px; align-items: baseline;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--serif); font-style: italic;
  color: var(--accent); font-size: 1.05rem; flex-shrink: 0;
}
.steps p { margin: 2px 0 0; font-size: 0.9rem; }

/* ---------- cards & rows ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 18px; margin: 14px 0;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.est { margin: 10px 0 4px; font-variant-numeric: tabular-nums; }

/* ---------- glossary ---------- */
.gloss-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.gloss-table th, .gloss-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.gloss-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.row input { flex: 1; min-width: 120px; }

/* ---------- progress ---------- */
.progress-wrap { margin: 18px 0; }
.progress-track {
  background: var(--surface2); border-radius: 99px; height: 10px; overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar {
  background: var(--accent); height: 100%; width: 0;
  transition: width 0.5s var(--ease-out); border-radius: 99px;
}
#p-stat { font-variant-numeric: tabular-nums; }
.ch-row {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.ch-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex-shrink: 0; transition: background 0.3s; }
.ch-row.done .ch-dot { background: var(--accent); }
.ch-row.translating .ch-dot { background: var(--accent); animation: pulse 1.4s var(--ease-out) infinite; }
.ch-row.failed .ch-dot { background: var(--danger); }
.ch-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-st { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.ch-row.failed { cursor: pointer; }
.ch-row.failed:hover .ch-st { color: var(--danger); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---------- done / warn ---------- */
.warn {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--ink);
  border-radius: var(--radius-card); padding: 13px 16px; font-size: 0.92rem;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 8, 5, 0.72);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 20; padding: 18px;
  animation: view-in 0.25s var(--ease-out);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px; width: 100%; max-width: 440px;
}
.modal h2 { margin: 0 0 0.4em; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface2); border: 1px solid var(--accent); color: var(--ink);
  padding: 12px 22px; border-radius: 99px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  z-index: 30; max-width: 90vw; text-align: center; font-size: 0.92rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  body { padding: 0 16px 70px; }
  .hero h1 { font-size: 1.6rem; }
  .row .btn { flex: 1; }
  .user-email { display: none; }
  .auth-card { padding: 26px 22px 20px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  main > section { animation: none; }
}
