/* ================================================================
   SAKINAH — Azkar page
   Library of occasions + focused, trackable reader
   ================================================================ */
:root {
  --font-arabic: 'Amiri', 'Scheherazade New', 'Geeza Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

/* ---------------- Intro ---------------- */
.azkar-intro {
  padding: calc(68px + var(--sp-12)) 0 var(--sp-6);
  background: linear-gradient(180deg, var(--bg-warm), var(--bg));
}
.azkar-intro .section-header { margin-bottom: 0; }
.azkar-stats { font-size: var(--t-sm); letter-spacing: 0.04em; font-weight: 500; color: var(--sand-deep); }

/* ---------------- Resume card ---------------- */
.resume-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  max-width: 580px;
  margin: var(--sp-8) auto 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.resume-card[hidden] { display: none; }
.resume-ring { flex-shrink: 0; width: 48px; height: 48px; position: relative; }
.resume-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.resume-ring .bg { fill: none; stroke: var(--line); stroke-width: 7; }
.resume-ring .fg { fill: none; stroke: var(--sand-deep); stroke-width: 7; stroke-linecap: round; }
.resume-text { flex: 1; min-width: 0; }
.resume-label { font-size: var(--t-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.resume-name { font-weight: 600; color: var(--ink); }
.resume-name span { color: var(--ink-3); font-weight: 400; }
.resume-btn {
  flex-shrink: 0;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--surface);
  background: var(--ink);
  border: none;
  border-radius: var(--r-full);
  padding: 0.55rem 1.1rem;
  transition: background var(--dur-fast) var(--ease);
}
.resume-btn:hover { background: var(--sand-deep); }

/* ---------------- Controls ---------------- */
.azkar-controls {
  position: sticky;
  top: 68px;
  z-index: 50;
  background: rgba(247, 244, 237, 0.93);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-5) 0 var(--sp-4);
}
.azkar-search-wrap { position: relative; max-width: 560px; margin: 0 auto; }
.azkar-search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.azkar-search {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 0.75rem 1.1rem 0.75rem 2.85rem;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.azkar-search::placeholder { color: var(--ink-4); }
.azkar-search:focus { outline: none; border-color: var(--sand); box-shadow: 0 0 0 4px var(--sand-soft); }
.filter-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-4); }
.filter-chip {
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 0.4rem 0.9rem;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.filter-chip:hover { border-color: var(--sand); color: var(--ink); }
.filter-chip.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.azkar-result-count { text-align: center; margin-top: var(--sp-3); font-size: var(--t-sm); color: var(--ink-3); min-height: 1.2em; }

/* ---------------- Library ---------------- */
.azkar-library-section { padding-top: var(--sp-12); }
.lib-group { margin-bottom: var(--sp-12); }
.lib-group[hidden] { display: none; }
.lib-group-head { display: flex; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.lib-group-en { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.4rem, 2.6vw, 1.9rem); color: var(--ink); }
.lib-group-ar { font-family: var(--font-arabic); font-size: var(--t-lg); color: var(--sand-deep); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.cat-tile {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.cat-tile[hidden] { display: none; }
.cat-tile:hover { transform: translateY(-2px); border-color: var(--sand); box-shadow: var(--shadow); }
.cat-tile.is-done { border-color: var(--sage-soft); }

.tile-ring { position: relative; flex-shrink: 0; width: 46px; height: 46px; display: grid; place-items: center; }
.tile-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.tile-ring .bg { fill: none; stroke: var(--line); stroke-width: 6; }
.tile-ring .fg { fill: none; stroke: var(--sand-deep); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset var(--dur) var(--ease); }
.cat-tile.is-done .tile-ring .fg { stroke: var(--sage); }
.tile-ring-icon { color: var(--sand-deep); display: grid; place-items: center; }
.tile-ring-icon svg { position: static; width: 16px; height: 16px; transform: none; }
.cat-tile.is-done .tile-ring-icon { color: var(--sage); }

.tile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tile-en { font-weight: 600; color: var(--ink); }
.tile-ar { font-family: var(--font-arabic); font-size: var(--t-sm); color: var(--ink-3); }
.tile-status { font-size: var(--t-xs); color: var(--ink-4); margin-top: 2px; }
.cat-tile.is-done .tile-status { color: var(--sage); }
.tile-chevron { flex-shrink: 0; color: var(--ink-4); }
.cat-tile:hover .tile-chevron { color: var(--sand-deep); }

/* ---------------- Search results ---------------- */
.search-results { max-width: 760px; margin: 0 auto; }
.search-results[hidden] { display: none; }
.result-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.result-row:hover { border-color: var(--sand); }
.result-cat { flex-shrink: 0; width: 130px; font-size: var(--t-sm); font-weight: 600; color: var(--sand-deep); }
.result-snippet { flex: 1; min-width: 0; font-family: var(--font-arabic); font-size: var(--t-md); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Empty ---------------- */
.azkar-empty { text-align: center; padding: var(--sp-16) 0; font-size: var(--t-md); color: var(--ink-3); }
.azkar-empty[hidden] { display: none; }

/* ================================================================
   Reader (focused, trackable)
   ================================================================ */
body.reader-open { overflow: hidden; }
.reader { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: var(--bg); --reader-scale: 1; }
.reader[hidden] { display: none; }

.reader-topbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--pad); border-bottom: 1px solid var(--line); }
.reader-icon-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--ink-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.reader-icon-btn:hover { background: var(--ink); color: var(--surface); }
.reader-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.reader-title-en { font-family: var(--font-display); font-size: var(--t-lg); line-height: 1.1; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title-ar { font-family: var(--font-arabic); font-size: var(--t-sm); color: var(--sand-deep); }
.reader-list-toggle { display: none; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-full); padding: 0.4rem 0.8rem; }
.reader-list-toggle:hover { border-color: var(--sand); }

.reader-fontsize { flex-shrink: 0; display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-full); overflow: hidden; }
.font-btn { width: 38px; height: 38px; display: grid; place-items: center; background: none; border: none; color: var(--ink-2); line-height: 1; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.font-btn:hover:not(:disabled) { background: var(--sand-faint); color: var(--ink); }
.font-btn:disabled { opacity: 0.3; cursor: default; }
.font-btn + .font-btn { border-left: 1px solid var(--line); }
.font-btn.small { font-size: 0.8rem; }
.font-btn.large { font-size: 1.2rem; }

.reader-progress { height: 4px; background: var(--line-soft); flex-shrink: 0; }
.reader-progress-fill { height: 100%; width: 0; background: var(--sand-deep); transition: width var(--dur) var(--ease); }

.reader-main { position: relative; display: flex; flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* Tracker */
.reader-track { width: 300px; flex-shrink: 0; overflow-y: auto; padding: var(--sp-4); background: var(--surface-2); border-right: 1px solid var(--line); }
.reader-track ol { display: flex; flex-direction: column; gap: 4px; }
.track-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0.5rem 0.7rem;
  color: var(--ink-2);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.track-row:hover { background: var(--sand-faint); }
.track-row.is-current { background: var(--surface); border-color: var(--sand); }
.track-num { flex-shrink: 0; width: 22px; height: 22px; display: grid; place-items: center; font-family: var(--font-mono); font-size: var(--t-xs); color: var(--ink-3); border: 1px solid var(--line); border-radius: var(--r-full); }
.track-row.is-current .track-num { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.track-row.is-done .track-num { background: var(--sage); color: var(--surface); border-color: var(--sage); }
.track-label { flex: 1; min-width: 0; font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-rep { flex-shrink: 0; font-size: var(--t-xs); font-weight: 600; color: var(--amber); }
.track-row.is-done .track-rep { color: var(--sage); }

/* Stage */
.reader-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
/* justify-content:center clips overflowing content in flex scroll containers;
   auto margins center when short but stay fully scrollable when tall. */
.reader-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-5); padding: var(--sp-8) var(--pad); }
.reader-body { display: flex; flex-direction: column; align-items: center; gap: var(--sp-5); width: 100%; max-width: 700px; margin: auto 0; }
.reader-body[hidden] { display: none; }
.reader-position { font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); }
.reader-rep-note { font-size: var(--t-sm); font-weight: 600; color: var(--amber); }
.reader-rep-note[hidden] { display: none; }
.reader-arabic { font-family: var(--font-arabic); font-size: calc(clamp(1.45rem, 2.8vw, 2rem) * var(--reader-scale)); line-height: 2.05; color: var(--ink); white-space: pre-line; }
.reader-translit { font-style: italic; font-size: calc(0.95rem * var(--reader-scale)); line-height: 1.7; color: var(--ink-3); white-space: pre-line; max-width: 640px; }
.reader-translation { font-size: calc(1.0625rem * var(--reader-scale)); line-height: 1.7; color: var(--ink-2); white-space: pre-line; max-width: 640px; }
.reader-source { font-size: var(--t-xs); line-height: 1.5; color: var(--ink-4); white-space: pre-line; max-width: 560px; }
.reader-translit[hidden], .reader-translation[hidden], .reader-source[hidden] { display: none; }

.reader-complete { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--sp-5); padding: var(--sp-10) var(--pad); }
.reader-complete[hidden] { display: none; }
.reader-complete-ar { font-family: var(--font-arabic); font-size: clamp(2.4rem, 7vw, 3.4rem); color: var(--sand-deep); }
.reader-complete-en { font-size: var(--t-md); color: var(--ink-2); }
.reader-complete-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; justify-content: center; }
.reader-btn { font-size: var(--t-sm); font-weight: 500; border-radius: var(--r-full); padding: 0.65rem 1.4rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.reader-btn:hover { border-color: var(--sand); }
.reader-btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.reader-btn.primary:hover { background: var(--sand-deep); border-color: var(--sand-deep); }

/* Foot / counter */
.reader-foot { flex-shrink: 0; border-top: 1px solid var(--line); padding: var(--sp-4) var(--pad) var(--sp-3); background: var(--surface-2); }
.reader-foot[hidden] { display: none; }
.reader-dock { display: flex; align-items: center; justify-content: center; gap: var(--sp-6); }
.reader-nav { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-full); background: var(--surface); color: var(--ink-2); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease); }
.reader-nav:hover:not(:disabled) { background: var(--ink); color: var(--surface); }
.reader-nav:disabled { opacity: 0.3; cursor: default; }

