:root {
  --bg: #000;
  --panel: #0a0a0a;
  --text: #eee;
  --muted-text: #b3b3b3;
  --muted-text-2: #686868;
  --muted-text-3: #1f1f1f;
  --muted-bg: #ffffff05;
  --hover: #ffffff10;
  --border: #33333350;
  --accent: #2ca4ab;
  --accent-translucent: #2ca4ab50;
  --indopak-font-size: 4.4vh;
  --max-img-height: 100vh;
  --max-img-width: auto;
  --sidebar-width: 56px;
}

.theme-sunset {
  --bg: #fff5e4;
  --panel: #fff5e4;
  --text: #0a0a0a;
  --muted-text: #333;
  --muted-text-2: #a39789;
  --muted-text-3: #b9a692;
  --muted-bg: #b9a69225;
  --hover: #b9a69225;
  --border: #e6d5c0;
  --accent: #72603f;
  --accent-translucent: #72603f77;
}

:root::selection {
  background: var(--accent-translucent);
  color: #f9f9f9;
}

.theme-sunset::selection {
  background: var(--accent-translucent);
  color: #f9f9f9;
}

#settingsOverlay.open {
  pointer-events: auto;
}

#settingsOverlay.open #settingsPanel {
  transform: translate(0, 0);
  opacity: 1;
}

