/*
 * Pyrix web · controls: the one set of form controls every page draws (dashboard, site, share pages).
 * Real inputs stay underneath (forms post without JS; names, ids and values are untouched). This file draws them in
 * the glass-cockpit look (DESIGN.md: black glass, Edge 2 frames, 3px corners, Pyrix blue as the only accent), and
 * /js/controls.js adds what CSS cannot: the select listbox, the colour picker, the slider fill, the search clear key
 * and tooltips. Everything here is :where()-wrapped (zero specificity), so a page's own rule always wins.
 * Hidden-input tiles (an input stretched invisible over its tile) are listed in --tiles below and left alone.
 */

:root {
  --c-void: #000;
  --c-well: #050506;
  --c-raise: #0c0c0f;
  --c-raise-2: #141418;
  --c-edge: rgba(255, 255, 255, 0.075);
  --c-edge-2: rgba(255, 255, 255, 0.13);
  --c-edge-hi: rgba(255, 255, 255, 0.22);
  --c-text: #f2f4f7;
  --c-text-2: #a4a9b4;
  --c-text-3: #767d8a;
  --c-blue: #3b82f6;
  --c-blue-2: #60a5fa;
  --c-blue-btn: #1d64e0;
  --c-blue-btn-2: #1e66e6;
  --c-blue-ink: #93c5fd;
  --c-wash: rgba(59, 130, 246, 0.1);
  --c-line-blue: rgba(59, 130, 246, 0.55);
  --c-red: #ef4444;
  --c-r: 3px;
  --c-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --c-t1: 110ms;
  --c-t2: 160ms;
  --c-ring: 0 0 0 3px rgba(59, 130, 246, 0.2);   /* (kept for pages that still use it; the controls draw the one ring) */
  --c-h: 36px;                                    /* a field's height; the dashboard sets the standard 40px */
  --c-drop: 0 20px 48px -12px rgba(0, 0, 0, 0.85);
  --c-mono: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
}

