:root {
  --font-scale: 1;
  --bg: #ffffff;
  --bg-page: #ffffff;
  --ink: #16191c;
  --ink-soft: #5c6570;
  --accent: #147c6f;
  --accent-soft: #e7f4f1;
  --gold: #a97a2f;
  --border: #e7e9ec;
  --shadow: 0 12px 28px -16px rgba(16, 23, 26, 0.16);
  --radius: 18px;
}

html[data-theme="sepia"] {
  --bg: #ecdfc2;
  --bg-page: #f3e8cd;
  --ink: #3a2f1c;
  --ink-soft: #7a6a48;
  --accent: #7a5a20;
  --accent-soft: #e6d6ac;
  --gold: #8a5a1f;
  --border: #d8c398;
}

html[data-theme="night"] {
  --bg: #17181c;
  --bg-page: #1e2025;
  --ink: #e9e4d8;
  --ink-soft: #a29d8f;
  --accent: #6fb8ab;
  --accent-soft: #262b2a;
  --gold: #d1a45f;
  --border: #33322d;
}

* {
  box-sizing: border-box;
}

html,
body {
  padding: 0;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  line-height: 1.55;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 3.25rem;
  height: 3.25rem;
}

.brand-small {
  font-size: 1.15rem;
}

/* ---------- Header / hero (home) ---------- */

.site-header {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.continue-link {
  font-size: 0.95rem;
  color: var(--accent);
}

.hero {
  max-width: 720px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2rem;
  text-align: center;
}

.hero h1 {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 1rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  text-decoration: none;
  filter: brightness(1.05);
}

.btn-ghost {
  border-color: var(--border);
  color: var(--ink);
}

.btn-ghost:hover {
  text-decoration: none;
  background: var(--accent-soft);
}

.search-section {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

#surah-search {
  width: 100%;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}

#surah-search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.surah-grid {
  max-width: 960px;
  margin: 2rem auto 0;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.surah-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
}

/* Small gallery-mount brackets that sharpen on hover, echoing the mushaf
   page's corner marks so the surah grid reads as pieces in a gallery. */
.surah-card::before,
.surah-card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--gold);
  opacity: 0.35;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.surah-card::before {
  top: 6px;
  left: 6px;
  border-right: none;
  border-bottom: none;
}

.surah-card::after {
  bottom: 6px;
  right: 6px;
  border-left: none;
  border-top: none;
}

.surah-card:hover::before,
.surah-card:hover::after {
  opacity: 0.85;
}

.surah-card:hover {
  text-decoration: none;
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.surah-number {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.surah-names {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.surah-en {
  font-weight: 600;
}

.surah-translation {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.surah-ar {
  font-family: "Amiri Quran", serif;
  font-size: 1.2rem;
  color: var(--ink);
}

.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-align: center;
}

.footer-links {
  margin-top: 0.4rem;
}

/* ---------- Reader ---------- */

.reader-header {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.reader-tools {
  display: flex;
  gap: 0.4rem;
}

.reader-tools button {
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink);
  font-size: 0.9rem;
}

.reader-tools button[aria-pressed="false"] {
  color: var(--ink-soft);
  background: transparent;
}

.reader-tools button:hover {
  border-color: var(--accent);
}

.page-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.first-visit-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--accent-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.7rem 0.6rem 0.7rem 1.1rem;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.first-visit-hint button {
  flex-shrink: 0;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
}

.first-visit-hint button:hover {
  background: rgba(0, 0, 0, 0.06);
}

.mushaf-page {
  position: relative;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.75rem 1.75rem 2.5rem;
}

/* Gallery-style corner mounts, like a print mounted under glass. */
.corner-mark {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gold);
  opacity: 0.55;
  pointer-events: none;
}

.corner-mark-tl {
  top: 14px;
  left: 14px;
  border-right: none;
  border-bottom: none;
}

.corner-mark-tr {
  top: 14px;
  right: 14px;
  border-left: none;
  border-bottom: none;
}

.corner-mark-bl {
  bottom: 14px;
  left: 14px;
  border-right: none;
  border-top: none;
}

.corner-mark-br {
  bottom: 14px;
  right: 14px;
  border-left: none;
  border-top: none;
}

.page-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.page-meta-center {
  font-weight: 700;
  color: var(--gold);
}

.surah-heading {
  text-align: center;
  margin: 1.5rem 0 1rem;
}

.surah-heading-line {
  height: 1px;
  background: var(--border);
  margin-bottom: 1rem;
}

.surah-heading h2 {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.surah-heading-ar {
  font-family: "Amiri Quran", serif;
  font-size: 1.7rem;
  color: var(--accent);
}

.surah-heading-en {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.bismillah {
  text-align: center;
  font-family: "Amiri Quran", serif;
  font-size: calc(1.5rem * var(--font-scale));
  color: var(--accent);
  margin: 0 0 1.25rem;
}

.ayah-block {
  font-family: "Amiri Quran", serif;
  font-size: calc(1.55rem * var(--font-scale));
  line-height: 2.35;
  text-align: justify;
  text-align-last: center;
  margin: 0 0 1rem;
}

.ayah {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.1em 0.05em;
}

.ayah:hover,
.ayah.playing {
  background: var(--accent-soft);
}

.ayah-end {
  display: inline-block;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 0.65em;
  color: var(--gold);
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  width: 1.6em;
  height: 1.6em;
  line-height: 1.55em;
  text-align: center;
  margin: 0 0.15em;
  vertical-align: middle;
}

.sajda-mark {
  color: var(--gold);
  font-size: 0.85em;
}

.translation-block {
  border-top: 1px dashed var(--border);
  margin-top: 1.25rem;
  padding-top: 1rem;
}

.translation-line {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
}

.translation-ref {
  color: var(--gold);
  font-weight: 600;
}

html[data-translation="off"] .translation-block {
  display: none;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 1rem;
}

.page-nav-btn {
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink);
}

.page-nav-btn:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.page-nav-btn[aria-disabled="true"] {
  opacity: 0.35;
  pointer-events: none;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

#page-jump-input {
  width: 3.4rem;
  text-align: center;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink);
  font-family: inherit;
}

/* ---------- Static prose pages ---------- */

.prose-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
}

.prose-page h1 {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.prose-page h2 {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 2rem;
}

.prose-page p,
.prose-page li {
  color: var(--ink-soft);
}

@media (max-width: 560px) {
  .surah-grid {
    grid-template-columns: 1fr;
  }
  .mushaf-page {
    padding: 1.5rem 1.1rem 2rem;
  }
}
