/* =====================================================================================================
   VAULT VIEW OPTIONS — R289/§282 P2+P3 (J3). Styles for the folder view-options <dialog> built by
   vault-viewopts.js. Strict-CSP (style-src 'self'): zero inline styles — the js writes dynamic values via
   setProperty only. Scoped entirely under .vlt-vopts.

   TOKENS: every color reads the Vault's own tokens (vault.css @layer tokens) THROUGH a --vo-* indirection
   with a hard fallback, so the panel renders correctly both mounted inside .vlt (inherits the live theme,
   light AND dark) and mounted standalone (probe harness / early integration) where it falls back to the
   Vault's dark palette. Liquid glass per BRIEF non-negotiable 10: chrome surface only, blur+saturate
   FALLBACK-FIRST behind @supports, solid under prefers-reduced-transparency.
   ===================================================================================================== */

/* --- TOKENS. The panel has to render correctly BOTH mounted inside `.vlt` (inherit the live theme) and
   standalone (probe harness / a document.body mount). `var(--ink, <fallback>)` CANNOT carry the standalone
   case: outside `.vlt` those names are still DEFINED — chrome.css `:root` sets `--ink: #eef1f6` and
   `--accent: oklch(...)` — so the fallback never fires and `hsl(#eef1f6)` is invalid at computed-value time
   (the whole declaration drops). Hence the vault-dock.css precedent: a LOCAL mirror of vault.css's HSL
   triplets, dark + light, with the `.vlt .vlt-vopts` rule LAST so an in-Vault mount always tracks the host's
   own tokens (retints and the live scheme flip included). `:where()` keeps the mirror at zero specificity. */
:where(.vlt-vopts) {
  --vo-overlay:  235 16% 13%;
  --vo-box:      235 14% 14.5%;
  --vo-hover:    235 14% 18.5%;
  --vo-line:     235 12% 21%;
  --vo-frame:    235 12% 27%;
  --vo-ink:      235 16% 95%;
  --vo-ink-dull: 235 11% 68%;
  --vo-ink-faint:235 9%  50%;
  --vo-accent:   268 88% 68%;
  --vo-radius:   12px;
  --vo-font:     'Atkinson Hyperlegible', system-ui, sans-serif;
  --vo-font-d:   'Comfortaa', ui-rounded, system-ui, sans-serif;
  --vo-fs:       clamp(12.5px, 12.1px + 0.18vw, 13.5px);
  --vo-fs-sm:    clamp(11.5px, 11.1px + 0.15vw, 12.5px);
  --vo-fs-xs:    clamp(10.5px, 10.1px + 0.15vw, 11.5px);
  color-scheme: dark;
}
/* LIGHT for the standalone mount — attribute override wins, prefers-color-scheme covers the unset case
   (the vault.css / vault-dock.css pattern, same values). */
:root[data-scheme="light"] :where(.vlt-vopts) {
  --vo-overlay:  0 0% 100%;
  --vo-box:      0 0% 100%;
  --vo-hover:    235 26% 93%;
  --vo-line:     235 20% 87%;
  --vo-frame:    235 18% 80%;
  --vo-ink:      235 24% 13%;
  --vo-ink-dull: 235 14% 36%;
  --vo-ink-faint:235 12% 50%;
  --vo-accent:   268 88% 58%;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-scheme]) :where(.vlt-vopts) {
    --vo-overlay:  0 0% 100%;
    --vo-box:      0 0% 100%;
    --vo-hover:    235 26% 93%;
    --vo-line:     235 20% 87%;
    --vo-frame:    235 18% 80%;
    --vo-ink:      235 24% 13%;
    --vo-ink-dull: 235 14% 36%;
    --vo-ink-faint:235 12% 50%;
    --vo-accent:   268 88% 58%;
    color-scheme: light;
  }
}
/* Mounted inside the Vault: defer to the host's own tokens — they are HSL triplets in BOTH schemes there
   (vault.css @layer tokens), so every hsl(var(--vo-*) / a) below stays valid. Declared LAST on purpose. */
.vlt .vlt-vopts {
  --vo-overlay: var(--overlay); --vo-box: var(--box); --vo-hover: var(--hover);
  --vo-line: var(--line); --vo-frame: var(--frame);
  --vo-ink: var(--ink); --vo-ink-dull: var(--ink-dull); --vo-ink-faint: var(--ink-faint);
  --vo-accent: var(--accent); --vo-radius: var(--radius);
  --vo-font: var(--font-body); --vo-font-d: var(--font-display);
  --vo-fs: var(--fs-md); --vo-fs-sm: var(--fs-sm); --vo-fs-xs: var(--fs-xs);
  color-scheme: inherit;
}

