/* Noor web theme v1 · theme.css
 * Components for home, reader, player, search, library, about and privacy.
 * Requires tokens.css first. All classes use the n- prefix so they can live beside the old
 * site.css and reader.css during migration. Logical properties keep RTL and LTR identical.
 */

/* Base styles remain in the existing page styles during migration. */
.n-container { width: min(100% - 2 * var(--s-4), var(--page-max)); margin-inline: auto; }
.n-measure { max-width: var(--measure); margin-inline: auto; }
.n-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.n-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }

.n-kicker { font: 600 var(--fs-small)/1.4 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-ink); }
:lang(ar) .n-kicker { text-transform: none; letter-spacing: 0; font-family: var(--font-ar-small); }
.n-meta { font-size: var(--fs-small); color: var(--ink-soft); }
.n-sample { font: 600 var(--fs-tiny)/1 var(--font-ui); color: var(--gold-ink); border: 1px solid var(--border-strong); border-radius: var(--r-pill); padding: 3px 8px; }

/* Ornament: a gold rule with a center diamond */
.n-ornament { display: flex; align-items: center; gap: var(--s-3); color: var(--gold); }
.n-ornament::before, .n-ornament::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: 0.6; }
.n-ornament > span { width: 8px; height: 8px; background: currentColor; transform: rotate(45deg); }

/* ── Buttons, chips, inputs ───────────────────────────────────────────── */
.n-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5); border-radius: var(--r-pill);
  border: 1px solid transparent; background: var(--accent); color: var(--on-accent);
  font: 600 var(--fs-body)/1 var(--font-ui); text-decoration: none; cursor: pointer;
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
:lang(ar) .n-btn { font-family: var(--font-ar); font-weight: 700; }
.n-btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.n-btn:active { transform: scale(0.98); }
.n-btn--quiet { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.n-btn--quiet:hover { background: var(--surface-alt); color: var(--ink); }
.n-btn--gold { background: var(--gold-light); color: #14100A; }
.n-btn--gold:hover { background: #EBDCAE; color: #14100A; }
.n-btn--sm { min-height: var(--tap); padding: 0 var(--s-4); font-size: var(--fs-small); }
.n-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.n-icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border-radius: 50%; border: 0; background: transparent; color: var(--ink); cursor: pointer;
}
.n-icon-btn:hover { background: var(--surface-alt); }
.n-icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.n-chip {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0 var(--s-4);
  border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: transparent;
  color: var(--ink); font: 500 var(--fs-small)/1 var(--font-ui); cursor: pointer;
}
:lang(ar) .n-chip { font-family: var(--font-ar-small); }
.n-chip[aria-pressed="true"], .n-chip[aria-selected="true"] { background: var(--emerald); border-color: var(--emerald); color: var(--on-emerald); }
[data-theme="night"] .n-chip[aria-pressed="true"], [data-theme="emerald"] .n-chip[aria-pressed="true"],
[data-theme="night"] .n-chip[aria-selected="true"], [data-theme="emerald"] .n-chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.n-input {
  width: 100%; min-height: 48px; padding: 0 var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font: 400 var(--fs-body)/1.4 var(--font-ui);
}
.n-input::placeholder { color: var(--ink-soft); }
.n-input:focus { outline: 3px solid var(--focus); outline-offset: 1px; }

.n-tabs { display: flex; gap: var(--s-1); padding: var(--s-1); border-radius: var(--r-pill); background: var(--surface-alt); width: fit-content; max-width: 100%; flex-wrap: wrap; }
.n-tab { min-height: var(--tap); padding: 0 var(--s-4); border-radius: var(--r-pill); border: 0; background: transparent; color: var(--ink-soft); font: 600 var(--fs-small)/1 var(--font-ui); cursor: pointer; }
.n-tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ── Header and footer ────────────────────────────────────────────────── */
.n-header {
  position: sticky; inset-block-start: 0; z-index: 20; height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-block-end: 1px solid var(--border);
}
.n-header__inner { height: 100%; display: flex; align-items: center; gap: var(--s-4); }
.n-brand { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; color: var(--ink); }
.n-brand__mark { font: 700 1.75rem/1 var(--font-ar); color: var(--emerald); }
[data-theme="night"] .n-brand__mark, [data-theme="emerald"] .n-brand__mark { color: var(--gold-light); }
.n-brand__word { font: 600 1.25rem/1 var(--font-display); }
.n-nav { display: flex; gap: var(--s-1); margin-inline-start: auto; }
.n-nav a { padding: 10px 14px; border-radius: var(--r-pill); color: var(--ink-soft); text-decoration: none; font-weight: 500; }
.n-nav a:hover { color: var(--ink); background: var(--surface-alt); }
.n-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-alt); }
@media (max-width: 720px) { .n-nav { flex-wrap: wrap; gap: var(--s-1); } }

