/* Base styles and CSS variables */
:root {
  --bg: #0b1020;
  --surface: #11162a;
  --text: #e6e6ea;
  --muted: #94a3b8;
  --brand: #0ea5e9;
  --brand-contrast: #081018;
  --border: #1f2937;
  --shadow: 0 10px 30px rgba(2,6,23,0.35);
   --footer-h: 78px;
}

html.no-footer { --footer-h: 0px; }

:root[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --brand: #0ea5e9;
  --brand-contrast: #edf2f7;
  --border: #e2e8f0;
  --shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0c0c0c;
  --surface: #21252b;
  --text: #e2e8f0;
  --muted: #a0aec0;
  --brand: #0ea5e9;
  --brand-contrast: #edf2f7;
  --border: #e2e8f0;
  --shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: light dark; }
body {
  margin: 0;
  min-height: 100vh;

  /* NEW: unified font stack */
  font-family:
    "Inter",
    "Noto Sans Arabic",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  /* Slightly nicer rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /*background: radial-gradient(circle at top, #0ea5e91a 0, #020617 50%);*/
  
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: 16px; 
  padding: 0.3rem;
  color: var(--text);
}
/* Make sure controls inherit the same font */
button,
input,
textarea,
select {
  font-family: inherit;
}

/* Font size scaling for the whole app */
body[data-font-size="small"] {
  font-size: 0.8rem;
}
body[data-font-size="medium"] {
  font-size: 1.1rem;
}
body[data-font-size="large"] {
  font-size: 1.4rem;
}
/* Ensure content and menu follow the base font size */
/* .view-content and .view-list inherit the font-size from the body, so no explicit rules are needed. */

/* Splash */
.splash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;              /* full viewport height */
  /* For phones with a notch / safe area */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);

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

  /* Full-screen background: pick gradient or an image */
  background:
    radial-gradient(circle at top, #0ea5e91a 0, #020617 60%);
  /* Or use an image:
     background: #020617 url("/images/splash-bg.jpg") center/cover no-repeat;
  */

  z-index: 9999;              /* above everything */
  /*smooth fade */
  opacity: 1;
  transition: opacity 300ms ease-out;
}
.splash.hidden {
  display: none;
  /*smooth fade */
  opacity: 0;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
  max-width: 90%;
}
.splash-title {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.8rem;
  color: white;
}

.splash-subtitle {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.8;
  color: white;
}
.splash .logo {
  width: 100%;
  height: 100%;
  max-width: 94vw;
  max-height: 68vw;
  border-radius: 15px;
}
@keyframes float { 0%,100% { transform: translateY(0);} 50%{ transform: translateY(-6px);} }


.fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: var(--surface);
  border-bottom: 2px solid rgba(198, 209, 230, 0.4);
  padding: 0.8em 0.2em;
  box-shadow: 0 4px 12px rgba(185, 106, 51, 0.08);
  z-index: 9999;
  display: flex;
  align-items: center;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
}

.app-header { top: 0; display: grid; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }

.app-footer { 
  bottom: 0; 
  padding: 0.2em 0.2em 0.2em 0.2em; 
  border-top: 2px solid var(--border);
  position: fixed; left: 0; right: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 999;
}

/* Language Button */
.language-btn {
  width: 44px;       /* Change size as needed */
  height: 40px;
 /* background-image: url('/icons/arabic_Eng_64x64.png');*/
  background-color: transparent; /* Ensures button background is transparent */
  background-size: cover;   /* Ensures the image covers the whole button */
  background-repeat: no-repeat;
  border: none;      /* No border for cleaner look */
  cursor: pointer;   /* Pointer on hover */
  margin-left: 0.5em;
  color: var(--text);
}