.reader-counter { position: relative; width: 124px; height: 124px; display: grid; place-items: center; border: none; background: none; -webkit-tap-highlight-color: transparent; transition: transform var(--dur-fast) var(--ease); }
.reader-counter:active { transform: scale(0.96); }
.reader-counter:disabled { cursor: default; }
.reader-counter:focus-visible { outline: 2px solid var(--sand-deep); outline-offset: 6px; border-radius: var(--r-full); }
.reader-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.reader-ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.reader-ring-fg { fill: none; stroke: var(--sand-deep); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset var(--dur) var(--ease), stroke var(--dur-fast) var(--ease); }
.reader-counter.done .reader-ring-fg { stroke: var(--sage); }
.reader-count { font-family: var(--font-display); font-size: 2.6rem; line-height: 1; color: var(--ink); }
.reader-count-label { position: absolute; bottom: 26px; font-size: var(--t-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.reader-hint { text-align: center; font-size: var(--t-xs); color: var(--ink-4); margin-top: var(--sp-3); }
.reader-hint[hidden] { display: none; }

/* ---------------- Names overlay (reference) ---------------- */
.names-view { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: var(--bg); }
.names-view[hidden] { display: none; }
.names-scroll { flex: 1; overflow-y: auto; padding: var(--sp-8) var(--pad) var(--sp-16); }
.asma-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-4); max-width: var(--container); margin: 0 auto; }
.asma-card { position: relative; display: flex; flex-direction: column; gap: var(--sp-2); text-align: center; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--sp-6) var(--sp-4) var(--sp-4); box-shadow: var(--shadow-sm); }
.asma-num { position: absolute; top: 10px; left: 12px; font-family: var(--font-mono); font-size: var(--t-xs); color: var(--ink-4); }
.asma-arabic { font-family: var(--font-arabic); font-size: 1.9rem; line-height: 1.4; color: var(--sand-deep); }
.asma-translit { font-weight: 600; font-size: var(--t-sm); color: var(--ink); }
.asma-meaning { font-size: var(--t-xs); line-height: 1.5; color: var(--ink-3); }

/* ---------------- Responsive ---------------- */
@media (min-width: 900px) {
  .reader-list-toggle { display: none !important; }
}
@media (max-width: 899px) {
  .reader-list-toggle { display: inline-flex; }
  .reader-track {
    position: absolute;
    top: 0; left: 0; right: 0;
    width: auto;
    max-height: 70%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateY(-101%);
    transition: transform var(--dur) var(--ease);
    z-index: 5;
  }
  .reader-track.is-open { transform: translateY(0); }
}
@media (max-width: 720px) {
  .azkar-intro { padding-top: calc(68px + var(--sp-8)); }
  .result-cat { width: 96px; }
  .reader-counter { width: 116px; height: 116px; }
  .reader-count { font-size: 2.3rem; }
  .reader-dock { gap: var(--sp-4); }
  .asma-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  /* Tighten the reader topbar so short titles aren't clipped */
  .reader-topbar { gap: var(--sp-2); padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .reader-icon-btn { width: 38px; height: 38px; }
  .font-btn { width: 32px; height: 34px; }
  .reader-list-toggle { padding: 0.35rem 0.6rem; gap: 4px; }
  .reader-title-en { font-size: var(--t-md); }
}
