/* ==========================================================================
   On-screen tool chrome — the shell VT.ui.build() emits.
   Built entirely on M3 tokens; no hard-coded colours.
   ========================================================================== */

.vt-tool { display: block; }

/* ------------------------------------------------------------------ stage */
.vt-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--vt-aspect, 16 / 9);
  min-block-size: 300px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  isolation: isolate;
  touch-action: manipulation;
}
.vt-stage canvas { display: block; width: 100%; height: 100%; }

.vt-stage:fullscreen,
.vt-stage:-webkit-full-screen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  min-block-size: 0;
  border: 0;
  border-radius: 0;
  background: var(--md-sys-color-surface);
}

/* High-contrast presentation modes tools can opt into */
.vt-stage--ink   { background: #ffffff; color: #000000; }
.vt-stage--night { background: #000000; color: #ffffff; }
.vt-stage--plain { background: var(--md-sys-color-surface); }

.vt-hint {
  position: absolute;
  inset-inline: 0;
  bottom: 16px;
  margin: 0 auto;
  max-width: 46ch;
  padding: 0 20px;
  text-align: center;
  font: var(--md-type-body-medium, 400 14px/20px Roboto, sans-serif);
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
  z-index: 3;
}
.vt-hint--center {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

/* Centred single cue — used by metronomes, timers, tachistoscopes */
.vt-cue {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}
.vt-cue__main {
  font-family: Roboto, system-ui, sans-serif;
  font-size: clamp(2.5rem, 1.2rem + 8vw, 6rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
}
.vt-cue__main--mono { font-family: 'Roboto Mono', ui-monospace, monospace; letter-spacing: .1em; }
.vt-cue__main--a { color: var(--md-sys-color-primary); }
.vt-cue__main--b { color: var(--md-sys-color-tertiary); }
.vt-cue__sub {
  margin-top: 14px;
  max-width: 46ch;
  font: var(--md-type-body-medium, 400 14px/20px Roboto, sans-serif);
  color: var(--md-sys-color-on-surface-variant);
}

/* Fixation cross for peripheral / VOR work */
.vt-fix {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  font-weight: 300;
  line-height: 1;
  color: var(--md-sys-color-on-surface-variant);
  z-index: 2;
}

/* -------------------------------------------------------------- bar / actions */
.vt-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-block-start: 20px;
}
.vt-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vt-readouts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-inline-start: auto; }

.vt-readout {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  font-variant-numeric: tabular-nums;
}
.vt-readout__label {
  font: var(--md-type-label-medium, 500 12px/16px Roboto, sans-serif);
  color: var(--md-sys-color-on-surface-variant);
}
.vt-readout__value {
  font: var(--md-type-label-large, 500 14px/20px Roboto, sans-serif);
  font-variant-numeric: tabular-nums;
}
.vt-readout--wide .vt-readout__value { font-family: 'Roboto Mono', ui-monospace, monospace; }

.vt-tool__note {
  margin: 16px 0 0;
  max-width: 72ch;
  color: var(--md-sys-color-on-surface-variant);
}

/* ---------------------------------------------------------------- controls */
.vt-controls {
  display: grid;
  gap: 18px 24px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-block-start: 24px;
  padding-block-start: 24px;
  border-block-start: 1px solid var(--md-sys-color-outline-variant);
}
.vt-advanced + .vt-controls,
.vt-controls + .vt-advanced .vt-controls {
  border-block-start: 0;
  padding-block-start: 0;
}

.vt-ctl { min-width: 0; }
.vt-ctl.is-disabled { opacity: .38; pointer-events: none; }
.vt-ctl--select { display: flex; flex-direction: column; gap: 6px; }
.vt-ctl--seg { display: flex; flex-direction: column; gap: 8px; grid-column: 1 / -1; }
.vt-ctl--seg .md-segmented-button { max-width: 100%; }

.vt-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 0 44px 0 16px;
  font: var(--md-type-body-large, 400 16px/24px Roboto, sans-serif);
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-highest);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 22px) calc(50% + 2px), calc(100% - 16px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  border: 0;
  border-block-end: 1px solid var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
  cursor: pointer;
}
.vt-select:hover { background-color: var(--md-sys-color-surface-container-high); }
.vt-select:focus-visible {
  outline: 3px solid var(--md-sys-color-secondary);
  outline-offset: 2px;
}

/* Advanced settings disclosure */
.vt-advanced {
  margin-block-start: 24px;
  padding-block-start: 20px;
  border-block-start: 1px solid var(--md-sys-color-outline-variant);
}
.vt-advanced > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.vt-advanced > summary::-webkit-details-marker { display: none; }
.vt-advanced > summary:hover { background: var(--md-sys-color-surface-container-highest); }
.vt-advanced > summary:focus-visible {
  outline: 3px solid var(--md-sys-color-secondary);
  outline-offset: 2px;
}
.vt-advanced__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font: var(--md-type-label-medium, 500 12px/16px Roboto, sans-serif);
}
.vt-advanced[open] > summary {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.vt-advanced .vt-controls { margin-block-start: 20px; }

/* ------------------------------------------------------------- calibration */
.vt-calib { padding: clamp(20px, 3vw, 28px); }
.vt-calib__card {
  position: relative;
  border: 2px solid var(--md-sys-color-primary);
  border-radius: 10px;
  background: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
  max-width: 100%;
  display: grid;
  place-items: center;
}
.vt-calib__card span {
  font: var(--md-type-label-large, 500 14px/20px Roboto, sans-serif);
  color: var(--md-sys-color-primary);
}

/* -------------------------------------------------------------- score chips */
.vt-answers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-block-start: 16px;
}
.vt-answers:empty { display: none; }

/* Target rendered as a DOM node (saccade/anaglyph style tools) */
.vt-target {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  font-family: Roboto, system-ui, sans-serif;
  font-weight: 500;
  line-height: 1;
  color: var(--md-sys-color-primary);
  user-select: none;
  z-index: 2;
}
.vt-target--dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
}
.vt-target--btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  border-radius: 50%;
}

/* Two-device / equipment callout inside a tool */
.vt-device-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-block-end: 20px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font: var(--md-type-body-medium, 400 14px/20px Roboto, sans-serif);
}
.vt-device-note .md-icon { flex: none; margin-top: 1px; }

.vt-muted { color: var(--md-sys-color-on-surface-variant); }

@media (max-width: 599px) {
  .vt-stage { min-block-size: 240px; }
  .vt-readouts { margin-inline-start: 0; width: 100%; }
  .vt-controls { grid-template-columns: 1fr; }
}

@media print {
  .vt-stage, .vt-bar, .vt-controls, .vt-advanced, .vt-tool__note { display: none !important; }
}