.icon-btn {
  background: transparent; 
  border: 1px solid var(--border); 
  color: var(--text);
  border-radius: 12px; 
  width: 40px; 
  height: 40px; 
  display: grid; 
  place-items: center; 
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn .tt { font-weight: 700; }

/* Title stays centered regardless of direction */
.title-wrap { text-align: center; }
.title-wrap h1 { 
  margin: 0; 
  font-size: 1.1rem;
  font-weight: 700; 
  letter-spacing: .3px; 
}
/* Keep the action buttons anchored at the far right */
.actions {
  display: flex;
  gap: .5rem;
  justify-self: end;    /* key line */
  /* Keep button order L→R even in RTL */
  direction: ltr;
}

.app-main {
  padding: calc(56px + env(safe-area-inset-top)) .05rem calc(var(--footer-h) + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* Views */
.view { max-width: 900px; margin: 23px auto; }
.view-list .menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.menu-card {
  background: linear-gradient(180deg, var(--surface), rgba(14, 165, 233, 0.03));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  display: flex;  
  gap: .65rem;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
  cursor: pointer;
  justify-content: space-between;
  align-items: center;
}
.menu-card:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); }
.menu-card .title {
  font-weight: 700; 
  font-size: 1.5em;
  color: var(--text);
}
.menu-card .meta { 
  color: var(--muted); 
  font-size: .85rem;
  display: flex; 
  gap: .5rem; 
  align-items: center; 
  color: var(--text);
}
.badge { font-size: .72rem; border: 1px dashed var(--border); padding: .1rem .45rem; border-radius: 999px; color: var(--muted); }
.lock { color: var(--brand); font-weight: 700; }


/* Keep the generic badge style for other uses, but make the lock badge icon-only */
.badge.lock {
  border: none;
  padding: 0;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.badge.lock svg {
  width: 16px;
  height: 16px;
  display: block;
}

.view-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem;
  box-shadow: var(--shadow);
/*  font-size: 1.25rem; */
}
.view-content h2 { margin-top: 0; }

/* Player */
.player {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    justify-content: center;
    justify-items: center;
    padding: 0em 0em 0em 0em;
    align-content: center;
    flex-wrap: nowrap;
}

.player-btn {
  background: var(--brand); 
  color: #fff; 
  border: none; 
  border-radius: 12px; 
  width: 45px; 
  height: 45px; 
  cursor: pointer; 
  font-size: 1.7rem; 
  font-weight: 700;
}
.player-btn:active { transform: scale(0.98); }
.player .track { display: grid; gap: 0rem; }
.now-playing { 
  display: flex; 
  justify-content: space-between; 
  align-items: baseline; 
  gap: .5rem; 
/*  font-size: 0.9em;*/
}
#seekBar { width: 100%; }

/* --------------- Audio list panel -----------*/
/* Player extra button: make it smaller to match */
  .player .player-btn + .player-btn {
    margin-left: .25rem;
  }

  /* Playlist panel */
  .panel .playlist { min-width: 320px; max-width: 480px; }
  .panel .playlist .row.header {
    display: flex; 
    justify-content: space-evenly;
    margin-bottom: 0.1rem;
    align-items: center;
  }
  .panel .playlist .list-wrap {
    max-height: 50vh; overflow: auto; border-top: 1px dashed var(--border);
    padding-top: .5rem;
  }
  .playlist-list {
    list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem;
  }
  .playlist-item {
    display: grid; gap: .15rem;
    padding: .5rem .6rem; border: 1px solid var(--border);
    border-radius: 10px; background: linear-gradient(180deg, var(--surface), rgba(14,165,233,.03));
    cursor: pointer;
  }
  .playlist-item:hover { border-color: var(--brand); }
  .playlist-item .title { font-weight: 600; }
  .playlist-item .meta  { 
  /*  font-size: .82rem;*/ 
    color: var(--muted); 
  }
  .playlist-item.active { 
    border: 4px solid var(--brand); 
    box-shadow: var(--shadow); 
  }
/* --------------- End Audio list panel -------*/
/* Settings panel */
.panel-inner.settings {
  min-width: 320px;
  max-width: 480px;
}

.settings-group {
  margin-top: 5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  width: 100%;
  flex-direction: column;
  direction: ltr;        /* force left-to-right flow */
  align-items: flex-start; /* left-align items */
  text-align: left;      /* align text to the left */
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}



/* Direction & responsiveness */
html[dir="rtl"] .title-wrap { text-align: center; } /* keep centered */
html[dir="rtl"] .menu-grid { direction: rtl; }
@media (min-width: 720px) {
  .app-main { padding-left: 1.5rem; padding-right: 1.5rem; }
}

/* Transitions */
.fade-enter { opacity: 0; transform: translateY(6px); }
.fade-enter-active { opacity: 1; transform: translateY(0); transition: all .28s ease; }
.fade-exit { opacity: 1; transform: translateY(0); }
.fade-exit-active { opacity: 0; transform: translateY(6px); transition: all .28s ease; }

/* Dialog (password prompt) */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.6); display: grid; place-items: center; z-index: 100;
}
.dialog {
  width: min(520px, 92vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1rem;
  box-shadow: var(--shadow);
}
.dialog h3 { margin: 0 0 .5rem 0; }
.dialog .row { display: flex; gap: .5rem; margin-top: .75rem; }
.dialog input {
  flex: 1; padding: .65rem .75rem; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--text);
}
.dialog button {
  padding: .65rem .9rem; 
  border-radius: 10px; 
  border: 1px solid var(--border); 
  background: var(--brand); 
  color: var(--brand-contrast); 
  cursor: pointer;
}
.dialog .hint { color: var(--muted); font-size: .85rem; }