.n-footer { margin-block-start: var(--s-9); padding-block: var(--s-7); border-block-start: 1px solid var(--border); color: var(--ink-soft); font-size: var(--fs-small); }
.n-footer a { color: var(--ink-soft); }
.n-footer a:hover { color: var(--ink); }

/* ── Cards, hero, Moments, store badges ───────────────────────────────── */
.n-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-1); }
.n-card--link { display: block; text-decoration: none; color: inherit; transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
.n-card--link:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); color: inherit; }
.n-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }

.n-hero { position: relative; overflow: hidden; border-radius: var(--r-xl); background: var(--hero-bg); color: var(--hero-ink); isolation: isolate; }
.n-hero__art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 80% 50%; z-index: -2; }
.n-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, var(--hero-bg) 0%, color-mix(in srgb, var(--hero-bg) 88%, transparent) 50%, transparent 100%); }
[dir="rtl"] .n-hero::after { background: linear-gradient(270deg, var(--hero-bg) 0%, color-mix(in srgb, var(--hero-bg) 88%, transparent) 50%, transparent 100%); }
[dir="rtl"] .n-hero__art[data-mirror-safe="true"] { transform: scaleX(-1); } /* only for art flagged mirror-safe */
.n-hero__body { padding: var(--s-8) var(--s-6); max-width: 34rem; display: flex; flex-direction: column; gap: var(--s-4); }
.n-hero h1 { color: var(--hero-ink); }
.n-hero p { color: var(--hero-soft); font-size: 1.125rem; }
.n-hero .n-kicker { color: var(--hero-accent); }

.n-moment { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-5); border-radius: var(--r-lg); background: var(--surface-alt); border: 1px solid var(--border-strong); }
.n-moment__glyph { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--emerald); color: var(--gold-light); font: 700 1.1rem/1 var(--font-ar); }
.n-moment__title { font-weight: 600; }

.n-store { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: 0 var(--s-5); border-radius: var(--r-md); background: var(--ink); color: var(--paper); text-decoration: none; }
.n-store small { display: block; font-size: var(--fs-tiny); opacity: 0.85; }
.n-store strong { display: block; font-size: 1.05rem; }

/* ── Reader ───────────────────────────────────────────────────────────── */
.n-appbar { position: sticky; inset-block-start: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-2); height: 56px; padding-inline: var(--s-2); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-block-end: 1px solid var(--border); }
.n-appbar__title { flex: 1; text-align: center; font: 700 1.15rem/1.3 var(--font-ar); }
.n-appbar__title small { display: block; font: 500 var(--fs-tiny)/1.3 var(--font-ui); color: var(--ink-soft); }

