/*
 * style.css — Styling aplikasi memudahkan pembaca PGR
 * versi: 1.1
 * Lisensi: MIT
 * Repositori: https://github.com/andimgthub/platform-gotong-royong/
 */

/* ============ Tokens ============ */
:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2c6e49;
  --accent-fg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 10px;
  --maxw: 760px;
  --header-h: 52px;
  --footer-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --fg: #e6e8eb;
  --muted: #9aa1ab;
  --border: #262b33;
  --accent: #6fcf97;
  --accent-fg: #0f1115;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ============ Home ============ */
.view { min-height: 100dvh; }
.home {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.5rem;
  min-height: 100dvh;
}
.home-title {
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}
.home-quote {
  margin: 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  text-align: center;
  font-size: .875rem;
  line-height: 1.55;
}
.home-quote p { margin: 0 0 .75rem; }
.home-quote p:last-child { margin-bottom: 0; }
.home-quote strong { color: var(--accent); }

.btn-primary {
  display: inline-block;
  padding: .85rem 1.6rem;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { transform: scale(.97); }

/* Tombol sekunder: mild, hanya border, tanpa warna isi. */
.btn-secondary {
  display: inline-block;
  padding: .65rem 1.3rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 500;
  font-size: .875rem;
  transition: border-color .15s ease, color .15s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { transform: scale(.97); }
.btn-secondary:hover {
  border-color: var(--fg);
  color: var(--fg);
}
.btn-secondary.copied {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-hint {
  margin: 0;
  font-size: .75rem;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.4;
}

.home-status {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: .35rem 1rem;
  margin: 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: .8rem;
  width: 100%;
}
.home-status dt { color: var(--muted); font-weight: 600; }
.home-status dd { margin: 0; }

.home-footer {
  font-size: .8rem;
  color: var(--muted);
  margin-top: auto;
}
.home-footer p { margin: .25rem 0; }

/* ============ Reader ============ */
#view-reader {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.reader-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  padding-top: calc(.5rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}
.reader-title {
  flex: 1;
  margin: 0;
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.reader-version {
  font-size: .75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: .15rem .5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.reader-version:empty { display: none; }

.markdown {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  overflow-wrap: anywhere;
}
.markdown > :first-child { margin-top: 0; }
.markdown h1 { font-size: 1.6rem; margin: 1.5rem 0 .75rem; line-height: 1.25; }
.markdown h2 { font-size: 1.3rem; margin: 1.75rem 0 .65rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
.markdown h4 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.markdown p { margin: 0 0 1rem; }
.markdown ul, .markdown ol { padding-left: 1.4rem; margin: 0 0 1rem; }
.markdown li { margin: .25rem 0; }
.markdown blockquote {
  margin: 0 0 1rem;
  padding: .5rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown blockquote > :last-child { margin-bottom: 0; }
.markdown code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: .1em .35em;
  border-radius: 4px;
}
.markdown pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
  font-size: .85rem;
  line-height: 1.5;
}
.markdown pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.markdown table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 1rem;
  font-size: .875rem;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: .4rem .6rem;
  text-align: left;
  vertical-align: top;
}
.markdown th { background: var(--surface); font-weight: 600; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.markdown a { text-decoration: underline; text-underline-offset: 2px; }

.loading { color: var(--muted); text-align: center; padding: 2rem 0; }
.error { color: #c0392b; text-align: center; padding: 1rem 0; }

.reader-footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .25rem;
  padding: .35rem .5rem;
  padding-bottom: calc(.35rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  min-height: var(--footer-h);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: .35rem;
  border-radius: var(--radius);
  font-size: 1.25rem;
  line-height: 1;
  transition: background .15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn:active { background: var(--border); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.reader-footer .icon-btn { width: 100%; font-size: 1.35rem; }

/* ============ Drawer ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(85vw, 340px);
  max-width: 100%;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: slide .22s ease;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(0); } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem .5rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
  -webkit-overflow-scrolling: touch;
}
.toc-list a {
  display: block;
  padding: .6rem 1rem;
  color: var(--fg);
  text-decoration: none;
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.toc-list a:hover { background: var(--surface); }
.toc-list a[data-level="3"] { padding-left: 2rem; font-size: .85rem; color: var(--muted); }
.toc-empty { padding: 1rem; color: var(--muted); font-size: .9rem; text-align: center; }

/* --- TOC sections --- */
.toc-section { padding: .25rem 0; }
.toc-section + .toc-section {
  margin-top: .5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.toc-section-title {
  padding: .5rem 1rem .35rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc-list a.active {
  background: var(--surface);
  border-left-color: var(--accent);
  font-weight: 600;
  color: var(--accent);
}

/* ============ Desktop ============ */
@media (min-width: 768px) {
  .reader-title { font-size: 1rem; }
  .markdown { padding-top: 2rem; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}