.dialog .btn-primary {
  background: var(--brand);
  color: var(--brand-contrast); /* Updates text color to use theme variable! */
  border: 1px solid var(--brand);
}
.dialog .btn-secondary {
  background: var(--brand);
  color: var(--text);
  border: 1px solid var(--border);
}
.dialog .btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.btn_OK {
  display: flex;
  justify-content: center; /* center button horizontally */
  align-items: center;     /* center vertically if container has height */
  gap: 0.25rem;
  margin-top: 1rem;
}

.btn_OK button {
  padding: .65rem .9rem; 
  border-radius: 10px; 
  border: 1px solid var(--border); 
  background: var(--brand); 
  color: var(--brand-contrast); 
  cursor: pointer;
  display: inline-block;
  margin: 0; /* centered by parent */
}


/* Red for [ ... ] selections */
.letter-red {
  color: #ef4444;      /* red */
  font-weight: 600;
  display: inline;
  line-height: 1;
}

/* Green for ** ... ** selections */
.letter-green {
  color: #10b981;      /* green */
  font-weight: 700;
  display: inline;
  line-height: 1;
}

.inline-link {
  color: var(--brand);
  text-decoration: none;
}
.inline-link:hover {opacity: .85;}
.inline-link:visited { color: var(--brand);}


/* Poetry layout */
.poetry {
  margin: .75rem 0 1rem;
  line-height: 1.8;
/*  font-size: 1.02rem; */
}
.poetry .verse {
  display: block;
  padding: .2rem 0;
}
.poetry .hemistich {
  display: block;
  white-space: pre-wrap;  /* keep user spacing */
  word-break: break-word;
/*  font-size: 1.25rem; */
}

/* Align toward the caesura (center) by default */
.poetry .hemistich.a { text-align: start; }
.poetry .hemistich.b { text-align: end; }

/* A subtle divider you can style or hide as you like */
.poetry .caesura {
  display: none;
/*  flex: 0 0 auto;
  opacity: .45;
  font-weight: 600;
  user-select: none;
*/
}

.poetry .hemistich h2 { 
  margin:0 0 .25em; 
/*  font-size: 1.25rem; */ 
  line-height: 1.35; 
}

/* RTL: keep visual symmetry by reversing the row */
html[dir="rtl"] .poetry .verse { flex-direction: row-reverse; }
/* logical alignment still works: end/start already flip in RTL */

/* Optional: compact look on very narrow screens */
@media (max-width: 380px) {
  .poetry .verse { gap: .35rem; }
}