/* ============================================================
   PANDUAN SHOLAT — "Serene Paper & Mihrab"
   Spiritual-modern editorial: warm sand paper, deep teal ink,
   terracotta & gold accents, mihrab-arch frames.
   Fonts: Fraunces (display) · Plus Jakarta Sans (body) · Amiri (Arabic)
   ============================================================ */

:root {
  /* palette — paper & ink */
  --paper: #f6f0e3;
  --paper-2: #efe7d3;
  --panel: #fcf9f0;
  --ink: #23423a;
  --ink-soft: #51695f;
  --ink-faint: #7e908a;
  --teal: #2f5d50;
  --teal-deep: #1e3e35;
  --terra: #b9663d;
  --terra-soft: #f0ddd0;
  --gold: #b9985a;
  --gold-soft: #e9dcbc;
  --line: rgba(35, 66, 58, 0.16);
  --line-strong: rgba(35, 66, 58, 0.32);
  --shadow: 0 10px 30px -12px rgba(31, 62, 53, 0.25);
  --focus: 3px solid #b9663d;

  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-arabic: "Amiri", "Scheherazade New", "Geeza Pro", "Traditional Arabic", serif;

  --measure: 42rem;
  --radius: 18px;
  --arch: 50% 50% 12px 12px / 42% 42% 12px 12px;
}

:root[data-theme="night"] {
  --paper: #12201b;
  --paper-2: #17291f;
  --panel: #1b2f28;
  --ink: #ece4d0;
  --ink-soft: #bcc7bb;
  --ink-faint: #8fa096;
  --teal: #9cc6b4;
  --teal-deep: #cfe5da;
  --terra: #d98a5f;
  --terra-soft: #3a2c22;
  --gold: #cfae6a;
  --gold-soft: #3c351f;
  --line: rgba(236, 228, 208, 0.16);
  --line-strong: rgba(236, 228, 208, 0.34);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body { overflow-x: hidden; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  /* faint 8-point star lattice, barely-there */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%232f5d50' stroke-opacity='0.05' stroke-width='1'%3E%3Cpath d='M48 8 58 38 88 48 58 58 48 88 38 58 8 48 38 38Z'/%3E%3Cpath d='M48 24 54 42 72 48 54 54 48 72 42 54 24 48 42 42Z'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- a11y ---------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--teal-deep);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
  border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.2rem);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.wordmark em { color: var(--terra); font-style: normal; }
.wordmark-moon { width: 1.35rem; height: 1.35rem; color: var(--gold); flex: none; }

.topnav { display: flex; gap: clamp(0.4rem, 2vw, 1.4rem); flex-wrap: wrap; justify-content: flex-end; }
.topnav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.4rem 0.2rem;
  border-bottom: 2px solid transparent;
}
.topnav a:hover, .topnav a[aria-current="true"] { color: var(--terra); border-bottom-color: var(--gold); }

/* ---------- disclaimer ribbon ---------- */
.ribbon {
  background: var(--terra-soft);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem clamp(1rem, 4vw, 2.2rem);
  font-size: 0.86rem;
  line-height: 1.5;
}
.ribbon strong { color: var(--terra); }
.ribbon a { color: var(--teal); font-weight: 700; text-decoration: none; white-space: nowrap; }
.ribbon a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
main {
  display: block;
  min-height: 62vh;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 4vw, 2.2rem) 4.5rem;
}
.wrap { max-width: var(--measure); margin: 0 auto; }
.wrap-wide { max-width: 60rem; margin: 0 auto; }

/* staggered page-load reveal */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.reveal > * { animation: fadeUp 0.55s cubic-bezier(0.22, 0.8, 0.36, 1) both; }
.reveal > *:nth-child(1) { animation-delay: 0.03s; }
.reveal > *:nth-child(2) { animation-delay: 0.11s; }
.reveal > *:nth-child(3) { animation-delay: 0.19s; }
.reveal > *:nth-child(4) { animation-delay: 0.27s; }
.reveal > *:nth-child(5) { animation-delay: 0.35s; }
.reveal > *:nth-child(6) { animation-delay: 0.43s; }
.reveal > *:nth-child(7) { animation-delay: 0.51s; }
.reveal > *:nth-child(8) { animation-delay: 0.59s; }

