/* ============================================================
   OORT — Component styles
   Class-based so primitives get real hover/focus/active states.
   All values reference the design tokens.
   ============================================================ */

/* ---------- Button ---------- */
.oort-btn {
  --_bg: var(--surface-raised);
  --_fg: var(--text-primary);
  --_bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--_fg);
  background: var(--_bg);
  border: var(--border-thin) solid var(--_bd);
  border-radius: var(--radius-xs);
  box-shadow: var(--etch-top);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-color), transform var(--dur-instant) var(--ease-servo);
  user-select: none;
}
.oort-btn:hover { background: var(--surface-hover); border-color: var(--steel-300); }
.oort-btn:active { transform: translateY(1px); }
.oort-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.oort-btn:disabled,
.oort-btn[aria-disabled="true"] {
  opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: var(--etch-top);
}

.oort-btn.sz-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-2xs); letter-spacing: var(--tracking-wider); }
.oort-btn.sz-md { height: 38px; padding: 0 var(--space-5); font-size: var(--text-xs); }
.oort-btn.sz-lg { height: 48px; padding: 0 var(--space-8); font-size: var(--text-sm); }
.oort-btn.is-block { display: flex; width: 100%; }

.oort-btn.is-primary {
  --_bg: var(--ion-400); --_fg: var(--text-on-ion); --_bd: var(--ion-300);
  box-shadow: var(--etch-top), var(--glow-soft-ion);
}
.oort-btn.is-primary:hover { background: var(--ion-300); border-color: var(--ion-200); }
.oort-btn.is-secondary { --_bg: transparent; --_fg: var(--ion-300); --_bd: var(--ion-600); }
.oort-btn.is-secondary:hover { background: rgba(47,227,207,0.08); border-color: var(--ion-400); }
.oort-btn.is-ghost { --_bg: transparent; --_fg: var(--text-secondary); --_bd: transparent; box-shadow: none; }
.oort-btn.is-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }
.oort-btn.is-danger { --_bg: transparent; --_fg: var(--status-crit); --_bd: rgba(255,77,73,0.45); }
.oort-btn.is-danger:hover { background: rgba(255,77,73,0.10); border-color: var(--status-crit); }
.oort-btn .oort-btn__icon { display: inline-flex; width: 1em; height: 1em; }
.oort-btn .oort-btn__icon svg { width: 100%; height: 100%; }

/* ---------- IconButton ---------- */
.oort-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition-color);
}
.oort-iconbtn:hover { background: var(--surface-hover); color: var(--text-primary); border-color: var(--border-hairline); }
.oort-iconbtn:active { background: var(--surface-raised); }
.oort-iconbtn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.oort-iconbtn:disabled { opacity: 0.4; cursor: not-allowed; }
.oort-iconbtn.sz-sm { width: 30px; height: 30px; }
.oort-iconbtn.sz-md { width: 38px; height: 38px; }
.oort-iconbtn.sz-lg { width: 48px; height: 48px; }
.oort-iconbtn.is-active { color: var(--ion-400); border-color: var(--ion-600); background: rgba(47,227,207,0.06); }
.oort-iconbtn svg { width: 1.15em; height: 1.15em; }
.oort-iconbtn.sz-sm svg { font-size: 15px; }
.oort-iconbtn.sz-md svg { font-size: 17px; }
.oort-iconbtn.sz-lg svg { font-size: 20px; }

/* ---------- Badge ---------- */
.oort-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 8px;
  font-family: var(--font-display); font-weight: var(--weight-semibold);
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase;
  border-radius: var(--radius-xs);
  border: var(--border-thin) solid var(--border-hairline);
  color: var(--text-secondary);
  background: var(--surface-raised);
}
.oort-badge .oort-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.oort-badge.tone-ion    { color: var(--ion-300);    border-color: var(--ion-700);   background: rgba(47,227,207,0.07); }
.oort-badge.tone-ok     { color: var(--status-ok);  border-color: rgba(52,217,138,0.35); background: rgba(52,217,138,0.07); }
.oort-badge.tone-warn   { color: var(--status-warn);border-color: rgba(255,192,74,0.35); background: rgba(255,192,74,0.07); }
.oort-badge.tone-crit   { color: var(--status-crit);border-color: rgba(255,77,73,0.40);  background: rgba(255,77,73,0.08); }
.oort-badge.tone-info   { color: var(--status-info);border-color: rgba(63,183,242,0.35); background: rgba(63,183,242,0.07); }
.oort-badge.tone-sodium { color: var(--sodium-400); border-color: var(--sodium-600);  background: rgba(255,157,60,0.07); }