/* ---------- checkbox and radio ---------- */
:where(input[type="checkbox"], input[type="radio"]):where(:not(span.d-switch > input, input.d-switch, .sn-chips input, .al-grp input, .pl-key input, .rd2-chips-seg input, .rc-seg input, .rc-raid input, .rc-hl input, .c-native)) {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--c-edge-hi);
  border-radius: var(--c-r);
  background: var(--c-void) no-repeat center / 12px 12px;
  vertical-align: -3px;
  cursor: pointer;
  transition: background-color var(--c-t1), border-color var(--c-t1), box-shadow var(--c-t1);
}
:where(input[type="radio"]):where(:not(.sn-chips input, .al-grp input, .pl-key input, .rd2-chips-seg input, .rc-seg input, .rc-raid input, .c-native)) {
  border-radius: 50%;
}
:where(input[type="checkbox"], input[type="radio"]):where(:not(span.d-switch > input, input.d-switch, .c-native)):hover {
  border-color: rgba(255, 255, 255, 0.36);
}
:where(input[type="checkbox"]):where(:not(span.d-switch > input, input.d-switch, .c-native)):checked {
  border-color: var(--c-blue-btn);
  background-color: var(--c-blue-btn);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 4.9 8.6 9.6 3.6' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:where(input[type="checkbox"]):where(:not(span.d-switch > input, input.d-switch, .c-native)):indeterminate {
  border-color: var(--c-blue-btn);
  background-color: var(--c-blue-btn);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6h6' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
:where(input[type="radio"]):where(:not(.sn-chips input, .al-grp input, .pl-key input, .rd2-chips-seg input, .rc-seg input, .rc-raid input, .c-native)):checked {
  border-color: var(--c-blue-2);
  background-color: var(--c-blue-2);
  box-shadow: inset 0 0 0 3.5px var(--c-void);
}
:where(input[type="checkbox"], input[type="radio"]):where(:not(span.d-switch > input, input.d-switch, .c-native)):focus-visible {
  outline: 1.5px solid var(--c-blue-2);
  outline-offset: 2px;
}
:where(input[type="checkbox"], input[type="radio"]):where(:not(span.d-switch > input, input.d-switch, .c-native)):disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
:where(input[type="checkbox"], input[type="radio"]):where(:not(span.d-switch > input, input.d-switch, .c-native)):user-invalid {
  border-color: rgba(239, 68, 68, 0.7);
}

/* ---------- range: a 4px square-ended scale with a blue reading (the fill comes from --c-fill, set by controls.js;
   Firefox draws it natively) and a white key ---------- */
:where(input[type="range"]):where(:not(.sr-range, .c-native)) {
  --c-fill: 0%;
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
:where(input[type="range"]):where(:not(.sr-range, .c-native))::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 0;
  background: linear-gradient(to right, var(--c-blue) 0 var(--c-fill), rgba(255, 255, 255, 0.14) var(--c-fill) 100%);
}
:where(input[type="range"]):where(:not(.sr-range, .c-native))::-moz-range-track {
  height: 4px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.14);
}
:where(input[type="range"]):where(:not(.sr-range, .c-native))::-moz-range-progress {
  height: 4px;
  background: var(--c-blue);
}
:where(input[type="range"]):where(:not(.sr-range, .c-native))::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 20px;
  margin-top: -8px;
  border: 1px solid #000;
  border-radius: 2px;
  background: var(--c-text);
  box-shadow: 0 0 0 1px var(--c-edge-hi);
  transition: background-color var(--c-t1), box-shadow var(--c-t1), transform var(--c-t1) var(--c-ease);
}
:where(input[type="range"]):where(:not(.sr-range, .c-native))::-moz-range-thumb {
  width: 10px;
  height: 18px;
  border: 1px solid #000;
  border-radius: 2px;
  background: var(--c-text);
  box-shadow: 0 0 0 1px var(--c-edge-hi);
  transition: background-color var(--c-t1), box-shadow var(--c-t1), transform var(--c-t1) var(--c-ease);
}
:where(input[type="range"]):where(:not(.sr-range, .c-native)):hover::-webkit-slider-thumb { background: #fff; }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):hover::-moz-range-thumb { background: #fff; }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):active::-webkit-slider-thumb { background: var(--c-blue-ink); transform: scaleY(1.1); }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):active::-moz-range-thumb { background: var(--c-blue-ink); }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):focus-visible { outline: none; }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--c-blue-2), 0 0 0 4px rgba(59, 130, 246, 0.35); }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--c-blue-2), 0 0 0 4px rgba(59, 130, 246, 0.35); }
:where(input[type="range"]):where(:not(.sr-range, .c-native)):disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- number and search fields: no spinner, no browser clear glyph (controls.js adds the clear key) ---------- */
:where(input[type="number"]) { -moz-appearance: textfield; appearance: textfield; }
:where(input[type="number"])::-webkit-inner-spin-button,
:where(input[type="number"])::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
:where(input[type="search"]) { -webkit-appearance: none; appearance: none; }
:where(input[type="search"])::-webkit-search-cancel-button,
:where(input[type="search"])::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* one focus ring per field: a text input inside a framed field never draws its own (the frame shows :focus-within) */
:where(.d-field, label.d-input, div.d-input, .pl-q, .ix-find, .rd2-field, .c-field) :where(input, textarea):focus-visible {
  outline: none;
  box-shadow: none;
}

/* the clear key controls.js puts inside a search field */
.c-clear {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0 -2px 0 2px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--c-text-3);
  cursor: pointer;
  transition: color var(--c-t1), border-color var(--c-t1), background-color var(--c-t1);
}
.c-clear:hover { color: var(--c-text); border-color: var(--c-edge-2); background: var(--c-raise); }
.c-clear[hidden] { display: none; }
.c-clear svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
@media (pointer: coarse) { .c-clear { width: 32px; height: 32px; } }

/* ---------- select: the real <select> stays (hidden, still posts); a key shows the value, a listbox opens over the
   page in the top layer ---------- */
