/* NDI document viewer: chrome (P3/P4). Complete replacement for assets/ndi_viewer.css.
   Window, header, notice, status, error, page area, phone sheet. The watermark layer
   (ndi_watermark.css) is not touched: it lives inside .ndi-viewer-paper and the chrome
   (header, notice, status) sits outside it, so nothing overlaps the marks.
   Tokens come from the site (--navy, --gold, --serif, --sans); fallbacks keep the file
   working on any page. There is deliberately no download or print control. */

body.ndi-viewer-open{overflow:hidden}

dialog.ndi-viewer{
  --v-bg:#2b3442;           /* reading area, from the approved design */
  --v-bar:var(--navy,#0E1F38);
  --v-strip:#1f2b3d;        /* notice and status strips */
  --v-ink:#fff;
  --v-soft:#c9d8e6;         /* secondary text on navy and strip, 9:1 or better */
  --v-focus:var(--gold,#E6B450);
  --v-ic-lock:url("data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20viewBox=%270%200%2024%2024%27%20fill=%27none%27%20stroke=%27black%27%20stroke-width=%272%27%20stroke-linecap=%27round%27%20stroke-linejoin=%27round%27%3E%3Crect%20x=%275%27%20y=%2711%27%20width=%2714%27%20height=%279%27%20rx=%272%27/%3E%3Cpath%20d=%27M8%2011V8a4%204%200%200%201%208%200v3%27/%3E%3C/svg%3E");
  --v-ic-x:url("data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20viewBox=%270%200%2024%2024%27%20fill=%27none%27%20stroke=%27black%27%20stroke-width=%272%27%20stroke-linecap=%27round%27%20stroke-linejoin=%27round%27%3E%3Cpath%20d=%27M5%205l14%2014M19%205%205%2019%27%20stroke-width=%272.6%27/%3E%3C/svg%3E");
  --v-ic-warn:url("data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20viewBox=%270%200%2024%2024%27%20fill=%27none%27%20stroke=%27black%27%20stroke-width=%272%27%20stroke-linecap=%27round%27%20stroke-linejoin=%27round%27%3E%3Cpath%20d=%27M12%203%202%2020h20L12%203z%27/%3E%3Cpath%20d=%27M12%2010v5M12%2017.5v.5%27/%3E%3C/svg%3E");
  position:fixed;inset:0;margin:auto;
  width:min(96vw,1040px);max-width:96vw;
  height:94vh;height:94dvh;max-height:94vh;max-height:94dvh;
  padding:0;border:0;border-radius:14px;overflow:hidden;
  display:flex;flex-direction:column;
  background:var(--v-bg);color:var(--v-ink);
  font-family:var(--sans,'Inter',system-ui,-apple-system,'Segoe UI',Arial,sans-serif);
  box-shadow:0 24px 70px rgba(7,14,26,.55);
}
dialog.ndi-viewer:not([open]){display:none}
dialog.ndi-viewer::backdrop{background:rgba(14,31,56,.62)}

/* ---- header: title, subtitle, close ---- */
.ndi-viewer-header{
  flex:none;display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:14px;align-items:center;
  padding:10px 12px 10px 22px;background:var(--v-bar);
}
dialog.ndi-viewer .ndi-viewer-header h3{
  grid-column:1;grid-row:1;margin:0;color:var(--v-ink);
  font-family:var(--serif,'Source Serif 4',Georgia,serif);font-size:18px;line-height:1.3;font-weight:600;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
dialog.ndi-viewer .ndi-viewer-header p.note{
  grid-column:1;grid-row:2;margin:1px 0 0;color:#b9c6d6;font-size:12.5px;line-height:1.4;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
dialog.ndi-viewer .ndi-viewer-header p.note:empty{display:none}
dialog.ndi-viewer .ndi-viewer-header button{
  grid-column:2;grid-row:1 / span 2;
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-width:44px;min-height:44px;padding:0 16px 0 13px;
  border:1px solid rgba(255,255,255,.28);border-radius:10px;background:rgba(255,255,255,.10);color:var(--v-ink);
  font:600 14px/1 var(--sans,'Inter',system-ui,sans-serif);cursor:pointer;
}
dialog.ndi-viewer .ndi-viewer-header button::before{
  content:"";width:14px;height:14px;flex:none;background:currentColor;
  -webkit-mask:var(--v-ic-x) center/contain no-repeat;mask:var(--v-ic-x) center/contain no-repeat;
}
dialog.ndi-viewer .ndi-viewer-header button:hover{background:rgba(255,255,255,.20);border-color:rgba(255,255,255,.45)}
dialog.ndi-viewer button:focus-visible{outline:3px solid var(--v-focus);outline-offset:2px}

/* ---- "View only" notice (second child, plain p.note) ---- */
dialog.ndi-viewer > p.note:not([role="status"]){
  flex:none;margin:0;padding:8px 22px;display:flex;align-items:center;gap:9px;
  background:var(--v-strip);color:var(--v-soft);font-size:12.5px;line-height:1.4;
  border-top:1px solid rgba(255,255,255,.06);
}
dialog.ndi-viewer > p.note:not([role="status"])::before{
  content:"";width:14px;height:14px;flex:none;background:currentColor;
  -webkit-mask:var(--v-ic-lock) center/contain no-repeat;mask:var(--v-ic-lock) center/contain no-repeat;
}

/* ---- status line: loading or error (hook classes .is-loading / .is-error, see MARKUP_NOTES) ---- */
dialog.ndi-viewer > p[role="status"]{
  flex:none;margin:0;padding:8px 22px;background:#243247;color:#dbe4ee;font-size:13px;line-height:1.4;
  display:flex;align-items:center;gap:10px;border-top:1px solid rgba(255,255,255,.06);
}
dialog.ndi-viewer > p[role="status"]:empty{display:none}
dialog.ndi-viewer > p[role="status"].is-loading::before{
  content:"";width:14px;height:14px;flex:none;border-radius:50%;
  border:2px solid rgba(255,255,255,.28);border-top-color:var(--v-focus);animation:ndiVwSpin .8s linear infinite;
}
/* centred spinner in the empty page area while the first bytes load */
dialog.ndi-viewer > p[role="status"].is-loading ~ .ndi-viewer-paper .ndi-viewer-body:empty::before{
  content:"";position:absolute;left:50%;top:50%;width:34px;height:34px;margin:-17px 0 0 -17px;border-radius:50%;
  border:3px solid rgba(255,255,255,.2);border-top-color:var(--v-focus);animation:ndiVwSpin .8s linear infinite;
}
@keyframes ndiVwSpin{to{transform:rotate(360deg)}}

/* error: the status line becomes the whole content area */
dialog.ndi-viewer > p[role="status"].is-error{
  flex:1;min-height:0;flex-direction:column;justify-content:center;text-align:center;gap:14px;
  padding:32px 28px;background:var(--v-bg);border-top:0;color:var(--v-ink);font-size:16px;line-height:1.5;
}
dialog.ndi-viewer > p[role="status"].is-error::before{
  content:"";width:44px;height:44px;flex:none;background:#f3b4ab;
  -webkit-mask:var(--v-ic-warn) center/contain no-repeat;mask:var(--v-ic-warn) center/contain no-repeat;
}
dialog.ndi-viewer > p[role="status"].is-error::after{
  content:"Use Close to go back to the page.";font-size:13px;color:var(--v-soft);
}
dialog.ndi-viewer > p[role="status"].is-error ~ .ndi-viewer-paper{display:none}

/* ---- page area ---- */
.ndi-viewer-paper{position:relative;flex:1;min-height:0;background:var(--v-bg)}
.ndi-viewer-body{
  height:100%;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  padding:22px 18px 36px;display:flex;flex-direction:column;align-items:center;gap:18px;
  scrollbar-color:#58677f transparent;-webkit-user-select:none;user-select:none;
}
.ndi-viewer-page{
  flex:none;display:block;width:auto;max-width:min(100%,860px);height:auto;margin:0;
  background:#fff;box-shadow:0 4px 18px rgba(0,0,0,.4);
}
/* Word documents: the iframe fills the area (the page look comes from the document itself) */
.ndi-viewer-body:has(> .ndi-viewer-frame){display:block;padding:0}
.ndi-viewer-frame{display:block;width:100%;height:100%;border:0;background:#808080}

/* ---- phone: full-screen sheet, safe areas, large targets ---- */
@media (max-width:640px){
  dialog.ndi-viewer{width:100vw;max-width:none;height:100vh;height:100dvh;max-height:none;border-radius:0;box-shadow:none}
  .ndi-viewer-header{
    padding:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left));
  }
  dialog.ndi-viewer .ndi-viewer-header h3{font-size:16px}
  dialog.ndi-viewer .ndi-viewer-header button{min-width:48px;min-height:48px;padding:0 14px 0 12px}
  dialog.ndi-viewer > p.note:not([role="status"]),dialog.ndi-viewer > p[role="status"]{
    padding-left:max(16px,env(safe-area-inset-left));padding-right:max(16px,env(safe-area-inset-right));
  }
  .ndi-viewer-body{padding:12px 8px max(28px,env(safe-area-inset-bottom));gap:12px;touch-action:pan-x pan-y pinch-zoom}
  .ndi-viewer-body:has(> .ndi-viewer-frame){padding:0 0 env(safe-area-inset-bottom)}
}
@media (max-height:480px) and (orientation:landscape){
  .ndi-viewer-header{padding-top:6px;padding-bottom:6px}
  dialog.ndi-viewer .ndi-viewer-header button{min-height:40px}
  dialog.ndi-viewer > p.note:not([role="status"]){padding-top:4px;padding-bottom:4px}
}

/* ---- motion: one short fade; spinners are working indicators and stay, but stop when motion is reduced ---- */
@media (prefers-reduced-motion:no-preference){
  :root:not([data-nm-reduce="1"]) dialog.ndi-viewer[open]{animation:ndiVwIn .18s ease-out both}
  @keyframes ndiVwIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
}
@media (prefers-reduced-motion:reduce){
  dialog.ndi-viewer > p[role="status"].is-loading::before,
  dialog.ndi-viewer > p[role="status"].is-loading ~ .ndi-viewer-paper .ndi-viewer-body:empty::before{animation:none}
}
:root[data-nm-reduce="1"] dialog.ndi-viewer > p[role="status"].is-loading::before,
:root[data-nm-reduce="1"] dialog.ndi-viewer > p[role="status"].is-loading ~ .ndi-viewer-paper .ndi-viewer-body:empty::before{animation:none}

@media print{dialog.ndi-viewer{display:none !important}}
