/* ======================================================
   GLOBAL RESET & SAFETY
====================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

.no-copy {
  user-select: none;
  -webkit-user-select: none;
}

/* ======================================================
   DESIGN TOKENS (APPLE-LIKE SYSTEM)
====================================================== */
:root {
  /* Backgrounds */
  --bg-main: #fafafa;
  --bg-card: #ffffff;
  --bg-muted: #f2f2f7;

  /* Text */
  --text-main: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-translation: #3a3a3c;

  /* Accent */
  --accent: #bfa742;
  --accent-soft: rgba(191, 167, 66, 0.14);

  /* Borders & Shadows */
  --border-light: rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 10px 30px rgba(0,0,0,0.04);

  /* Radius */
  --radius-lg: 20px;
  --radius-md: 14px;

  /* Fonts */
  --font-quran: "Amiri Quran", serif;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;

  /* Reading Controls */
  --font-scale: 1;
  --line-scale: 1;

  --reading-line-opacity: 0.14;
}

/* ======================================================
   BODY
====================================================== */
body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-quran);
  padding-bottom: 120px;
  -webkit-font-smoothing: antialiased;
}

/* ======================================================
   TOP BAR
====================================================== */
.juzz-top-bar {
  position: sticky;
  top: 0;
  z-index: 100;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 12px 16px;
  background: rgba(250, 250, 250, 0.94);
  backdrop-filter: saturate(180%) blur(10px);

  border-bottom: 1px solid var(--border-light);
}

.back-btn {
  position: absolute;
  left: 16px;
  font-size: 20px;
  color: var(--accent);
  text-decoration: none;
}

.juzz-title-wrap {
  text-align: center;
}

.juzz-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.juzz-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ======================================================
   READING SETTINGS BUTTON
====================================================== */
.reading-settings-btn {
  position: absolute;
  right: 16px;

  min-width: 36px;
  height: 32px;

  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;

  border-radius: 10px;
  border: 1px solid var(--border-light);

  background: var(--bg-card);
  color: var(--text-main);

  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.reading-settings-btn:active {
  transform: scale(0.96);
}

/* ======================================================
   SETTINGS PANEL
====================================================== */
.reading-settings-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 200;

  width: 260px;
  padding: 18px;

  background: var(--bg-card);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);

  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;

  transition: opacity 0.25s ease, transform 0.25s ease;
}

.reading-settings-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ======================================================
   SETTINGS CONTENT
====================================================== */
.settings-section {
  margin-bottom: 18px;
}

.settings-title {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-ui);
}

.settings-controls {
  display: flex;
  gap: 10px;
}

.settings-controls button {
  flex: 1;
  min-height: 42px;

  border-radius: 12px;
  border: 1px solid var(--border-light);

  background: var(--bg-muted);
  font-family: var(--font-ui);
  font-size: 14px;

  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.settings-controls button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.settings-controls button:active {
  transform: scale(0.96);
}

/* ======================================================
   MOBILE SETTINGS (BOTTOM SHEET)
====================================================== */
@media (max-width: 640px) {
  .reading-settings-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;

    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px env(safe-area-inset-bottom);

    transform: translateY(100%);
    opacity: 1;
  }

  .reading-settings-panel.open {
    transform: translateY(0);
  }
}

/* ======================================================
   JUZ CONTAINER
====================================================== */
.juzz-container {
  max-width: 720px;
  margin: auto;
  padding: 28px 16px 0;
}

/* ======================================================
   SURAH HEADER
====================================================== */
.surah-section {
  margin-bottom: 56px;
}

.surah-name {
  text-align: center;
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 28px;
  color: var(--accent);
}

/* ======================================================
   AYAH CARD
====================================================== */
.ayah-card {
  position: relative;
  margin-bottom: 40px;
  padding: 30px 26px;

  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);

  scroll-margin-top: 120px;
}