/* ---------- Tag (removable chip) ---------- */
.oort-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 6px 0 10px;
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: var(--border-thin) solid var(--border-hairline);
  border-radius: var(--radius-xs);
}
.oort-tag.no-remove { padding-right: 10px; }
.oort-tag__remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border: none; background: transparent;
  color: var(--text-faint); cursor: pointer; border-radius: var(--radius-xs);
}
.oort-tag__remove:hover { color: var(--status-crit); background: rgba(255,77,73,0.12); }

/* ---------- StatusDot ---------- */
.oort-statusdot { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.oort-statusdot__led { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--steel-300); }
.oort-statusdot.is-ok   .oort-statusdot__led { background: var(--status-ok);   box-shadow: 0 0 8px rgba(52,217,138,0.7); }
.oort-statusdot.is-warn .oort-statusdot__led { background: var(--status-warn); box-shadow: 0 0 8px rgba(255,192,74,0.7); }
.oort-statusdot.is-crit .oort-statusdot__led { background: var(--status-crit); box-shadow: 0 0 8px rgba(255,77,73,0.7); }
.oort-statusdot.is-idle .oort-statusdot__led { background: var(--steel-300); }
.oort-statusdot.pulse .oort-statusdot__led::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid currentColor; opacity: 0; color: inherit;
  animation: oort-ping 1.8s var(--ease-out) infinite;
}
.oort-statusdot.is-ok.pulse   .oort-statusdot__led::after { color: var(--status-ok); }
.oort-statusdot.is-warn.pulse .oort-statusdot__led::after { color: var(--status-warn); }
.oort-statusdot.is-crit.pulse .oort-statusdot__led::after { color: var(--status-crit); }
@keyframes oort-ping { 0% { transform: scale(0.6); opacity: 0.8; } 100% { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .oort-statusdot.pulse .oort-statusdot__led::after { animation: none; } }

/* ---------- Field / Input / Select ---------- */
.oort-field { display: flex; flex-direction: column; gap: 6px; }
.oort-label {
  font-family: var(--font-display); font-weight: var(--weight-semibold);
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wider);
  text-transform: uppercase; color: var(--text-muted);
}
.oort-input, .oort-select {
  height: 38px; width: 100%; padding: 0 var(--space-3);
  font-family: var(--font-body); font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-input);
  border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-xs);
  box-shadow: var(--etch-top);
  transition: var(--transition-color);
}
.oort-input.is-mono { font-family: var(--font-mono); }
.oort-input::placeholder { color: var(--text-faint); }
.oort-input:hover, .oort-select:hover { border-color: var(--steel-300); }
.oort-input:focus, .oort-select:focus { outline: none; border-color: var(--ion-500); box-shadow: var(--etch-top), 0 0 0 1px var(--ion-600), 0 0 14px var(--ion-glow); }
.oort-input:disabled, .oort-select:disabled { opacity: 0.5; cursor: not-allowed; }
.oort-input.has-error, .oort-select.has-error { border-color: var(--status-crit); }
.oort-select {
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--steel-200) 50%), linear-gradient(135deg, var(--steel-200) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: var(--space-8);
}
.oort-field__hint { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }
.oort-field__hint.is-error { color: var(--status-crit); }

/* ---------- Switch ---------- */
.oort-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.oort-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.oort-switch__track {
  position: relative; width: 40px; height: 22px;
  background: var(--surface-sunken); border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-pill); transition: var(--transition-color);
}
.oort-switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: var(--steel-200); border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease-servo), background var(--dur-fast);
}
.oort-switch input:checked + .oort-switch__track { background: var(--accent-quiet); border-color: var(--ion-500); }
.oort-switch input:checked + .oort-switch__track .oort-switch__thumb { transform: translateX(18px); background: var(--ion-300); box-shadow: 0 0 10px var(--ion-glow); }
.oort-switch input:focus-visible + .oort-switch__track { box-shadow: var(--ring-focus); }
.oort-switch__label { font-family: var(--font-body); font-size: var(--text-sm); color: var(--text-secondary); }
.oort-switch.is-disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Checkbox ---------- */
.oort-checkbox { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.oort-checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.oort-checkbox__box {
  position: relative; width: 18px; height: 18px;
  background: var(--surface-input); border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-xs); transition: var(--transition-color);
}
.oort-checkbox__box::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 9px;
  border: solid var(--text-on-ion); border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform var(--dur-fast) var(--ease-servo);
}
.oort-checkbox input:checked + .oort-checkbox__box { background: var(--ion-400); border-color: var(--ion-300); }
.oort-checkbox input:checked + .oort-checkbox__box::after { transform: rotate(45deg) scale(1); }
.oort-checkbox input:focus-visible + .oort-checkbox__box { box-shadow: var(--ring-focus); }
.oort-checkbox__label { font-family: var(--font-body); font-size: var(--text-sm); color: var(--text-secondary); }