#settingsPanel h3 {
  margin: 0 0 12px 0;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.theme-section {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

/* square sample buttons */
.theme-sample {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  padding: 5px;
  border: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
}

.theme-sample img {
  height: 100%;
  object-fit: cover;
  display: block;
}

.theme-sample.active {
  border: 1px solid var(--border);
}

.theme-labels {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
  color: var(--muted-text-2);
  font-size: 10px;
}

.theme-labels div {
  width: 96px;
  text-align: center;
}

.settings-select {
  width: 100%;
  padding: 8px 10px;
  padding-right: 32px;
  /* extra space for the arrow */
  font-size: 14px;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid var(--muted-text-3);
  background: var(--panel);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.settings-select:hover {
  border-color: var(--muted-text-2);
}

.settings-stepper {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 10px;
}

.settings-stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--muted-text-3);
  background: var(--panel);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.settings-stepper-btn:hover {
  background-color: var(--muted-text-3);
}

.settings-stepper-value {
  text-align: center;
  font-size: 14px;
  color: var(--text);
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.indopak-preview-box {
  background: var(--bg);
  border: 1px solid var(--border);
  min-height: 150px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.indopak-preview-text {
  font-family: 'IndoPakNastaleeq', serif;
  font-size: var(--indopak-font-size);
  line-height: 1.45;
  text-align: center;
  direction: rtl;
}


body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Arial', sans-serif;
  transition: background 260ms ease, color 260ms ease;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  justify-content: center;
  display: flex;
  align-items: center;
}

* {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

a:focus,
button:focus,
input:focus,
select:focus,
[tabindex]:focus {
  outline: none;
}

@font-face {
  font-family: 'SFPro';
  src: url('assets/Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SuraNames';
  src: url('assets/sura_names.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bismillah';
  src: url('assets/bismillah.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IndoPakNastaleeq';
  src: url('assets/indopak.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
}

.page-container {
  aspect-ratio: 1 / 1.6;
  height: 90vh;
  padding: 0 6%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  position: relative;
}

.page-header {
  position: fixed;
  top: 3.3cqh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  cursor: default;
  display: flex;
  opacity: 95%;
  justify-content: space-between;
  align-items: center;
  min-width: 46cqh;
  gap: 15px;
  margin: 0;
}

.page-footer {
  position: fixed;
  bottom: 3.3cqh;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-family: 'SFPro', sans-serif;
  font-size: 2cqh;
  opacity: 0.95;
  cursor: default;
}

#juz-label,
#surah-label {
  font-family: 'SFPro', sans-serif;
  font-size: 1.8cqh;
}

#mushaf-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 1vh;
}

.mushaf-line {
  display: flex;
  justify-content: center;
  direction: rtl;
  width: 100%;
  font-size: 3.3vh;
  line-height: 1.7;
  gap: 0.011vw;
}

body.page-1 .mushaf-line:not(.surah-header):not(.bismillah) { margin-bottom: -1vh; }
body.page-2 .mushaf-line:not(.surah-header):not(.bismillah) { margin-bottom: -1vh; }
body.page-1 #mushaf-page { margin-top: 1.5vh; justify-content: space-between; }
body.page-2 #mushaf-page { margin-top: 1.5vh; justify-content: space-between; }

body.page-2 .bismillah { font-size: 1.3vw; }

.verse-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  overflow-y: auto;
  padding: 2rem 1rem;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.verse-modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.verse-modal {
  cursor: default;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 3rem 1rem 2rem 1rem;
  width: 80%;
  border-radius: 12px;
  position: relative;
  direction: rtl;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.verse-modal-content {
  padding: 0.8rem 0;
  overflow-y: auto;
  direction: rtl;
}

.verse-modal-content {
  border-top: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.verse-modal-header {
  display: flex;
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  direction: ltr;
  text-align: center;
  pointer-events: none;
}

.verse-modal-surah-name {
  font-family: 'SuraNames', sans-serif;
  font-size: 1.1rem;
  padding: 0 0.2rem;
}

.modal-btn {
  display: flex;
  position: absolute;
  top: 10px;
  cursor: pointer;
  padding: 7px;
  border-radius: 5px;
  transition: background-color 0.2s ease;
}

.modal-btn:hover {
  background-color: #ffffff10;
}

.verse-modal-nav.prev {
  left: 3.5rem;
}

.verse-modal-nav.next {
  left: 1rem;
}

.verse-modal-toggle-layout {
  left: 6rem;
}

.verse-modal-arabic {
  line-height: 1.6;
  font-size: var(--indopak-font-size);
  text-align: right;
  margin-bottom: 1.5rem;
}

.verse-modal-translation {
  direction: ltr;
  text-align: left;
  font-size: 2.2vh;
  font-weight: 300;
  opacity: 0.9;
}

.verse-footnote-trigger {
  color: var(--accent);
  padding: 0 3px;
  cursor: pointer;
  user-select: none;
}

.verse-footnote-trigger:hover {
  text-decoration: underline;
}

.verse-footnote-frame {
  position: relative;
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid var(--muted-text-3);
  border-radius: 8px;
  background: var(--muted-bg);
  direction: ltr;
  text-align: left;
}

.verse-footnote-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 13px;
  padding-right: 22px;
}

.verse-footnote-body {
  font-weight: 300;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
}

.verse-footnote-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  line-height: 1;
}
.verse-footnote-close svg {
  width: 50%;
  height: 50%;
}

.verse-footnote-close:hover {
  background-color: var(--muted-text-3);
}

/* Skeleton shimmer animation */
@keyframes verseSkeletonShimmer {
  0% {
    background-position: -400px 0;
  }

  100% {
    background-position: 400px 0;
  }
}

.verse-skeleton-line {
  height: 1em;
  margin: 0.6em 0;
  border-radius: 6px;
  background: linear-gradient(90deg,
      rgba(200, 200, 200, 0.1) 25%,
      rgba(200, 200, 200, 0.3) 50%,
      rgba(200, 200, 200, 0.1) 75%);
  background-size: 400px 100%;
  animation: verseSkeletonShimmer 1.2s ease-in-out infinite;
}

/* Arabic skeleton slightly taller */
.verse-skeleton-line.arabic {
  height: 1.4em;
}

/* Optional: reduce opacity for dark mode */
body.dark .verse-skeleton-line {
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.05) 25%,
      rgba(255, 255, 255, 0.15) 50%,
      rgba(255, 255, 255, 0.05) 75%);
}

.word {
  position: relative;
  cursor: pointer;
}

.word::after {
  font-family: "SFPro", sans-serif;
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  /* above the word */
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 0em 0.5em;
  font-size: 1.9cqh;
  border-radius: 5px;
  white-space: nowrap;
  box-shadow: 0 0px 6px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.word:hover::after {
  opacity: 1;
}

.word:hover {
  color: var(--accent);
  border-radius: 4px;
}

.verse-modal-item.verse-focused {
  animation: verse-focus-pulse 1.2s ease;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.08);
}

@keyframes verse-focus-pulse {
  0% {
    transform: translateY(0);
    background: var(--accent-translucent);
  }

  50% {
    background: var(--accent-translucent);
    transform: translateY(-2px);
  }

  100% {
    transform: translateY(0);
    background: transparent;
  }
}

.verse-modal-item {
  position: relative;
}

.verse-modal-top-left {
  top: 1vh;
  left: 1.5vw;
  padding: 0 0 2.2vh 0;
  display: flex;
  align-items: center;
  gap: 0.6vw;
  font-size: 2vh;
  color: var(--muted-text-2);
  direction: ltr;
}

.custom-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--muted-text-3);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  transform: translateY(6px) scale(.96);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms cubic-bezier(.2, .9, .2, 1);
  z-index: 14000;
  box-shadow: 0 0px 5px rgba(0, 0, 0, 0.05);
  will-change: transform, opacity;
}

.custom-tooltip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.verse-separator {
  opacity: 90%;
}

.highlighted {
  color: var(--accent);
}

.surah-header {
  font-size: 3.55cqh;
  direction: ltr;
  unicode-bidi: embed;
  position: relative;
}

.surah-num {
  font-family: 'surah-name';
  color: var(--text);
}

.surah-header-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('assets/header.svg') no-repeat center;
  background-size: auto 95%;
  z-index: 0;
  filter: none;
}

body:not(.theme-sunset) .surah-header-bg {
  filter: invert(1);
}

.surah-header-text {
  cursor: default;
  position: relative;
  z-index: 1;
  font-family: 'surah-name';
}

