/* ============================================
   Quran Player – Dark Theme
   ============================================ */

:root {
  --bg-primary: #323232;
  --bg-card: #2a2a2a;
  --bg-surface: #484848;
  --accent: #ff6348;
  --accent-glow: rgba(255, 99, 72, 0.25);
  --text-primary: #ececec;
  --text-secondary: #9e9ea3;
  --text-arabic: #f5deb3;
  --border: rgba(255, 255, 255, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 50%;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@font-face {
  font-family: "me_quran";
  font-weight: 500;
  src: url("/static/fonts/me_quran.ttf") format("opentype");
}

/* ---- Base ---- */
*, ::after, ::before { box-sizing: border-box; }
html { font-size: 18px; }
@media (max-width: 400px) { html { font-size: 16px; } }

body {
  font-family: 'Nunito', sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  margin: 0;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}
body::before {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 55%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 800px 250px at 50% 80%, rgba(255, 99, 72, 0.07) 0%, transparent 100%),
    radial-gradient(ellipse 500px 200px at 25% 85%, rgba(255, 99, 72, 0.05) 0%, transparent 100%),
    radial-gradient(ellipse 500px 200px at 75% 85%, rgba(255, 99, 72, 0.05) 0%, transparent 100%);
  animation: waveGlow 3s ease-in-out infinite alternate;
}
@keyframes waveGlow {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}
html, body { height: 100%; }
html.safari body {
  position: fixed;
  width: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-overflow-scrolling: touch;
}

button {
  padding: 0;
  border: none;
  outline: none;
  background: none;
  cursor: pointer;
  color: inherit;
}
html.safari input { border-radius: 0; }
input[type="email"], input[type="number"] { direction: ltr; }
::placeholder { color: #666; }

html.non-mobile ::-webkit-scrollbar { width: 3px; }
html.non-mobile ::-webkit-scrollbar-thumb { background-color: #555; }

main {
  margin: 0 auto;
  max-width: 500px;
  overflow-x: hidden;
  text-align: center;
  padding: 1rem 0.75rem 1px;
  position: relative;
  z-index: 1;
}

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  fill: currentColor;
  font-size: 24px;
  vertical-align: middle;
}

/* ---- Hidden selects (js.js reads these) ---- */
#qari-select, #surah-select {
  position: fixed;
  top: 1px;
  left: 0;
  display: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: none;
  border-radius: 0;
  outline: none;
  font-family: inherit;
  line-height: 1.1;
  color: var(--text-primary);
}

/* ---- Selector Pills ---- */
.selector-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1.2rem;
}
.selector-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  background: #3e3e3e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  font-size: 0.85rem;
  font-family: 'Nunito', sans-serif;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selector-pill:hover, .selector-pill:active {
  background: #474747;
  border-color: rgba(255, 99, 72, 0.25);
}
.selector-pill .pill-icon {
  width: 14px;
  height: 14px;
  fill: var(--accent);
  flex-shrink: 0;
}

/* ---- Ayah Text Card ---- */
#ayah-text-cont {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 45vh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 1.2rem;
  z-index: 1;
  font-size: 1.55rem;
  overflow-y: auto;
  padding-bottom: 0.5rem;
  color: var(--text-primary);
  word-wrap: break-word;
  line-height: 1.8;
  animation: cardFadeIn 0.35s ease;
}
#ayah-text-cont.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 100vh;
  width: 100%;
  max-width: 100%;
  border-radius: 0;
  background: var(--bg-primary);
  backdrop-filter: none;
  z-index: 100;
}

/* ---- Progress Bar ---- */
#ayah-progress {
  height: 3px;
  width: 0;
  max-width: 100% !important;
  margin-bottom: 5px;
  transition: width 400ms;
  background: linear-gradient(to right, var(--accent) 0%, #e67e22 100%);
  border-radius: 2px;
}

/* ---- Ayah Text ---- */
#ayah-text {
  font-family: Ayah;
  user-select: none;
  direction: rtl;
  text-align: justify;
  letter-spacing: -2.1px;
  font-size: 35px;
  color: var(--text-arabic);
  padding: 0 0.5rem;
}
#ayah-text-cont.fullscreen #ayah-text {
  letter-spacing: -2.2px;
  line-height: 1.85;
  font-size: 22.1px;
  text-align-last: justify;
  margin-top: 40px;
}
@media (max-width: 380px) {
  #ayah-text-cont.fullscreen { width: 100%; }
  #ayah-text-cont.fullscreen #ayah-text { font-size: 19.9px; }
}
#ayah-text.tajweed {
  font-family: Kitab;
  letter-spacing: 0;
  line-height: 1.6;
}
#ayah-text.tajweed i { font-style: normal; }

