/* Visual language borrowed from Tashkeel Hero: pure black on white,
   2px black borders, square inputs, solid black primary buttons,
   grey for the current line, inverted (white on black) for the current item. */

:root {
  --bg: #fff;
  --fg: #000;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f3f4f6;
  --card: rgba(255, 255, 255, .92);
  --thumb: #888;
  --thumb-hover: #555;
  --track: #f1f1f1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000; --fg: #fff; --muted: #9ca3af; --line: #262626; --soft: #171717;
    --card: rgba(0, 0, 0, .92); --thumb: #555; --thumb-hover: #888; --track: #111;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000; --fg: #fff; --muted: #9ca3af; --line: #262626; --soft: #171717;
  --card: rgba(0, 0, 0, .92); --thumb: #555; --thumb-hover: #888; --track: #111;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 "IBM Plex Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* header · pages · sticky player, stacked */
  display: flex; flex-direction: column; height: 100dvh;
}

a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* Buttons — outlined secondary, solid black primary (Tashkeel style) */
.btn {
  font: inherit; font-size: 13px; color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--fg);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.btn:hover { background: var(--soft); }
.btn.on, .btn.primary { background: var(--fg); color: var(--bg); font-weight: 600; }
.btn.on:hover, .btn.primary:hover { opacity: .85; }
.btn:disabled { opacity: .3; cursor: default; }
.btn.square { width: 34px; padding: 6px 0; font-size: 16px; line-height: 1; }
.btn.big { font-size: 18px; font-weight: 700; padding: 14px 40px; border-radius: 0; }

/* Scrollbar */
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-track { background: var(--track); }
.scroll::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 3px; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--thumb-hover); }

/* Top bar */
.bar {
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.logo {
  width: 32px; height: 32px; border-radius: 4px;
  display: grid; place-items: center;
  background: var(--fg); color: var(--bg);
  font: 20px/1 "Amiri Quran", serif; padding-bottom: 4px;
}
.source { margin-inline: auto 8px; color: var(--muted); font-size: 12px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1; min-height: 0;
  transition: grid-template-columns .3s;
}

/* Collapsed surah list */
body.index-collapsed .layout { grid-template-columns: 0 1fr; }
body.index-collapsed .index { visibility: hidden; border: 0; }
.index { overflow: hidden; }
#toggle-index[aria-expanded="false"] { background: var(--fg); color: var(--bg); }

/* Surah index */
.index { display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--line); }
#search {
  margin: 16px; padding: 10px 12px;
  font: inherit; color: inherit; background: var(--soft);
  border: 2px solid var(--fg); border-radius: 0;
  outline: none;
}
#search::placeholder { color: var(--muted); }

.chapters { list-style: none; overflow-y: auto; padding-bottom: 24px; }
.chapters a {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px;
  padding: 10px 16px;
  transition: background-color .2s;
}
.chapters a:hover { background: var(--soft); }
.chapters a[aria-current] { background: var(--fg); color: var(--bg); }
.chapters a[aria-current] .num, .chapters a[aria-current] .meta { color: inherit; opacity: .7; }
.num { font: 12px ui-monospace, monospace; color: var(--muted); }
.meta { display: block; font-size: 12px; color: var(--muted); }
.ar-name { font: 18px "Amiri Quran", serif; }