.vlt-vopts {
  /* R267 §L1 density law: 44px is a CEILING, not a target — fine-pointer rows sit at 32px and only a
     coarse pointer raises the floor to 44 (BRIEF non-negotiable 7). */
  --vo-tap: 32px;

  padding: 0;
  border: 1px solid hsl(var(--vo-frame) / .85);
  border-radius: var(--vo-radius);
  inline-size: min(420px, calc(100dvw - 24px));
  max-block-size: min(85dvh, 640px);   /* dvh, never vh — OSK/URL-bar honest (ASL law 1) */
  color: hsl(var(--vo-ink));
  font-family: var(--vo-font);
  font-size: var(--vo-fs);
  background: hsl(var(--vo-overlay));  /* solid FIRST — glass is the upgrade, not the baseline */
  box-shadow: 0 24px 64px -24px hsl(235 30% 3% / .6);
}
.vlt-vopts[open] { display: flex; flex-direction: column; }  /* [open]-scoped so the closed dialog stays display:none */
.vlt-vopts::backdrop { background: hsl(235 20% 4% / .45); }

/* liquid glass — @supports-gated enhancement on this chrome surface only (never on rows) */
@supports ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .vlt-vopts {
    background: hsl(var(--vo-overlay) / .74);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    backdrop-filter: blur(18px) saturate(1.35);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .vlt-vopts {
    background: hsl(var(--vo-overlay));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .vlt-vopts::backdrop { background: hsl(235 20% 4% / .7); }
}

/* ---------------- header ---------------- */
.vo-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 10px;
  border-block-end: 1px solid hsl(var(--vo-line) / .8);
  flex: 0 0 auto;
}
.vo-head__t { min-inline-size: 0; flex: 1; }
.vo-title {
  margin: 0;
  font-family: var(--vo-font-d);
  font-size: calc(var(--vo-fs) + 2px);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;  /* long folder names never wrap the head */
}
.vo-sub { margin: 0; font-size: var(--vo-fs-xs); color: hsl(var(--vo-ink-faint)); }
.vo-close {
  flex: 0 0 auto;
  inline-size: var(--vo-tap); block-size: var(--vo-tap);
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent; color: hsl(var(--vo-ink-dull));
  cursor: pointer;
}
.vo-close:hover { background: hsl(var(--vo-hover)); color: hsl(var(--vo-ink)); }
.vo-close svg { inline-size: 1.1em; block-size: 1.1em; }

/* ---------------- scroll body + sections ---------------- */
.vo-body {
  flex: 1 1 auto; min-block-size: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 14px 10px;
  container: vopts / inline-size;   /* component-scoped queries (ASL law: container, not viewport) */
}
.vo-sec { border-block-end: 1px solid hsl(var(--vo-line) / .5); }
.vo-sec:last-child { border-block-end: 0; }
.vo-sec__s {
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  min-block-size: var(--vo-tap);
  padding-block: 4px;
  font-family: var(--vo-font-d);
  font-size: var(--vo-fs-sm);
  font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: hsl(var(--vo-ink-dull));
  cursor: pointer; user-select: none;
}
.vo-sec__s::-webkit-details-marker { display: none; }
.vo-sec__s::before {
  content: ""; inline-size: .55em; block-size: .55em;
  border-inline-end: 2px solid currentColor; border-block-end: 2px solid currentColor;
  transform: rotate(-45deg); transform-origin: 60% 60%;
  transition: transform .15s var(--ease-swift, ease);
}
.vo-sec[open] > .vo-sec__s::before { transform: rotate(45deg); }
.vo-sec__b { padding-block: 2px 10px; display: grid; gap: 2px; }