#ayah-commentary {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 5px;
  text-align: initial;
  line-height: 1.3;
  padding: 0 0.5rem;
}
#active-ayah { color: var(--accent); }
.basmalah {
  font: 20px Kitab;
  margin: 6px 20% 5px 0;
  line-height: 1.4;
  color: var(--text-arabic);
}

/* ---- Mushaf View Buttons ---- */
#mushaf-view-btns {
  position: absolute;
  top: 0;
  padding: 0 0.5rem;
  z-index: 101;
}
#mushaf-view-btns button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  background: var(--bg-card);
}
#mushaf-view-btns .icon {
  color: var(--text-secondary);
  font-size: 20px;
  vertical-align: bottom;
}
#play-small .icon { margin-left: 3px; }
#play-small .icon-pause { display: none; }
#play-small.playing .icon-play { display: none; }
#play-small.playing .icon-pause { display: inline-block; }
.icon-minimize { padding: 2px; }
#mushaf-view-info {
  font-size: 1rem;
  opacity: 0.6;
  vertical-align: middle;
  color: var(--text-secondary);
}

/* ---- Equalizer ---- */
#equalizer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 28px;
  margin-bottom: 12px;
}
.eq-bar {
  width: 4px;
  height: 6px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.35;
  transition: opacity 0.3s;
}
#equalizer.active .eq-bar {
  opacity: 1;
  animation: eqBar 0.8s ease-in-out infinite alternate;
}
#equalizer.active .eq-bar:nth-child(1) { animation-delay: 0s; }
#equalizer.active .eq-bar:nth-child(2) { animation-delay: 0.12s; }
#equalizer.active .eq-bar:nth-child(3) { animation-delay: 0.24s; }
#equalizer.active .eq-bar:nth-child(4) { animation-delay: 0.06s; }
#equalizer.active .eq-bar:nth-child(5) { animation-delay: 0.18s; }
#equalizer.active .eq-bar:nth-child(6) { animation-delay: 0.3s; }
#equalizer.active .eq-bar:nth-child(7) { animation-delay: 0.1s; }

@keyframes eqBar {
  0%   { height: 6px; }
  100% { height: 24px; }
}

/* ---- Play Button ---- */
#play {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  background: linear-gradient(145deg, #3a3a3a, #252525);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  transition: transform 0.15s ease, box-shadow 0.3s;
}
#play:hover {
  box-shadow: 0 4px 28px rgba(255, 99, 72, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
#play:active { transform: scale(0.94); }
#play[disabled] { opacity: 0.5; pointer-events: none; }

#play-icon {
  width: 36px;
  height: 36px;
  fill: var(--text-primary);
  margin-left: 4px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
#play.playing #play-icon { margin-left: 0; }

/* Progress Ring */
.progress-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 108px;
  height: 108px;
  transform: rotate(-90deg);
}
#progress-ring-circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 282.74;
  stroke-dashoffset: 282.74;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s;
}

/* ---- Action Buttons ---- */
#playing-btns {
  display: flex;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transition: visibility 0.3s, opacity 0.3s;
  margin-bottom: 1.2rem;
}
#playing-btns.active {
  opacity: 1;
  visibility: visible;
}
#playing-btns button {
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
#playing-btns button:active {
  background: var(--bg-surface);
}
#playing-btns button svg {
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
}
#copy-btn { transition: box-shadow 0.5s; }
#copy-btn.active { box-shadow: 0 0 8px var(--accent-glow); }
#tajweed-btn.active {
  box-shadow: 0 0 6px 1px var(--accent-glow);
  border-color: var(--accent);
}

