/* ============================================================
   Test surface styling — scoped to #test-host.
   The cardinal rule: the surface itself carries ZERO chrome. Every
   overlay is a sibling that fades to fully transparent when idle, so a
   dead-pixel or uniformity test is never contaminated by a stray pixel.
   ============================================================ */

/* Kill scrollbars while a test is engaged so nothing bleeds onto the edge. */
html.testing,
html.testing body {
  overflow: hidden;
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

#test-host {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  background: #000;
  z-index: 2147483000; /* above everything, incl. the menu */
  /* Doubles as the iOS pseudo-fullscreen surface when the real Fullscreen
     API is unavailable: it already covers the entire viewport. */
}

#test-host[hidden] {
  display: none;
}

/* The pristine surface: fills the host, no margin/padding/border/outline. */
.test-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: #000;
  /* `touch-action: none` lets the router own swipe/tap without the browser
     hijacking gestures for scroll/zoom. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Hide the cursor when idle. */
#test-host.idle {
  cursor: none;
}

/* ---- Shared transient label (color name, level, etc.) ----
   Lives inside the surface but fades to fully transparent, leaving it pristine.
   pointer-events:none so it never intercepts a tap. */
.test-label {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(18, 18, 20, 0.6);
  color: #fff;
  font: 600 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 5;
}
.test-label.show {
  opacity: 1;
}

/* ---- Informational note (viewing tips, caveats) ----
   Top-center, fades out with idle like the control hint so it never
   contaminates a uniformity/gradient field. */
.test-note {
  position: absolute;
  left: 50%;
  top: max(20px, env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: min(92vw, 640px);
  padding: 9px 16px;
  border-radius: 12px;
  background: rgba(18, 18, 20, 0.62);
  color: rgba(255, 255, 255, 0.92);
  font: 500 13.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  text-align: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
  z-index: 6;
}
#test-host.idle .test-note {
  opacity: 0;
}

/* ---- Readout panel for informational tests (refresh, HDR) ----
   This content IS the test, so it does NOT fade with idle. */
.test-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #eef1f6;
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}
.test-readout {
  font-size: clamp(2.5rem, 9vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.test-readout small {
  font-size: 0.32em;
  font-weight: 600;
  color: #aab2c2;
  letter-spacing: 0.02em;
}
.test-sub {
  color: #aab2c2;
  font-size: 0.95rem;
  max-width: 52ch;
}
.test-caveat {
  color: #7b8494;
  font-size: 0.82rem;
  max-width: 56ch;
}

/* ---- Control hint (auto-hiding controls reminder, bottom center) ---- */
.control-hint {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 92vw;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.72);
  color: rgba(255, 255, 255, 0.92);
  font: 500 13px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none; /* never steals a tap from the surface */
  opacity: 1;
  transition: opacity 0.4s ease;
  z-index: 10;
}

/* ---- Exit button (touch affordance; desktop uses Esc) ---- */
.exit-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: none; /* shown only on touch devices */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(10, 12, 18, 0.72);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.4s ease;
  z-index: 10;
}
.exit-btn svg {
  width: 22px;
  height: 22px;
}
#test-host.is-touch .exit-btn {
  display: flex;
}

/* ============================================================
   Per-test layout (content, not chrome — does not fade).
   ============================================================ */

/* contrast.js — a row of equal-width step patches */
.contrast-stage {
  position: absolute;
  inset: 0;
  display: flex;
}
.contrast-patch {
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8%;
}
.contrast-tick {
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  color: var(--tick, #888);
}

/* color.js — wide-gamut swatch grid */
.gamut-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
  background: #000;
  padding: 6vmin;
  box-sizing: border-box;
}
.gamut-cell {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.gamut-cell span {
  font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  color: #fff;
  mix-blend-mode: difference;
}

/* sharpness.js — text sample sheet */
.sharp-text {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  color: #000;
  padding: 6vmin;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}
.sharp-text.invert {
  background: #000;
  color: #fff;
}
.sharp-text p {
  margin: 0 0 0.6em;
}

/* refresh.js — live frame-time graph sits below the readout */
.refresh-graph {
  width: min(90vw, 640px);
  height: 120px;
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  background: #0b0d12;
}

/* stuck.js — the movable flashing square */
.stuck-square {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%);
  touch-action: none;
  cursor: grab;
  will-change: background-color;
}
.stuck-square:active {
  cursor: grabbing;
}

/* Idle and explicit-hide states fade overlays to fully transparent. */
#test-host.idle .control-hint,
#test-host.idle .exit-btn,
#test-host.hint-off .control-hint {
  opacity: 0;
  pointer-events: none;
}

/* Respect reduced-motion: drop the fades (instant show/hide). */
@media (prefers-reduced-motion: reduce) {
  .control-hint,
  .exit-btn,
  .test-label {
    transition: none;
  }
}