/* ============================================================
   TYPE
   ============================================================ */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.1rem, 6.5vw, 3.4rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.45rem, 4vw, 2rem); }
h3 { font-size: 1.15rem; }

.kicker {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--gold);
  margin: 0 0 0.9rem;
}
.kicker::after {
  content: "";
  display: inline-block;
  width: 2.2rem;
  height: 1px;
  background: var(--gold);
  vertical-align: middle;
  margin-left: 0.7rem;
  opacity: 0.7;
}

.lead { font-size: 1.15rem; color: var(--ink-soft); }

/* ============================================================
   BUTTONS & CHIPS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 0.78rem 1.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fdfaf2; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--teal-deep); transform: translateY(-1px); }
:root[data-theme="night"] .btn-primary { background: #2f5d50; }
:root[data-theme="night"] .btn-primary:hover { background: #38705f; }
.btn-ghost { background: transparent; color: var(--teal); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 7%, transparent); }
.btn-quiet { background: var(--paper-2); color: var(--ink-soft); }
.btn-quiet:hover { color: var(--ink); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

.linklike {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--teal); font-weight: 700; cursor: pointer; text-decoration: underline;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  white-space: nowrap;
}
.chip-rukun { background: var(--terra); color: #fdf6ee; }
.chip-wajib { background: color-mix(in srgb, var(--terra) 82%, #000 8%); color: #fdf6ee; }
.chip-sunnah { border-color: var(--teal); color: var(--teal); background: transparent; }
.chip-syarat { border-color: var(--gold); color: color-mix(in srgb, var(--gold) 60%, var(--ink)); }
.chip-info { background: var(--paper-2); color: var(--ink-soft); }
.chip-repeat { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 40%, var(--ink)); }

/* ============================================================
   HOME
   ============================================================ */
.hero { display: grid; gap: clamp(1.5rem, 4vw, 3rem); align-items: center; }
@media (min-width: 820px) { .hero { grid-template-columns: 1.1fr 0.9fr; } }

.hero-art {
  border-radius: var(--arch);
  overflow: hidden;
  border: 1px solid var(--line);
  outline: 1px solid var(--gold);
  outline-offset: 5px;
  box-shadow: var(--shadow);
}
.hero-art img { display: block; width: 100%; height: 100%; object-fit: cover; }

.hero-ctas { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.6rem; }

.notice {
  margin-top: clamp(2rem, 5vw, 3rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--terra);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  font-size: 0.95rem;
}
.notice h3 { color: var(--terra); margin-bottom: 0.35rem; font-family: var(--font-body); font-weight: 800; font-size: 0.95rem; }
.notice p { margin: 0.3rem 0; color: var(--ink-soft); }

.home-grid { display: grid; gap: 1rem; margin-top: clamp(2rem, 5vw, 3rem); }
@media (min-width: 680px) { .home-grid { grid-template-columns: repeat(3, 1fr); } }

.tile {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--gold); }
.tile h3 { margin-bottom: 0.2rem; }
.tile p { margin: 0; font-size: 0.88rem; color: var(--ink-soft); }
.tile .tile-n { font-family: var(--font-display); font-size: 0.85rem; color: var(--gold); }

/* prayers table */
.prayers { margin-top: clamp(2rem, 5vw, 3rem); }
.prayer-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.85rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
.prayer-row:first-of-type { border-top: 1px solid var(--line); }
.prayer-name { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.prayer-time { color: var(--ink-faint); font-size: 0.85rem; }
.prayer-rakaat { font-weight: 800; color: var(--terra); white-space: nowrap; }
.prayer-loud { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }

/* ============================================================
   STEP-BY-STEP GUIDE
   ============================================================ */
.progress {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.4rem;
}
.progress-label { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; color: var(--ink-soft); white-space: nowrap; }
.progress-track { flex: 1; height: 4px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--terra)); border-radius: 999px; transition: width 0.4s cubic-bezier(0.22, 0.8, 0.36, 1); }

.toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.toggle {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
}
.toggle[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fdfaf2; }
.toggle-hafalan[aria-pressed="true"] { background: var(--terra); border-color: var(--terra); }

.step-card { animation: fadeUp 0.4s cubic-bezier(0.22, 0.8, 0.36, 1) both; }

.step-figure {
  width: min(46vw, 220px);
  margin: 0 auto 1.4rem;
  border-radius: var(--arch);
  overflow: hidden;
  border: 1px solid var(--line);
  outline: 1px solid var(--gold);
  outline-offset: 4px;
  background: var(--paper-2);
}
.step-figure img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }

.step-head { text-align: center; margin-bottom: 1.2rem; }
.step-chips { display: flex; justify-content: center; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.step-title { margin-bottom: 0.25rem; }
.step-move { color: var(--ink-soft); font-size: 0.97rem; max-width: 34rem; margin: 0 auto; }

.arabic {
  font-family: var(--font-arabic);
  direction: rtl;
  text-align: center;
  white-space: pre-line;
  font-size: clamp(1.9rem, 6.5vw, 2.9rem);
  line-height: 2.05;
  color: var(--ink);
  margin: 1.6rem 0 0.8rem;
  font-weight: 400;
}
.arabic-sm { font-size: clamp(1.5rem, 5vw, 2.1rem); line-height: 2; }

.translit {
  text-align: center;
  white-space: pre-line;
  color: var(--teal-deep);
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0 auto 0.6rem;
  max-width: 36rem;
}
.arti {
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
  white-space: pre-line;
  color: var(--ink-soft);
  font-size: 1.08rem;
  max-width: 34rem;
  margin: 0 auto 1.4rem;
}
.arti::before { content: "“"; color: var(--gold); }
.arti::after { content: "”"; color: var(--gold); }

.meaning {
  background: var(--paper-2);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.95rem 1.15rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 1.2rem 0;
}
.meaning strong:first-child { color: var(--ink); }

.source-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--ink-faint);
  margin: 1rem 0 0.3rem;
  line-height: 1.5;
}
.source-line svg { flex: none; width: 1rem; height: 1rem; margin-top: 0.15rem; color: var(--gold); }
.source-line a { color: var(--teal); font-weight: 600; text-decoration: none; }
.source-line a:hover { text-decoration: underline; }
.source-grade { font-weight: 700; color: var(--ink-soft); }

details.variants { margin: 0.8rem 0 0; font-size: 0.88rem; color: var(--ink-soft); }
details.variants summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
details.variants summary:hover { color: var(--terra); }
details.variants ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
details.variants li { margin-bottom: 0.35rem; }

/* hafalan (memorization) mode */
.veil {
  position: relative;
  cursor: pointer;
  border-radius: 12px;
}
.veil.is-hidden > .veil-content { filter: blur(9px); opacity: 0.45; user-select: none; }
.veil .veil-hint {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--terra);
}
.veil.is-hidden .veil-hint { display: flex; }

.hafalan-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 1.2rem 0;
}
.hafalan-count {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--terra);
  min-width: 3.2rem;
  text-align: center;
}
@keyframes pop { 50% { transform: scale(1.25); } }
.hafalan-count.pop { animation: pop 0.3s ease; }

/* prev/next bar */
.stepbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.7rem;
  padding: 0.8rem 0 max(0.8rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 65%, transparent);
  margin-top: 2rem;
}
.stepbar .btn { flex: 1; }

