/* Accessibility settings (set on <html> by shared/prefs.js) and the
   floating controls shared by every page. Load after theme.css. */

/* ---------- text size ---------- */
/* zoom scales the whole layout together, so pages sized in px still grow
   without text overflowing its boxes. */
:root[data-font-scale="115"] body{ zoom:1.15; }
:root[data-font-scale="130"] body{ zoom:1.3; }

/* ---------- keyboard focus ----------
   The one indicator for everything that can take keyboard focus, on every
   page. Without it a control that declares nothing gets the browser's own
   ring — a black box on these dark panels — so the page ended up with three
   different focus treatments and a fourth that was the browser's.

   :where() carries no specificity, so this is only the default: anything with
   its own rule (the eye button inside a field, an input, the high-contrast
   override below) still wins. :focus-visible, so a mouse press never draws it.
   An outline takes no space, so nothing moves when it appears. */
:where(a[href], area[href], button, input, select, textarea, summary,
       [tabindex]:not([tabindex="-1"]), [contenteditable]):focus-visible{
  outline:2px solid var(--nebula-soft, #7fb3dd);
  outline-offset:2px;
}

/* ---------- high contrast ---------- */
:root[data-contrast="high"]:not([data-theme="light"]){
  --void:#000000;
  --depth:#05060d;
  --panel:#0a0c18;
  --panel-2:#0a0c18;
  --line:#a9b3d9;
  --starlight:#ffffff;
  --dust:#e8ebf7;
  --dust-dim:#cdd2e8;
  --nebula:#4a6bff;
  --nebula-soft:#b3c3ff;
  --grid:#39406a;
}
:root[data-contrast="high"][data-theme="light"]{
  --void:#ffffff;
  --depth:#ffffff;
  --panel:#ffffff;
  --panel-2:#ffffff;
  --line:#1f2937;
  --starlight:#000000;
  --dust:#111827;
  --dust-dim:#374151;
  --nebula:#0a3a9e;
  --nebula-soft:#0a3a9e;
  --brand-hover:#062a75;
  --grid:#9aa3b2;
}
:root[data-contrast="high"] a{ text-decoration:underline; }
:root[data-contrast="high"] :focus-visible{ outline:3px solid #ffbf00 !important; outline-offset:2px !important; }
:root[data-contrast="high"] .card,
:root[data-contrast="high"] .panel,
:root[data-contrast="high"] .kpi,
:root[data-contrast="high"] .item,
:root[data-contrast="high"] .signin-card,
:root[data-contrast="high"] .admin-login-card,
:root[data-contrast="high"] .chat-shell,
:root[data-contrast="high"] .chat-panel{ border:1px solid var(--line) !important; box-shadow:none !important; }
:root[data-contrast="high"] #storm-bg,
:root[data-contrast="high"] #sky,
:root[data-contrast="high"] .grain{ display:none !important; }

/* ---------- reduced motion ---------- */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after{
  animation-duration:.01ms !important;
  animation-iteration-count:1 !important;
  transition-duration:.01ms !important;
  scroll-behavior:auto !important;
}
/* The starfield is continuous motion; with reduced motion it is not drawn. */
:root[data-motion="reduced"] #storm-bg,
:root[data-motion="reduced"] #sky{ display:none !important; }

/* ---------- floating controls ---------- */
.oc-dock{
  position:fixed; right:20px; bottom:20px; z-index:9000;
  display:flex; flex-direction:column; align-items:center; gap:10px;
}
.oc-dock.is-collapsed .oc-fab:not(.oc-chat){ display:none; }
.oc-more{ display:none !important; }
/* Same shape as the page's own outlined controls: see-through, a thin
   border, no shadow — in both themes. */
.oc-fab{
  width:46px; height:46px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  background:transparent; backdrop-filter:blur(6px);
  color:var(--starlight);
  border:1px solid var(--line);
  cursor:pointer; padding:0; font:600 13px/1 'Lusail','Manrope',system-ui,sans-serif;
  text-decoration:none;
  transition:border-color .15s ease, background .15s ease, transform .15s ease;
}
.oc-fab:hover{ border-color:var(--nebula-soft); transform:translateY(-1px); }
.oc-fab:focus-visible{ outline:2px solid var(--nebula-soft); outline-offset:2px; }
.oc-fab svg{ width:20px; height:20px; }
.oc-fab[aria-pressed="true"]{ border-color:var(--nebula-soft); color:var(--nebula-soft); }
.oc-fab.oc-chat{
  width:56px; height:56px;
  border-color:var(--nebula-soft); color:var(--nebula-soft);
}
.oc-fab.oc-chat svg{ width:24px; height:24px; }
.oc-top{
  position:fixed; left:20px; bottom:20px; z-index:9000;
  opacity:0; pointer-events:none; transform:translateY(8px);
  transition:opacity .2s ease, transform .2s ease;
}
.oc-top.is-visible{ opacity:1; pointer-events:auto; transform:none; }

.oc-a11y{
  position:fixed; right:80px; bottom:20px; z-index:9001;
  width:min(280px, calc(100vw - 110px));
  background:var(--panel); color:var(--starlight);
  border:1px solid var(--line); border-radius:14px;
  padding:14px 16px; display:flex; flex-direction:column; gap:12px;
  font:14px/1.4 'Lusail','Manrope',system-ui,sans-serif;
}
.oc-a11y[hidden]{ display:none; }
.oc-a11y h2{ margin:0; font-size:15px; font-weight:700; }
.oc-a11y .oc-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.oc-a11y .oc-row span{ color:var(--dust); font-size:13px; }
.oc-seg{ display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.oc-seg button{
  background:none; border:0; color:var(--starlight); padding:6px 10px; cursor:pointer;
  font:600 12px/1 'Lusail','Manrope',system-ui,sans-serif; min-width:40px;
}
.oc-seg button + button{ border-inline-start:1px solid var(--line); }
.oc-seg button[aria-pressed="true"]{ background:var(--nebula); color:#ffffff; }
.oc-switch{
  position:relative; width:42px; height:24px; border-radius:999px; flex:none;
  background:var(--depth); border:1px solid var(--line); cursor:pointer; padding:0;
}
.oc-switch::after{
  content:""; position:absolute; top:2px; inset-inline-start:2px; width:18px; height:18px; border-radius:50%;
  background:var(--dust); transition:inset-inline-start .15s ease, background .15s ease;
}
.oc-switch[aria-checked="true"]{ background:var(--nebula); border-color:var(--nebula); }
.oc-switch[aria-checked="true"]::after{ inset-inline-start:20px; background:#ffffff; }
.oc-a11y .oc-reset{
  align-self:flex-start; background:none; border:0; padding:0; cursor:pointer;
  color:var(--nebula-soft); font:inherit; font-size:13px; text-decoration:underline;
}
@media (max-width:520px){
  .oc-dock{ right:12px; bottom:12px; gap:8px; }
  .oc-top{ left:12px; bottom:12px; }
  /* On a phone the dock sits over the text, so see-through buttons mix
     their icon with the words behind them — give them a solid face. */
  .oc-fab{ width:42px; height:42px; background:var(--panel); }
  .oc-dock:not(.is-collapsed) .oc-more{ display:inline-flex !important; }
  .oc-dock.is-folded .oc-fab:not(.oc-chat):not(.oc-more){ display:none; }
  .oc-a11y{ right:64px; bottom:12px; }
}
@media print{
  .oc-dock, .oc-top, .oc-a11y{ display:none !important; }
}