.n-surah-head { text-align: center; padding-block: var(--s-6) var(--s-4); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.n-surah-head__name { font: 700 2.25rem/1.4 var(--font-ar); color: var(--emerald); }
[data-theme="night"] .n-surah-head__name, [data-theme="emerald"] .n-surah-head__name { color: var(--gold-light); }
.n-surah-head__band { width: min(100%, 26rem); padding: var(--s-2) var(--s-4); border: 1px solid var(--gold); border-radius: var(--r-sm); outline: 1px solid var(--gold); outline-offset: 3px; }

/* Quran text: Amiri Quran only. Text is inserted from the canonical data, never typed. */
.n-quran { font-family: var(--font-quran); font-size: calc(var(--fs-quran) * var(--quran-scale)); line-height: 2.2; color: var(--ink); direction: rtl; text-align: right; word-spacing: 0.05em; }
.n-quran--center { text-align: center; }
.n-ayah-num { all: unset; cursor: pointer; color: var(--gold-ink); border-radius: 50%; padding-inline: 2px; }
.n-ayah-num:focus-visible { outline: 2px solid var(--focus); }

.n-ayah { padding: var(--s-5) var(--s-4); border-block-end: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s-3); transition: background var(--dur-2) var(--ease); }
.n-ayah.is-playing { background: var(--highlight); }
.n-ayah__head { display: flex; justify-content: space-between; align-items: center; }
.n-ayah__ref { font: 600 var(--fs-small)/1 var(--font-ui); color: var(--gold-ink); border: 1px solid var(--border-strong); border-radius: var(--r-pill); padding: 6px 10px; }
.n-ayah__trans { font-size: 1.0625rem; line-height: 1.7; color: var(--ink-soft); direction: ltr; text-align: left; }
.n-ayah__trans:lang(ur) { direction: rtl; text-align: right; font-family: "Noto Nastaliq Urdu", var(--font-ar); line-height: 2.2; }
.n-ayah__tools { display: flex; gap: var(--s-1); }

.n-page { position: relative; background: var(--surface); border-radius: var(--r-md); padding: var(--s-6) var(--s-5) var(--s-5); box-shadow: var(--shadow-1); }
.n-page::before { content: ""; position: absolute; inset: 10px; border: 1px solid var(--gold); border-radius: 6px; outline: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); outline-offset: 3px; pointer-events: none; }
.n-page__top, .n-page__foot { display: flex; justify-content: space-between; font: 500 var(--fs-small)/1 var(--font-ar-small); color: var(--ink-soft); }
.n-page__foot { justify-content: center; font-family: var(--font-ar); color: var(--gold-ink); }
.n-page .n-quran { font-size: calc(var(--fs-quran-page) * var(--quran-scale)); text-align: justify; text-align-last: center; }

/* Sheets: bottom sheet on phones, side panel on desktop */
.n-sheet { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 40; max-height: 86vh; overflow: auto; background: var(--surface); color: var(--ink); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-2); padding: var(--s-3) var(--s-5) var(--s-6); animation: n-sheet-up var(--dur-3) var(--ease); }
.n-sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto var(--s-4); }
@media (min-width: 900px) {
  .n-sheet { inset-block: 0; inset-inline-start: auto; inset-inline-end: 0; width: 420px; max-height: none; border-radius: 0; border-inline-start: 1px solid var(--border); animation-name: n-panel-in; }
  [dir="rtl"] .n-sheet { inset-inline-end: auto; inset-inline-start: 0; }
  .n-sheet__handle { display: none; }
}
dialog.n-sheet::backdrop, .n-backdrop { background: var(--scrim); }
@keyframes n-sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes n-panel-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.n-word__ar { font-family: var(--font-quran); font-size: 2.5rem; line-height: 1.6; text-align: center; color: var(--emerald); direction: rtl; }
[data-theme="night"] .n-word__ar, [data-theme="emerald"] .n-word__ar { color: var(--gold-light); }
.n-word__tr { text-align: center; font-style: italic; color: var(--ink-soft); }
.n-defs { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-4); margin: 0; }
.n-defs dt { font: 600 var(--fs-small)/1.6 var(--font-ui); color: var(--gold-ink); }
.n-defs dd { margin: 0; }
.n-defs dd:lang(ar) { font-family: var(--font-ar); font-size: 1.1rem; }

.n-tafseer { font-family: var(--font-ar); font-size: 1.15rem; line-height: 1.9; direction: rtl; text-align: right; }
.n-source { font-size: var(--fs-small); color: var(--ink-soft); border-block-start: 1px solid var(--border); padding-block-start: var(--s-3); }