/* ---------- Panel (HUD frame) ---------- */
.oort-panel {
  position: relative;
  background: var(--surface-panel);
  border: var(--border-thin) solid var(--border-hairline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md), var(--etch-panel);
}
.oort-panel.has-ticks::before,
.oort-panel.has-ticks::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none;
  border-color: var(--ion-500); border-style: solid; opacity: 0.8;
}
.oort-panel.has-ticks::before { top: -1px; left: -1px; border-width: 1.5px 0 0 1.5px; }
.oort-panel.has-ticks::after  { bottom: -1px; right: -1px; border-width: 0 1.5px 1.5px 0; }
.oort-panel__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-thin) solid var(--border-hairline);
}
.oort-panel__title {
  font-family: var(--font-display); font-weight: var(--weight-semibold);
  font-size: var(--text-xs); letter-spacing: var(--tracking-wider); text-transform: uppercase;
  color: var(--text-secondary);
}
.oort-panel__body { padding: var(--space-4); }

/* ---------- Stat (telemetry readout) ---------- */
.oort-stat { display: flex; flex-direction: column; gap: 4px; }
.oort-stat__label { font-family: var(--font-display); font-weight: var(--weight-semibold); font-size: var(--text-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--text-muted); }
.oort-stat__row { display: flex; align-items: baseline; gap: 6px; }
.oort-stat__value { font-family: var(--font-mono); font-weight: var(--weight-medium); font-size: var(--text-2xl); line-height: 1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.oort-stat__unit { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); }
.oort-stat__delta { font-family: var(--font-mono); font-size: var(--text-xs); display: inline-flex; align-items: center; gap: 3px; }
.oort-stat__delta.is-up   { color: var(--status-ok); }
.oort-stat__delta.is-down { color: var(--status-crit); }
.oort-stat.accent .oort-stat__value { color: var(--ion-300); }

/* ---------- Progress ---------- */
.oort-progress { display: flex; flex-direction: column; gap: 6px; }
.oort-progress__meta { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-muted); letter-spacing: var(--tracking-wide); }
.oort-progress__track { position: relative; height: 6px; background: var(--surface-sunken); border: var(--border-thin) solid var(--border-hairline); border-radius: var(--radius-pill); overflow: hidden; }
.oort-progress__bar { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--ion-600), var(--ion-400)); box-shadow: 0 0 10px var(--ion-glow); transition: width var(--dur-slow) var(--ease-servo); }
.oort-progress.tone-sodium .oort-progress__bar { background: linear-gradient(90deg, var(--sodium-600), var(--sodium-400)); box-shadow: 0 0 10px var(--sodium-glow); }
.oort-progress.tone-crit   .oort-progress__bar { background: linear-gradient(90deg, #7a1f1d, var(--status-crit)); box-shadow: 0 0 10px rgba(255,77,73,0.4); }
.oort-progress.is-segmented .oort-progress__track { background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--surface-sunken) calc(10% - 2px) 10%); border: none; height: 8px; }

/* ---------- SegmentedControl ---------- */
.oort-segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-sunken); border: var(--border-thin) solid var(--border-hairline); border-radius: var(--radius-sm); }
.oort-segmented__item {
  font-family: var(--font-display); font-weight: var(--weight-semibold);
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase;
  color: var(--text-muted); background: transparent; border: none; cursor: pointer;
  padding: 6px 14px; border-radius: var(--radius-xs); transition: var(--transition-color);
}
.oort-segmented__item:hover { color: var(--text-primary); }
.oort-segmented__item.is-active { color: var(--text-on-ion); background: var(--ion-400); box-shadow: var(--glow-soft-ion); }
