/* ═══════════════ e'thix AI — Document page viewer ═══════════════
   Owner: W3 ETHIX-DOCUMENTS (PK-W3-1). Styles js/doc-viewer.js: a side panel on a desktop, a full-screen sheet on a
   phone (≤ 820 px), and the «ص ٣» triggers other surfaces add. Every class starts with dv- (or is a data-doc-* trigger),
   so nothing here restyles another module. CSP is style-src 'self': nothing is inline. */

dialog.dv{
  --dv-w:min(560px,46vw);
  position:fixed;inset-block:0;inset-inline-end:0;inset-inline-start:auto;z-index:400;
  width:var(--dv-w);max-width:none;height:100dvh;max-height:none;margin:0;padding:0;
  display:flex;flex-direction:column;overflow:hidden;
  background:var(--surface);color:var(--ink);border:0;border-inline-start:1px solid var(--line);box-shadow:var(--shadow-3);
  animation:dv-in .4s var(--ios) both;
}
dialog.dv:not([open]){display:none}
dialog.dv.at-start{inset-inline-start:0;inset-inline-end:auto;border-inline-start:0;border-inline-end:1px solid var(--line)}
dialog.dv::backdrop{background:rgba(18,22,28,.28)}
/* it slides in from the edge it sits on */
dialog.dv.at-start{--dv-dx:-1}
html[dir="rtl"] dialog.dv{--dv-dx:-1}
html[dir="rtl"] dialog.dv.at-start{--dv-dx:1}
@keyframes dv-in{from{opacity:0;transform:translateX(calc(24px * var(--dv-dx,1)))}}
@media (prefers-reduced-motion:reduce){dialog.dv{animation:none}}
html.reduce-motion dialog.dv{animation:none}

.dv-head{display:flex;align-items:center;gap:10px;flex:none;padding:14px 12px 12px 16px;border-bottom:1px solid var(--line)}
html[dir="rtl"] .dv-head{padding:14px 16px 12px 12px}
.dv-ic{width:34px;height:34px;flex:none;border-radius:11px;display:grid;place-items:center;background:var(--g-accent);color:var(--on-accent)}
.dv-ic .i{width:18px;height:18px}
.dv-titles{flex:1;min-width:0;display:grid;gap:2px}
.dv-title{margin:0;font-size:16px;font-weight:700;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;outline:none}
.dv-title:focus-visible{outline:2px solid var(--ring,var(--accent-b));outline-offset:2px;border-radius:4px}
.dv-pos{margin:0;font-size:12.5px;color:var(--muted)}
.dv-x{flex:none}

/* the quoted words, and whether they are on this page */
.dv-quote{flex:none;display:grid;gap:6px;margin:12px 16px 0;padding:10px 12px;border-radius:var(--r-sm,10px);
  background:var(--surface-2);border:1px solid var(--line)}
.dv-quote.found{border-color:color-mix(in srgb,var(--gold) 55%,var(--line))}
.dv-quote.missing{border-color:color-mix(in srgb,var(--warn) 45%,var(--line))}
.dv-quote-k{margin:0;font-size:11.5px;font-weight:800;color:var(--gold-text)}
.dv-quote-t{margin:0;max-height:6.2em;overflow-y:auto;font-size:13.5px;line-height:1.6;color:var(--ink);overflow-wrap:anywhere}
.dv-quote-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px}
.dv-quote-s{flex:1 1 200px;margin:0;font-size:12px;line-height:1.5;color:var(--ink-soft)}
.dv-quote.missing .dv-quote-s{color:var(--ink)}
.dv-jump{flex:none;min-height:32px;padding:4px 10px;border-radius:999px;border:1px solid var(--line);background:var(--surface);
  color:var(--ink);font:inherit;font-size:12.5px;font-weight:600;cursor:pointer}
.dv-jump:focus-visible{outline:2px solid var(--ring,var(--accent-b));outline-offset:2px}
@media (hover:hover){.dv-jump:hover{background:var(--surface-2)}}

/* the page */
.dv-main{flex:1;min-height:0;display:flex;flex-direction:column}
.dv-body{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px 20px 24px;font-size:15.5px;line-height:1.9;
  color:var(--ink);outline:none}