select.c-sel-on {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip-path: inset(50%) !important;
}
:where(select):where(:not(.c-sel-on, [multiple], .c-native)) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background: var(--c-void) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.6 3 3 3-3' fill='none' stroke='%23767d8a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center / 12px 12px;
}
.d-select :where(select):where(:not(.c-sel-on)) { background-image: none; }
:where(select) option { background: #0c0c0f; color: var(--c-text); }

.c-sel-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: var(--c-h);
  padding: 0 32px 0 12px;
  border: 1px solid var(--c-edge-2);
  border-radius: var(--c-r);
  background: var(--c-void);
  color: var(--c-text);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--c-t1), box-shadow var(--c-t1), background-color var(--c-t1);
}
.d-select > .c-sel-btn,
.c-sel-btn.c-sel-full { width: 100%; }
.c-sel-btn:hover { border-color: var(--c-edge-hi); }
/* the one focus ring (1.5px Lit Blue, 2px off); an open list keeps its key's frame lit */
.c-sel-btn:focus-visible {
  outline: 1.5px solid var(--c-blue-2);
  outline-offset: 2px;
  border-color: var(--c-blue);
}
.c-sel-btn[aria-expanded="true"] { border-color: var(--c-blue); }
.c-sel-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.c-sel-btn > .c-sel-v {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-sel-btn > .c-sel-chev {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  stroke: var(--c-text-3);
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  transition: transform var(--c-t2) var(--c-ease), stroke var(--c-t1);
}
.c-sel-btn { position: relative; }
.c-sel-btn[aria-expanded="true"] > .c-sel-chev { transform: rotate(180deg); stroke: var(--c-blue-2); }
/* the wrapper's own chevron icon gives way to the key's */
.d-select:has(> .c-sel-btn) > .ico { display: none; }

/* the floating listbox and picker panels (top layer via popover) */
.c-pop {
  position: fixed;
  inset: auto;
  left: var(--c-x, 0px);
  top: var(--c-y, 0px);
  min-width: var(--c-w, 160px);
  max-width: min(420px, calc(100vw - 16px));
  margin: 0;
  padding: 4px;
  border: 1px solid var(--c-edge-2);
  border-radius: 4px;
  background: rgba(5, 5, 6, 0.96);
  color: var(--c-text);
  box-shadow: var(--c-drop);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  overscroll-behavior: contain;
}
/* a closed panel stays out of the page (its own display: flex / grid would beat the browser's popover rule) */
.c-pop:not(:popover-open) { display: none; }
.c-pop:popover-open { animation: c-pop-in var(--c-t2) var(--c-ease); }
.c-pop.up:popover-open { animation-name: c-pop-up; }
@keyframes c-pop-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes c-pop-up { from { opacity: 0; transform: translateY(4px); } }
.c-list { display: flex; flex-direction: column; max-height: min(var(--c-h, 320px), 320px); }
.c-list-q {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 40px;
  margin: 0 0 4px;
  padding: 0 10px;
  border-bottom: 1px solid var(--c-edge);
  color: var(--c-text-3);
  transition: border-color var(--c-t1), color var(--c-t1);
}
/* the list's search line shows focus on its rule (its input draws none) */
.c-list-q:focus-within { border-bottom-color: var(--c-blue); color: var(--c-blue-2); }
.c-list-q svg { width: 13px; height: 13px; flex: none; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; }
.c-list-q input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--c-text);
  font: inherit;
}
.c-list-q input::placeholder { color: var(--c-text-3); }
.c-list-o {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #26272c transparent;
}
.c-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 30px 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--c-r);
  color: var(--c-text-2);
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
}
.c-opt.on {
  border-color: var(--c-edge-2);
  background: var(--c-raise);
  color: var(--c-text);
}
.c-opt[aria-selected="true"] { color: var(--c-text); font-weight: 600; }
.c-opt[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 4.9 8.6 9.6 3.6' fill='none' stroke='%2360a5fa' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.c-opt[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.c-opt-sub { margin-left: auto; padding-left: 12px; color: var(--c-text-3); font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-opt-g {
  padding: 8px 10px 4px;
  color: var(--c-text-3);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.c-list-none { padding: 10px; color: var(--c-text-3); }
@media (pointer: coarse) { .c-opt { min-height: 44px; } }

/* ---------- colour: a swatch key opens a picker (saturation/brightness field, hue scale, hex field, presets) ---------- */
input[type="color"].c-color-on {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip-path: inset(50%) !important;
}
:where(input[type="color"]):where(:not(.c-color-on, .c-native)) {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--c-edge-2);
  border-radius: 2px;
  background: var(--c-void);
  cursor: pointer;
}
:where(input[type="color"])::-webkit-color-swatch-wrapper { padding: 0; }
:where(input[type="color"])::-webkit-color-swatch { border: 0; border-radius: 1px; }
:where(input[type="color"])::-moz-color-swatch { border: 0; border-radius: 1px; }
.c-color-btn {
  position: relative;
  flex: none;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--c-edge-2);
  border-radius: 2px;
  background: var(--c-void);
  cursor: pointer;
  transition: border-color var(--c-t1), box-shadow var(--c-t1);
}
.c-color-btn::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 1px;
  background: var(--c-val, #fff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.c-color-btn:hover { border-color: var(--c-edge-hi); }
.c-color-btn:focus-visible { outline: 1.5px solid var(--c-blue-2); outline-offset: 2px; border-color: var(--c-blue); }
.c-color-btn[aria-expanded="true"] { border-color: var(--c-blue); }
@media (pointer: coarse) { .c-color-btn { width: 36px; height: 32px; } }
.c-cp { display: grid; gap: 10px; width: 232px; padding: 10px; }
.c-cp-sv {
  position: relative;
  height: 140px;
  border-radius: 2px;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(var(--c-h, 210) 100% 50%);
  cursor: crosshair;
  touch-action: none;
}
.c-cp-sv > i {
  position: absolute;
  left: var(--c-sx, 0%);
  top: var(--c-sy, 0%);
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.c-cp-hue {
  position: relative;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
  touch-action: none;
}
.c-cp-hue > i {
  position: absolute;
  left: var(--c-hx, 0%);
  top: -3px;
  bottom: -3px;
  width: 6px;
  margin-left: -3px;
  border: 1px solid #000;
  border-radius: 2px;
  background: #fff;
  pointer-events: none;
}
.c-cp-sv:focus-visible,
.c-cp-hue:focus-visible { outline: 1.5px solid var(--c-blue-2); outline-offset: 2px; }
.c-cp-row { display: flex; align-items: center; gap: 8px; }
.c-cp-hex {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--c-edge-2);
  border-radius: var(--c-r);
  background: var(--c-void);
  color: var(--c-text);
  font-family: var(--c-mono);
  font-size: 12px;
  text-transform: uppercase;
}
.c-cp-hex:hover { border-color: var(--c-edge-hi); }
.c-cp-hex:focus-visible { outline: 1.5px solid var(--c-blue-2); outline-offset: 2px; border-color: var(--c-blue); }
.c-cp-sw { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.c-cp-sw button {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--c-edge-2);
  border-radius: 2px;
  background: var(--c-val, #000);
  cursor: pointer;
}
.c-cp-sw button:hover { border-color: rgba(255, 255, 255, 0.5); }
.c-cp-sw button[aria-pressed="true"] { outline: 1.5px solid var(--c-blue-2); outline-offset: 1px; }

/* ---------- tooltip: replaces the browser's title bubble (the title text stays the element's description) ---------- */
.c-tip {
  position: fixed;
  left: var(--c-x, 0px);
  top: var(--c-y, 0px);
  z-index: 2147483000;
  max-width: min(300px, calc(100vw - 16px));
  padding: 5px 8px;
  border: 1px solid var(--c-edge-2);
  border-radius: 3px;
  background: rgba(8, 8, 10, 0.97);
  color: var(--c-text);
  box-shadow: 0 10px 28px -8px rgba(0, 0, 0, 0.9);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity var(--c-t1) var(--c-ease), transform var(--c-t1) var(--c-ease);
}
.c-tip.on { opacity: 1; transform: none; }
.c-tip[hidden] { display: none; }

/* ---------- a strip that scrolls sideways shows a fade on the edge that still has more (controls.js) ---------- */
.c-more-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.c-more-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); }
.c-more-l.c-more-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }

/* ---------- first paint: what is on screen when the page opens stands still; the same cards animate when a state
   change brings them in later (controls.js sets c-ready ~0.7 s after load; a 0s duration does not replay then) ---------- */
html:not(.c-ready) :is(.rc-card, .rd2-state-card, .rd2-banner, .rd2-gm, .g-stage.on) { animation-duration: 0s; }

/* ---------- browser surfaces: scrollbars and selection on pages that set neither ---------- */
:where(html) { scrollbar-color: #26272c #000; }
:where(html) ::selection { background: rgba(59, 130, 246, 0.38); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .c-pop:popover-open,
  .c-pop.up:popover-open { animation: none; }
  .c-tip,
  .c-sel-btn > .c-sel-chev { transition: none; }
}