/* ── Audio player ─────────────────────────────────────────────────────── */
.n-player { position: fixed; inset-inline: var(--s-3); inset-block-end: calc(var(--s-3) + env(safe-area-inset-bottom, 0px)); z-index: 30; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-3); min-height: var(--player-h); padding: var(--s-2) var(--s-4); border-radius: var(--r-xl); background: var(--emerald); color: var(--on-emerald); box-shadow: var(--shadow-2); }
[data-theme="night"] .n-player, [data-theme="emerald"] .n-player { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border-strong); }
.n-player__play { width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--gold-light); color: #14100A; cursor: pointer; }
.n-player__play svg { width: 22px; height: 22px; fill: currentColor; }
.n-player__info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.n-player__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n-player__meta { font-size: var(--fs-small); opacity: 0.85; }
.n-player__bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
[data-theme="night"] .n-player__bar, [data-theme="emerald"] .n-player__bar { background: var(--border-strong); }
.n-player__bar > span { display: block; height: 100%; background: var(--gold-light); }
.n-player .n-icon-btn { color: inherit; }
.n-player .n-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.n-player__source { font: 600 var(--fs-tiny)/1 var(--font-ui); padding: 4px 8px; border-radius: var(--r-pill); border: 1px solid currentColor; opacity: 0.8; }
@media (min-width: 900px) { .n-player { inset-inline: auto; inset-inline-end: var(--s-5); inset-block-end: var(--s-5); width: 520px; } }

/* ── Search ───────────────────────────────────────────────────────────── */
.n-search { position: relative; }
.n-search .n-input { padding-inline-start: 48px; border-radius: var(--r-pill); min-height: 52px; }
.n-search svg { position: absolute; inset-inline-start: 16px; inset-block-start: 50%; transform: translateY(-50%); width: 20px; height: 20px; stroke: var(--ink-soft); fill: none; stroke-width: 1.8; }
.n-result { display: block; padding: var(--s-4); border-radius: var(--r-md); text-decoration: none; color: inherit; border: 1px solid transparent; }
.n-result:hover { background: var(--surface); border-color: var(--border); color: inherit; }
.n-result__ref { font: 600 var(--fs-small)/1 var(--font-ui); color: var(--gold-ink); }
.n-result mark { background: var(--highlight-strong); color: inherit; border-radius: 3px; padding-inline: 2px; }

/* ── Library ──────────────────────────────────────────────────────────── */
.n-lib-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.n-book { position: relative; display: flex; flex-direction: column; gap: var(--s-2); min-height: 180px; padding: var(--s-5) var(--s-5) var(--s-4); padding-inline-start: calc(var(--s-5) + 8px); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: inherit; box-shadow: var(--shadow-1); transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
.n-book::before { content: ""; position: absolute; inset-block: 10px; inset-inline-start: 10px; width: 4px; border-radius: 2px; background: var(--book-color, var(--emerald)); }
.n-book:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); color: inherit; }
.n-book__title { font: 700 1.25rem/1.5 var(--font-ar); }
.n-book__author { font-size: var(--fs-small); color: var(--ink-soft); }
.n-book__tags { margin-block-start: auto; display: flex; flex-wrap: wrap; gap: var(--s-1); }
.n-tag { font: 600 var(--fs-tiny)/1 var(--font-ui); padding: 5px 8px; border-radius: var(--r-pill); background: var(--surface-alt); color: var(--ink-soft); }
:lang(ar) .n-tag { font-family: var(--font-ar-small); font-size: 0.8rem; }
.n-toc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.n-toc a { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-2); border-block-end: 1px solid var(--border); color: var(--ink); text-decoration: none; }
.n-toc a:hover { background: var(--surface-alt); }
.n-toc span { color: var(--ink-soft); font-size: var(--fs-small); }

/* ── Feedback ─────────────────────────────────────────────────────────── */
.n-toast { position: fixed; inset-inline: 0; inset-block-end: calc(var(--player-h) + var(--s-6)); margin-inline: auto; width: fit-content; max-width: calc(100% - 32px); padding: var(--s-3) var(--s-5); border-radius: var(--r-pill); background: var(--ink); color: var(--paper); font-weight: 500; box-shadow: var(--shadow-2); z-index: 50; }
.n-offline { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-small); color: var(--ink-soft); }
.n-offline::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
  .n-header, .n-player, .n-appbar, .n-ayah__tools { display: none !important; }
  body { background: #fff; color: #000; }
}

.n-store:hover { color: var(--paper); }
.n-sheet { margin: 0; inset-block-start: auto; max-width: none; padding-bottom: calc(var(--s-6) + env(safe-area-inset-bottom, 0px)); }
@media(min-width:900px) { .n-sheet { inset-block-start:0; } }