.bismillah {
  cursor: default;
  font-family: "Bismillah";
  font-size: 3.2cqh;
  direction: ltr;
  unicode-bidi: embed;
}

#navOverlay,
#settingsOverlay {
  direction: ltr;
  position: fixed;
  inset: 0;
  display: block;
  z-index: 10000;
  background: transparent;
  pointer-events: none;
}

#navPanel,
#settingsPanel {
  position: absolute;
  right: 0;
  transition: transform 320ms cubic-bezier(.2, .9, .2, 1), opacity 220ms ease, background 260ms ease, color 260ms ease, border-color 260ms ease;
  background: var(--panel);
  color: var(--text);
  padding: 24px 14px;
  width: min(320px, 92%);
  height: 100%;
  border: 1px solid var(--border);
  box-shadow: 0 0px 5px rgba(0, 0, 0, 0.05);
  transform: translate(120%, 0);
  opacity: 0;
  will-change: transform, opacity;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* nav tabs */
.nav-tabs {
  align-items: center;
  justify-content: center;
  background: var(--muted-bg);
  border-radius: 999px;
}

.nav-tab {
  background: transparent;
  width: 50%;
  border: none;
  color: var(--muted-text-2);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 150ms ease;
}

.nav-tab:first-child {
  border-radius: 999px 0 0 999px;
}

.nav-tab:last-child {
  border-radius: 0 999px 999px 0;
}

.nav-tab:not(:first-child):not(:last-child) {
  border-radius: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.nav-tab:hover {
  background-color: var(--muted-bg);
}

.nav-tab[aria-pressed="true"] {
  background-color: var(--muted-text-3);
  color: #fff;
}

.surah-name {
  font-size: 14px;
  color: var(--text);
}

h3 {
  margin: 0px 2px 0px 0px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

#navOverlay.open {
  pointer-events: auto;
}

#navOverlay.open #navPanel {
  transform: translate(0, 0);
  opacity: 1;
}

/* search input */
#navSearch {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  font-size: 14px;
}

#navSearch::placeholder {
  color: var(--muted-text-2);
}

/* remove browser-specific "clear" / "x" on search inputs */
#navSearch::-webkit-search-decoration,
#navSearch::-webkit-search-cancel-button,
#navSearch::-webkit-search-results-button,
#navSearch::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

#navSearch::-ms-clear,
#navSearch::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

.nav-list {
  overflow: auto;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  box-sizing: border-box;
  height: 85vh;
  /* fixed height as requested */
  width: 100%;
  /* responsive width but fixed height */
}
.settings-scroll {
  overflow: auto;
  background: transparent;
  border: none;
  box-sizing: border-box;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.settings-scroll::-webkit-scrollbar {
  width: 0px;
  height: 10px;
}
.settings-scroll::-webkit-scrollbar-thumb {
  display: none;
}
.settings-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* scrollbar theming */
.nav-list::-webkit-scrollbar {
  width: 0px;
  height: 10px;
}

.nav-list::-webkit-scrollbar-thumb {
  display: none;
}

body.theme-sunset .nav-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.05);
}

.nav-list::-webkit-scrollbar-track {
  background: transparent;
}

.small-num {
  font-family: "SuraNames";
  display: flex;
  padding-right: 5px;
  font-size: 14px;
}

/* surah item layout - uniform sizes and consistent alignment */
.surah-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
  padding: 10px;
  /* reset padding so children control spacing uniformly */
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 160ms ease;
  height: 72px;
  box-sizing: border-box;
  overflow: hidden;
}

.surah-item:first-child {
  border-radius: 8px 8px 0 0;
}

.surah-item:last-child {
  border-radius: 0 0 8px 8px;
}

.surah-item:not(:first-child):not(:last-child) {
  border-radius: 0;
}

.surah-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

/* left section: name + verses - aligned to left and takes remaining space */
.surah-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* vertically center content within the fixed item height */
  align-items: flex-start;
  /* ensure left alignment */
  gap: 5px;
  padding-left: 5px;
}

/* surah name + number row: keep close together */
.surah-title-row {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
}

/* verses count muted */
.surah-verses {
  display: flex;
  font-size: 12px;
  color: var(--muted-text-2);
  line-height: 1;
}

/* right section: start page - fixed width and vertically centered */
.surah-page {
  width: 30px;
  text-align: right;
  margin-right: 10px;
  color: var(--muted-text-2);
  font-weight: 300;
  font-size: 14px;
}

.surah-item:hover {
  background-color: var(--border);
  outline: none;
}

/* ensure small screens are okay */
@media (max-width:420px) {
  #navPanel {
    width: calc(100% - 28px);
    left: 14px;
    right: 14px;
    top: 12px;
  }

  .surah-page {
    width: 44px;
    flex: 0 0 44px;
    font-size: 13px;
  }

  .nav-list {
    height: 320px;
  }
}