/* step jump strip */
.stepjump {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.3rem 0.1rem 0.8rem;
  scrollbar-width: thin;
  margin-bottom: 1rem;
}
.stepjump button {
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}
.stepjump button.done { border-color: var(--gold); color: var(--gold); }
.stepjump button[aria-current="true"] { background: var(--teal); border-color: var(--teal); color: #fdfaf2; }

/* ============================================================
   REFERENCE LISTS (rukun, kesalahan, sumber)
   ============================================================ */
.ref-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin-bottom: 0.9rem;
}
.ref-item h3 { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.ref-item p { margin: 0.3rem 0; font-size: 0.95rem; color: var(--ink-soft); }
.ref-num {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 700;
  min-width: 1.6rem;
}

.mistake-fix { color: var(--teal); font-weight: 600; }
.mistake-fix::before { content: "✓ "; color: var(--gold); }

.sources-group { margin-bottom: 2rem; }
.sources-group h3 { border-bottom: 2px solid var(--gold-soft); padding-bottom: 0.4rem; }
.sources-group li { margin-bottom: 0.5rem; font-size: 0.92rem; color: var(--ink-soft); }
.sources-group a { color: var(--teal); text-decoration: none; font-weight: 600; }
.sources-group a:hover { text-decoration: underline; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer { border-top: 1px solid var(--line); background: var(--paper-2); }
.footer-inner { max-width: var(--measure); margin: 0 auto; padding: 1.6rem clamp(1rem, 4vw, 2.2rem); }
.footer-note { font-size: 0.85rem; color: var(--ink-soft); margin: 0 0 0.6rem; }
.footer-links { font-size: 0.85rem; margin: 0; }
.footer-links a { color: var(--teal); font-weight: 600; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* ============================================================
   SEO fallback (pre-rendered content shown before JS / to crawlers)
   app.js replaces #main on load, so JS users rarely see this.
   ============================================================ */
.seo-fallback { max-width: var(--measure); margin: 0 auto; }
.seo-fallback h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); }
.seo-fallback h2 { margin-top: 2rem; border-bottom: 1px solid var(--line); padding-bottom: 0.3rem; }
.seo-fallback .seo-lead { font-size: 1.1rem; color: var(--ink-soft); }
.seo-fallback .seo-disclaimer {
  background: var(--terra-soft);
  border-left: 4px solid var(--terra);
  padding: 0.9rem 1.1rem;
  border-radius: 0 10px 10px 0;
}
.seo-fallback img { max-width: 200px; height: auto; border-radius: 12px; display: block; margin: 0.6rem 0; }
.seo-fallback table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; }
.seo-fallback th, .seo-fallback td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); }
.seo-fallback .seo-translit { color: var(--teal-deep); }
.seo-fallback .seo-src { font-size: 0.85rem; color: var(--ink-faint); }
.seo-fallback .seo-var { font-size: 0.85rem; color: var(--ink-faint); }
.seo-fallback .seo-step { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }

/* ============================================================
   PRINT — linear document, ink on white
   ============================================================ */
#print-doc { display: none; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .ribbon, .footer, main, .skip-link, noscript { display: none !important; }
  #print-doc { display: block; padding: 0; color: #000; }
  #print-doc h1, #print-doc h2, #print-doc h3 { font-family: var(--font-display); color: #000; }
  #print-doc h1 { font-size: 20pt; margin-bottom: 4pt; }
  #print-doc h2 { font-size: 15pt; margin: 18pt 0 6pt; border-bottom: 1pt solid #999; padding-bottom: 3pt; }
  #print-doc .p-disclaimer {
    border: 1.5pt solid #000;
    padding: 8pt 10pt;
    margin: 10pt 0 14pt;
    font-weight: 600;
    font-size: 10pt;
  }
  #print-doc .p-step { page-break-inside: avoid; margin-bottom: 14pt; padding-bottom: 10pt; border-bottom: 0.5pt solid #ccc; }
  #print-doc .p-cat { font-size: 8pt; font-weight: 800; text-transform: uppercase; letter-spacing: 1pt; }
  #print-doc .arabic { font-size: 18pt; line-height: 2; margin: 8pt 0 4pt; text-align: right; }
  #print-doc .p-translit { font-style: italic; font-size: 10.5pt; margin: 2pt 0; }
  #print-doc .p-arti { font-size: 10.5pt; margin: 2pt 0 6pt; }
  #print-doc .p-src { font-size: 8.5pt; color: #333; }
  #print-doc img { display: none; }
}