/* ======================================================
   ARABIC AYAH
====================================================== */
.ayah-text {
  direction: rtl;
  text-align: center;

  font-size: calc(1.55rem * var(--font-scale));
  line-height: calc(3.7rem * var(--line-scale));

  max-width: 42ch;
  margin: auto;

  font-feature-settings: "liga" 1, "calt" 1;

  background-image: linear-gradient(
    to bottom,
    transparent 86%,
    rgba(0, 0, 0, var(--reading-line-opacity)) 86%,
    rgba(0, 0, 0, var(--reading-line-opacity)) 88%,
    transparent 88%
  );
  background-size: 100% calc(3.7rem * var(--line-scale));
}

.ayah-number {
  font-size: 1.05rem;
  color: var(--accent);
  margin-inline-start: 0.4rem;
}

/* ======================================================
   ENGLISH TRANSLATION
====================================================== */
.ayah-translation {
  margin-top: 18px;
  text-align: center;

  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.75;

  color: var(--text-translation);
  max-width: 48ch;
  margin-left: auto;
  margin-right: auto;
}

/* ======================================================
   BOOKMARK MARKER
====================================================== */
.ayah-marker {
  position: absolute;
  left: 16px;
  top: 22px;

  width: 12px;
  height: 12px;
  border-radius: 50%;

  background: rgba(191, 167, 66, 0.25);
  cursor: pointer;
}

.ayah-card.marked {
  background: var(--accent-soft);
}

.ayah-card.marked .ayah-marker {
  background: var(--accent);
}

/* ======================================================
   FLOATING BOOKMARK BUTTON
====================================================== */
.floating-bookmark-btn {
  position: fixed;
  right: 18px;
  bottom: 96px;

  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;

  background: rgba(191, 167, 66, 0.9);
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  z-index: 999;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
}

.floating-bookmark-btn[hidden] {
  display: none;
}

/* ======================================================
   AUDIO BAR
====================================================== */
.audio-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;

  padding: 12px 14px;
  background: rgba(65, 64, 64, 0.037);
  backdrop-filter: blur(8px);

  border-top: 1px solid var(--border-light);
  z-index: 60;

  display: flex;
  justify-content: center;
}

.audio-bar audio {
  width: min(700px, 100%);
  border-radius: var(--radius-md);
}





/* DIM MODE → darker professional gray/blue (#0e1520 feel) */
body.dim audio {
  filter:
    invert(0.92)       /* darker base */
    hue-rotate(180deg) /* keep tint natural */
    brightness(0.80)   /* slightly darker */
    contrast(1);       /* maintain clarity */
  opacity: 0.95;       /* subtle polish */
}

/* DARK MODE → deep professional gray/blue (#0e1520 feel) */
body.dark audio {
  filter:
    invert(0.92)       
    hue-rotate(180deg) 
    brightness(0.75)   /* slightly darker than dim mode */
    contrast(1);       
  opacity: 0.95;       
}



/* ================= AUDIO PLAYER ================= */


/* ======================================================
   DARK & DIM MODES
====================================================== */
body.dim {
  --bg-main: #0f141c;
  --bg-card: #161e2f;
  --bg-muted: #141c2d;

  --text-main: #f2f2f7;
  --text-secondary: #a1a1aa;
  --text-translation: #c7c7cc;

  --border-light: rgba(255,255,255,0.08);
}

body.dark {
  --bg-main: #000000;
  --bg-card: #0b1020;
  --bg-muted: #050e34;

  --text-main: #f2f2f7;
  --text-secondary: #a1a1aa;
  --text-translation: #d1d1d6;

  --border-light: rgba(255,255,255,0.08);
}

body.dim .ayah-text,
body.dark .ayah-text {
  background-image: linear-gradient(
    to bottom,
    transparent 86%,
    rgba(255,255,255, calc(var(--reading-line-opacity) + 0.04)) 86%,
    rgba(255,255,255, calc(var(--reading-line-opacity) + 0.04)) 88%,
    transparent 88%
  );
}

/* ======================================================
   SMALL MOBILE POLISH
====================================================== */
@media (max-width: 480px) {
  .ayah-text {
    max-width: 34ch;
  }

  .ayah-translation {
    font-size: 0.92rem;
  }

  .juzz-title,
  .surah-name {
    font-size: 18px;
  }
}