/* ---- Settings Card ---- */
.settings-card {
  background: #3e3e3e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.settings-header:active { background: rgba(255, 255, 255, 0.04); }
.settings-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 99, 72, 0.12);
  border: 1px solid rgba(255, 99, 72, 0.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.summary-chip-neutral {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.settings-chevron {
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.settings-card.open .settings-chevron {
  transform: rotate(180deg);
}
.settings-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.settings-card.open .settings-body {
  max-height: 500px;
}
.settings-inner {
  padding: 4px 18px 20px;
}
.settings-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}
.settings-row:last-child {
  margin-bottom: 0;
}
.settings-field {
  flex: 1;
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 14px 10px 12px;
}
.settings-field label {
  display: block;
  font-size: 0.7rem;
  color: var(--accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

/* ---- Spinner Controls ---- */
.spinner-cont {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.spinner-cont button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.spinner-cont button:active {
  background: rgba(255, 99, 72, 0.15);
  border-color: rgba(255, 99, 72, 0.3);
}
.increase { color: var(--text-primary) !important; }
.decrease { color: var(--text-secondary) !important; }

.spinner {
  height: 34px;
  width: 42px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0;
  color: var(--text-primary);
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 8px;
}
.spinner::-webkit-inner-spin-button,
.spinner::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }
.invalid {
  box-shadow: #ff4444 0 0 3px 0;
  border-radius: 3px;
}

/* ---- Bottom Sheets ---- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.sheet-overlay.visible {
  display: block;
  opacity: 1;
}
.sheet-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 75vh;
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.sheet-overlay.visible .sheet-panel {
  transform: translateY(0);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.sheet-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
}
.sheet-close svg {
  width: 14px;
  height: 14px;
  fill: var(--text-secondary);
}
.sheet-search {
  margin: 0 16px 8px;
  flex-shrink: 0;
}
.sheet-search input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.sheet-search input:focus {
  border-color: rgba(255, 255, 255, 0.2);
}
.sheet-list {
  overflow-y: auto;
  padding: 0 8px 24px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.sheet-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-primary);
  font-size: 0.95rem;
}
.sheet-item:active, .sheet-item:hover {
  background: var(--bg-surface);
}
.sheet-item.selected {
  color: var(--accent);
}
.surah-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-primary);
  font-size: 0.95rem;
}
.surah-item:active, .surah-item:hover {
  background: var(--bg-surface);
}
.surah-item .surah-num {
  color: var(--text-secondary);
  font-size: 0.8rem;
  min-width: 28px;
  text-align: center;
}
.surah-item .surah-name { flex: 1; text-align: left; }
.surah-item .surah-arabic {
  font-family: 'me_quran', serif;
  font-size: 1.1rem;
  color: var(--text-arabic);
}

/* ---- Ayah Tip Toast ---- */
#ayah-tip {
  position: fixed;
  top: 210px;
  width: 100%;
  font-family: Kitab;
  text-align: center;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.3s, opacity 0.3s;
  z-index: 300;
}
#ayah-tip p {
  color: var(--text-arabic);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: inline-block;
  padding: 9px 14px 6px;
  direction: rtl;
}
#ayah-tip.active {
  visibility: visible;
  opacity: 0.95;
}

/* ---- Copy Text Container ---- */
#copy-text {
  position: absolute;
  left: -1000px;
  top: -1000px;
}

/* ---- Tajweed Colors ---- */
.madd-lazim  { color: #ff69b4; }
.madd-wajib  { color: #ff5252; }
.madd-aarid  { color: #ffab40; }
.ikhfaa      { color: #69f0ae; }
.idgham      { color: rgba(200, 200, 200, 0.55); }
.qalqalah    { color: #80d8ff; }

/* ---- Ambient Sound Waves (background decoration) ---- */
.ambient-waves {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,1) 60%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,1) 60%);
}
.ambient-waves svg {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100%;
}
.wave-path-1 {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0.45;
  animation: waveDrift1 4s ease-in-out infinite;
}
.wave-path-2 {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.3;
  animation: waveDrift2 5s ease-in-out infinite;
}
.wave-path-3 {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 0.8;
  opacity: 0.4;
  animation: waveDrift3 6s ease-in-out infinite;
}
.wave-path-4 {
  fill: none;
  stroke: var(--accent);
  stroke-width: 0.6;
  opacity: 0.2;
  animation: waveDrift4 3.5s ease-in-out infinite;
}
.wave-path-5 {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.5;
  opacity: 0.3;
  animation: waveDrift5 7s ease-in-out infinite;
}
@keyframes waveDrift1 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(-20px) translateY(-8px); }
}
@keyframes waveDrift2 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(25px) translateY(-12px); }
}
@keyframes waveDrift3 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(-15px) translateY(-6px); }
}
@keyframes waveDrift4 {
  0%, 100% { transform: translateX(0) translateY(0); }
  30% { transform: translateX(18px) translateY(-10px); }
  70% { transform: translateX(-12px) translateY(-5px); }
}
@keyframes waveDrift5 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(-22px) translateY(-4px); }
}

/* ---- Animations ---- */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes ringPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ---- Responsive ---- */
@media (max-width: 360px) {
  .spinner-cont button { width: 28px; height: 28px; }
  .selector-pill { padding: 8px 12px; font-size: 0.8rem; }
  #playing-btns { gap: 10px; }
}