/* ---------------- rows + native controls ---------------- */
.vo-check {
  display: flex; align-items: center; gap: 10px;
  min-block-size: var(--vo-tap);
  padding-inline: 2px; border-radius: 8px;
  cursor: pointer;
}
.vo-check:hover { background: hsl(var(--vo-hover) / .5); }
.vo-check__t { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vo-cbx {
  inline-size: 16px; block-size: 16px; flex: 0 0 auto;
  accent-color: hsl(var(--vo-accent));
  cursor: pointer;
}
.vo-cbx:disabled { opacity: .45; cursor: default; }

.vo-row {
  display: flex; align-items: center; gap: 10px;
  min-block-size: var(--vo-tap);
  padding-inline: 2px;
}
.vo-row__l { flex: 0 0 auto; inline-size: 34%; min-inline-size: 88px; color: hsl(var(--vo-ink-dull)); font-size: var(--vo-fs-sm); }
.vo-row__c { flex: 1; display: flex; align-items: center; gap: 8px; min-inline-size: 0; }

.vo-select, .vo-num {
  flex: 1; min-inline-size: 0;
  min-block-size: calc(var(--vo-tap) - 6px);
  padding: 4px 8px;
  border: 1px solid hsl(var(--vo-frame) / .8);
  border-radius: 8px;
  background: hsl(var(--vo-box));
  color: hsl(var(--vo-ink));
  font: inherit; font-size: var(--vo-fs-sm);
}
.vo-select--sz { flex: 0 1 8.5em; }
.vo-num { flex: 0 1 5em; font-variant-numeric: tabular-nums; }
.vo-select:focus-visible, .vo-num:focus-visible, .vo-cbx:focus-visible, .vo-grip:focus-visible,
.vo-close:focus-visible, .vo-defaults:focus-visible, .vo-range:focus-visible, .vo-sec__s:focus-visible {
  outline: 2px solid hsl(var(--vo-accent)); outline-offset: 1px;
}

.vo-range { flex: 1; min-inline-size: 0; accent-color: hsl(var(--vo-accent)); block-size: var(--vo-tap); cursor: pointer; }
.vo-out { flex: 0 0 auto; inline-size: 4em; text-align: end; font-size: var(--vo-fs-sm); color: hsl(var(--vo-ink-dull)); font-variant-numeric: tabular-nums; }

/* ---------------- ordered multi-sort: numbered precedence badges ---------------- */
.vo-sortlist { display: grid; gap: 2px; }
.vo-badge {
  flex: 0 0 auto;
  inline-size: 1.55em; block-size: 1.55em;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: var(--vo-fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
  color: transparent; background: transparent;   /* empty badge holds the slot so labels stay aligned */
}
.vo-badge.is-on { background: hsl(var(--vo-accent) / .28); color: hsl(var(--vo-ink)); box-shadow: inset 0 0 0 1px hsl(var(--vo-accent) / .55); }

/* ---------------- Show Columns: check = visible, grip = drag/keys = order ---------------- */
.vo-collist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.vo-colrow {
  display: flex; align-items: center; gap: 2px;
  border-radius: 8px;
  min-block-size: var(--vo-tap);
}
.vo-colrow > .vo-check { flex: 1; min-inline-size: 0; }
.vo-colrow.is-drag { background: hsl(var(--vo-hover)); box-shadow: inset 0 0 0 1px hsl(var(--vo-accent) / .6); }
.vo-grip {
  flex: 0 0 auto;
  inline-size: var(--vo-tap); block-size: var(--vo-tap);
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent; color: hsl(var(--vo-ink-faint));
  cursor: grab;
  touch-action: none;         /* the pointer-drag engine owns this surface — scroll must not eat it */
}
.vo-grip:hover { color: hsl(var(--vo-ink-dull)); background: hsl(var(--vo-hover)); }
.vo-colrow.is-drag .vo-grip { cursor: grabbing; }
.vo-grip svg { inline-size: 1.05em; block-size: 1.05em; }
.vo-grip--off { cursor: default; }
.vo-colrow--pin .vo-check { cursor: default; }
.vo-colrow--pin .vo-check:hover { background: transparent; }

/* ---------------- footer ---------------- */
.vo-foot {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-block-start: 1px solid hsl(var(--vo-line) / .8);
  display: flex; justify-content: center;
}
.vo-defaults {
  min-block-size: var(--vo-tap);
  padding: 6px 18px;
  border: 1px solid hsl(var(--vo-frame));
  border-radius: 10px;
  background: hsl(var(--vo-box));
  color: hsl(var(--vo-ink));
  font: inherit; font-size: var(--vo-fs-sm); font-weight: 600;
  cursor: pointer;
}
.vo-defaults:hover { background: hsl(var(--vo-hover)); border-color: hsl(var(--vo-accent) / .6); }
.vo-defaults:active { transform: translateY(1px); }

/* screen-reader-only live region (reorder announcements) */
.vo-sr {
  position: absolute; inline-size: 1px; block-size: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------------- responsive ----------------
   Coarse pointer: raise every target to the 44px floor (BRIEF: >=44px coarse targets). */
@media (pointer: coarse) {
  .vlt-vopts { --vo-tap: 44px; }
}
/* Wide panel body: the three appearance toggles flow two-up (the sliders/selects keep a full row) —
   a CONTAINER query on the body, per the components-use-container-queries law. */
@container vopts (min-width: 380px) {
  .vo-sec[data-sec="appearance"] .vo-sec__b { grid-template-columns: 1fr 1fr; column-gap: 10px; }
  .vo-sec[data-sec="appearance"] .vo-sec__b > .vo-row { grid-column: 1 / -1; }
}
/* Landscape phone (844x390 class): the dialog goes wide-and-short, body scrolls internally;
   svh keeps it honest when browser chrome collapses. */
@media (max-height: 500px) {
  .vlt-vopts { max-block-size: calc(100svh - 16px); inline-size: min(560px, calc(100dvw - 24px)); }
  .vo-head { padding-block: 8px 6px; }
  .vo-foot { padding-block: 6px; }
}
/* Reduced motion: the disclosure chevron is the only animated thing — stop it. */
@media (prefers-reduced-motion: reduce) {
  .vo-sec__s::before { transition: none; }
  .vo-defaults:active { transform: none; }
}