.dv-body:focus-visible{box-shadow:inset 0 0 0 2px var(--ring,var(--accent-b))}
.dv-body:empty{display:none}
.dv-section{margin:0 0 12px;font-size:14px;font-weight:800;color:var(--gold-text)}
.dv-p{margin:0 0 .9em;white-space:pre-wrap;overflow-wrap:anywhere}
.dv-p:last-child{margin-bottom:0}
mark.dv-hl{color:inherit;background:color-mix(in srgb,var(--gold) 42%,transparent);border-radius:3px;
  box-shadow:0 0 0 2px color-mix(in srgb,var(--gold) 42%,transparent)}
mark.dv-hl:focus{outline:2px solid var(--gold-deep,var(--gold));outline-offset:2px}
@media (forced-colors:active){mark.dv-hl{background:Mark;color:MarkText;forced-color-adjust:none}}

.dv-state{display:grid;gap:10px;justify-items:start;margin:16px;padding:12px 14px;border-radius:var(--r-sm,10px);
  background:var(--surface-2);border:1px solid var(--line);font-size:14px;line-height:1.6;color:var(--ink-soft)}
.dv-state[hidden]{display:none}
.dv-state-t{margin:0}
.dv-state.st-gone,.dv-state.st-failed,.dv-state.st-server,.dv-state.st-offline,.dv-state.st-session,.dv-state.st-disclaimer{
  border-color:color-mix(in srgb,var(--danger) 35%,var(--line));color:var(--ink)}
.dv-state.st-loading{border-style:dashed}

/* page arrows: a thumb's reach on a phone, 44 px targets */
.dv-foot{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 14px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line)}
.dv-foot .b{min-height:44px;min-width:44px;display:inline-flex;align-items:center;gap:6px}
.dv-foot .b[disabled]{opacity:.45;cursor:default}
html[dir="rtl"] .dv-foot .i{transform:scaleX(-1)}
.dv-count{font-size:13px;font-weight:600;color:var(--ink-soft);font-variant-numeric:tabular-nums}
.dv-keys{flex:none;margin:0;padding:0 16px 10px;font-size:11.5px;color:var(--muted);text-align:center}
@media (hover:none),(pointer:coarse){.dv-keys{display:none}}

/* a phone and a narrow tablet: the whole screen, like a native reader */
@media (max-width:820px){
  dialog.dv,dialog.dv.at-start{inset:0;width:100%;height:100dvh;border:0;box-shadow:none;
    padding-top:env(safe-area-inset-top);animation-name:dv-up}
  @keyframes dv-up{from{opacity:0;transform:translateY(24px)}}
  .dv-body{padding:14px 16px 20px;font-size:16px}
  .dv-quote{margin:10px 12px 0}
}
/* «السابقة» / «التالية» keep their words down to 330 px; below that the arrows alone (their aria-labels still speak) */
@media (max-width:380px){
  .dv-foot{padding-inline:10px}
  .dv-foot .b{padding-inline:10px}
}
@media (max-width:330px){.dv-foot .b span{display:none}}

/* the triggers other surfaces carry (E.docViewer.link / decorate) */
.dv-link{display:inline-flex;align-items:center;min-height:24px;padding:1px 9px;border-radius:999px;border:1px solid var(--line);
  background:var(--surface-2);color:var(--ink);font:inherit;font-size:12px;font-weight:600;line-height:1.4;cursor:pointer;white-space:nowrap}
.dv-link:focus-visible{outline:2px solid var(--ring,var(--accent-b));outline-offset:2px}
@media (hover:hover){.dv-link:hover{border-color:color-mix(in srgb,var(--gold) 60%,var(--line))}}
[data-doc-id][data-doc-page][role="button"]{cursor:pointer;border-radius:6px}
[data-doc-id][data-doc-page][role="button"]:focus-visible{outline:2px solid var(--ring,var(--accent-b));outline-offset:2px}
/* «مستنداتي»: a ready document's name and state open its first page */
.docs-mine-txt[data-doc-id]{padding:2px 4px;margin:-2px -4px}
@media (hover:hover){.docs-mine-txt[data-doc-id]:hover b{text-decoration:underline;text-underline-offset:2px}}