/* Reader pane */
.pane { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.reader { flex: 1; overflow-y: auto; padding: 48px 24px 96px; transition: opacity .3s; }
.reader > * { max-width: 760px; margin-inline: auto; }
.reader.dim { opacity: .5; }

.empty { text-align: center; margin-top: 18vh; }
.empty .ar-title { font: 56px/1.6 "Amiri Quran", serif; }
.empty p { color: var(--muted); margin: 8px 0 32px; }
.status { color: var(--muted); text-align: center; margin-top: 20vh; }

.head { text-align: center; margin-bottom: 40px; }
.head .ar-title { font: 44px/1.8 "Amiri Quran", serif; }
.head h1 { font-size: 20px; font-weight: 700; }
.head p { color: var(--muted); font-size: 13px; }
.back { display: none; color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.verse { padding: 24px 16px; border-top: 1px solid var(--line); border-radius: 4px; transition: background-color .2s; }
.verse.current { background: var(--soft); }
.verse .n { font: 12px ui-monospace, monospace; color: var(--muted); }
.verse .ar {
  font: 30px/2.5 "Amiri Quran", serif; /* generous line height for tashkeel */
  text-align: start; /* dir="rtl" is set in the markup */
}
/* Readable transliteration line: between the Arabic and the translation */
.verse .rd { margin-top: 4px; font-size: 16px; font-weight: 600; letter-spacing: .01em; }
.verse .tr { margin-top: 8px; color: var(--muted); }

.w { padding: 0 2px; border-radius: 4px; cursor: pointer; transition: background-color .2s, color .2s; }
.w:hover { background: var(--line); }
.w.active { background: var(--fg); color: var(--bg); }
.end { color: var(--muted); font-size: .8em; }

.pager { display: flex; justify-content: space-between; gap: 8px; padding-top: 32px; border-top: 1px solid var(--line); }

/* Progress (Tashkeel style: thin black bar + mono counter) */
.progress { flex: none; border-top: 1px solid var(--line); }
.track { height: 4px; background: var(--soft); }
/* Transform + a fixed-size counter: updating them never re-lays out the (long) page. */
.fill { height: 100%; background: var(--fg); transform: scaleX(0); transform-origin: right; transition: transform .3s; }
:root[dir="ltr"] .fill { transform-origin: left; }
.count { font: 12px/24px ui-monospace, monospace; height: 24px; width: 100%; contain: strict; color: var(--muted); text-align: center; }

/* Sticky player at the bottom of every page */
.player { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.now { margin-inline-start: auto; font-size: 12px; color: var(--muted); height: 24px; line-height: 24px; width: 200px; contain: strict; text-align: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.now:hover { color: var(--fg); text-decoration: underline; }
.time { font: 12px/24px ui-monospace, monospace; height: 24px; width: 96px; contain: strict; color: var(--muted); text-align: end; }
.select {
  font: inherit; font-size: 13px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--fg); border-radius: 4px;
  padding: 5px 8px; max-width: 240px; cursor: pointer;
}
#recite { min-width: 92px; }

/* Search page */
.search-form { display: flex; gap: 8px; margin-bottom: 8px; }
.search-big {
  flex: 1; min-width: 0;
  font: inherit; font-size: 18px; color: inherit; background: var(--soft);
  border: 2px solid var(--fg); border-radius: 0;
  padding: 12px 14px; outline: none;
}
.search-big::placeholder { color: var(--muted); }
.search-form .btn.big { padding: 12px 28px; }
.meta-line { color: var(--muted); font-size: 13px; margin: 16px 0; }
.btn.go { display: inline-block; margin-bottom: 16px; }
.result { display: block; padding: 20px 16px; border-top: 1px solid var(--line); border-radius: 4px; transition: background-color .2s; }
.result:hover { background: var(--soft); }
.result .n { font: 12px ui-monospace, monospace; color: var(--muted); }
.result .ar { font: 24px/2.2 "Amiri Quran", serif; text-align: start; }
.result .tr { margin-top: 4px; color: var(--muted); }
.result mark { background: var(--fg); color: var(--bg); padding: 0 2px; border-radius: 2px; }
.result .by { font-size: 12px; }
.page-no { font: 12px ui-monospace, monospace; color: var(--muted); align-self: center; }

/* Magnify overlay (Tashkeel big-word mode) */
.overlay {
  position: absolute; inset: 0 0 32px; /* stay above the progress bar */
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  pointer-events: none; /* text behind stays clickable */
}
.card {
  pointer-events: auto;
  width: min(100%, 560px);
  padding: 24px 24px 16px;
  text-align: center;
  background: var(--card);
  backdrop-filter: blur(4px);
  border: 2px solid var(--fg);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .2);
}
.mag-ar { font: clamp(64px, 14vw, 120px)/1.7 "Amiri Quran", serif; padding-bottom: .3em; }
.mag-tr { font-size: 24px; font-weight: 600; letter-spacing: .02em; }
.mag-ac { font-size: 13px; color: var(--muted); font-style: italic; min-height: 1.4em; }
.mag-en { color: var(--muted); font-size: 16px; min-height: 1.6em; }
.mag-nav { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.mag-ref { margin-top: 12px; font: 12px ui-monospace, monospace; color: var(--muted); }

/* Collapsed card: a compact bar at the bottom, text behind it stays readable */
.card { position: relative; }
.mag-min { position: absolute; top: 8px; inset-inline-end: 8px; border-color: var(--line); }
.overlay.mini { align-items: flex-end; }
.overlay.mini .card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 16px; padding-block: 8px; padding-inline: 16px 56px; text-align: start; }
.overlay.mini .mag-ar { font-size: 40px; line-height: 1.6; padding: 0; grid-row: span 2; }
.overlay.mini .mag-tr { font-size: 16px; }
.overlay.mini .mag-en { font-size: 13px; grid-column: 2; }
.overlay.mini .mag-nav { margin: 0; grid-column: 3; grid-row: 1 / span 2; }
.overlay.mini .mag-ref, .overlay.mini .mag-ac { display: none; }

/* Phone: one pane at a time */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .index { border-inline-end: 0; }
  #toggle-index { display: none; } /* phones already show one pane at a time */
  body.index-collapsed .layout { grid-template-columns: 1fr; }
  body.index-collapsed .index { visibility: visible; }
  .overlay.mini .card { grid-template-columns: auto 1fr; padding-inline-end: 48px; }
  .overlay.mini .mag-nav { grid-column: 1 / -1; grid-row: auto; justify-content: center; }
  body.reading .index { display: none; }
  body:not(.reading) .pane { display: none; }
  .reader { padding: 24px 16px 64px; }
  .back { display: inline-block; }
  .source { display: none; }
  .brand { margin-inline-end: auto; }
  .head .ar-title { font-size: 34px; }
  .verse { padding: 20px 8px; }
  .verse .ar { font-size: 25px; }
  .mag-tr { font-size: 20px; }
  .player { padding: 6px 8px; gap: 6px; }
  .now { width: auto; flex: 1; min-width: 0; }
  .select { max-width: 130px; }
  .time { display: none; }
  .bar .btn:not(.square) { padding: 6px 8px; }
  .search-form .btn.big { padding: 12px 16px; }

  /* Type scale matched to the Facebook app: 15px body, 13px secondary, 17px titles.
     Inputs are 16px so iOS doesn't zoom the page when they get focus. */
  .btn, .select { font-size: 15px; }
  .btn.square { font-size: 16px; }
  .head h1, .mag-tr { font-size: 17px; }
  .verse .rd { font-size: 15px; }
  .mag-en { font-size: 15px; }
  .meta, .num, .verse .n, .count, .now, .mag-ref,
  .result .n, .result .by, .page-no, .time { font-size: 13px; }
  #search, .search-big { font-size: 16px; }
  .search-form .btn.big { font-size: 15px; font-weight: 600; }
}
