/* ==========================================================================
   Spellworks · TV · every view, the knobs and the controls
   The TV screen and the photos keep their own colours (they are pictures of
   light, not UI); everything around them uses the shared tokens.
   ========================================================================== */

.sw-tv {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
  background: #0b0a0e;
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}
.sw-tv--auto { aspect-ratio: 4 / 3; width: 100%; }
.sw-tv canvas { max-width: none; }

.tvv, .tvv__stage { position: absolute; inset: 0; }
.tvv__photo {
  position: absolute;
  max-width: none;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.tvv__glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tvv__quad {
  position: absolute;
  left: 0;
  top: 0;
  width: 640px;
  height: 480px;
  transform-origin: 0 0;
  backface-visibility: hidden;
  background: #050806;
}
.tvv__quad > canvas,
.tvv__screenbox > canvas,
.tvv__rawframe > canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.tv-screen--raw { image-rendering: pixelated; image-rendering: crisp-edges; }
.tvv__ambient {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0.3;
  pointer-events: none;
}
.tvv__sheen {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}

/* ---------- face: the concept photo of the Familiar ---------- */
.tvv--face { background: #5d5952; }
.tvv--face .tvv__ambient { opacity: 0.34; }

/* ---------- bench: the walnut portable ---------- */
.tvv--bench { background: #3b3936; }
.tvv--bench .tvv__ambient { opacity: 0.16; }
.tvv__knobs, .tvv__print { position: absolute; inset: 0; pointer-events: none; }
.tvv__knobs > * { pointer-events: auto; }
.tvv__plabel {
  position: absolute;
  transform: translate(-50%, 0);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 125;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(28, 27, 26, 0.74);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}
.tvv__dialprint { position: absolute; width: 0; height: 0; }
.tvv__dialprint span {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--f-body);
  font-variation-settings: "wdth" 110;
  font-weight: 700;
  line-height: 1;
  color: rgba(28, 27, 26, 0.7);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: rotate(var(--a)) translateY(calc(-1 * var(--r, 40px))) rotate(calc(-1 * var(--a))) translate(-50%, -50%);
}

.knob {
  position: absolute;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  outline: none;
}
.knob.is-turning { cursor: grabbing; }
.knob:focus-visible { box-shadow: 0 0 0 2px #0b0a0e, 0 0 0 4px #8fe27a; }
.knob__cap, .knob__rot, .knob__shine { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.knob__cap {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 62%, rgba(0, 0, 0, 0.28) 74%, rgba(0, 0, 0, 0.62) 100%),
    conic-gradient(from 12deg, #cfd3d7, #8b9095 9%, #eceff1 21%, #9da2a7 33%, #dfe2e5 46%, #868b90 58%, #f2f4f5 71%, #979ca1 84%, #cfd3d7);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.55), 0 1px 1px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.5);
}
.knob--small .knob__cap {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 46%, rgba(0, 0, 0, 0.2) 52%, transparent 56%),
    repeating-conic-gradient(rgba(0, 0, 0, 0.2) 0 4deg, rgba(255, 255, 255, 0.12) 4deg 8deg) center / 100% 100%,
    conic-gradient(from 20deg, #d5d8dc, #8e9398, #eff1f3, #9a9fa4, #dcdfe2, #898e93, #f3f5f6, #949a9f, #d5d8dc);
}
.knob--small .knob__cap::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: conic-gradient(from 40deg, #e6e9eb, #a1a6ab, #f6f7f8, #a7acb1, #e6e9eb);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.knob__shine {
  background: radial-gradient(ellipse 60% 40% at 34% 24%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 70%);
  mix-blend-mode: screen;
}
.knob__fin {
  position: absolute;
  left: 50%;
  top: 3%;
  width: 21%;
  height: 94%;
  transform: translateX(-50%);
  border-radius: 3px;
  background: linear-gradient(90deg, #5e6267 0%, #c7cace 18%, #f5f7f8 42%, #d4d7da 62%, #8a8e93 86%, #5b5f64 100%);
  box-shadow: 2px 3px 4px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}
.knob__tip {
  position: absolute;
  left: 50%;
  top: 8%;
  width: 7%;
  height: 7%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #1d1d1c;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.knob__ptr {
  position: absolute;
  left: 50%;
  top: 7%;
  width: 9%;
  height: 30%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #222;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 1px 1px rgba(0, 0, 0, 0.6);
}
.knob--small .knob__ptr { top: 5%; width: 12%; height: 26%; z-index: 1; }
.knob__rot { transition: transform 0.12s cubic-bezier(0.2, 0.7, 0.2, 1); }
.knob.is-turning .knob__rot { transition: none; }

.tv-readout {
  position: absolute;
  z-index: 3;
  transform: translate(-100%, -50%);
  padding: 0.34em 0.85em 0.32em;
  border-radius: 999px;
  background: #121016;
  color: #f4efe4;
  box-shadow: 0 0 0 1px rgba(244, 239, 228, 0.16);
  font-family: var(--f-mono);
  font-size: 0.66rem;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.tv-readout.is-on { opacity: 1; }

/* ---------- raw: the bare signal ---------- */
.tvv--raw {
  display: grid;
  place-items: center;
  background: var(--bg-inset);
}
.tvv__rawfig { margin: 0; }
.tvv__rawframe {
  position: relative;
  background: #050806;
  box-shadow: 0 0 0 1px var(--hair-2);
}
.tvv__safe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.tvv__safe.is-on { opacity: 1; }
.tvv__safe rect { fill: none; stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.tvv__safe .s-action { stroke: rgba(255, 255, 255, 0.72); }
.tvv__safe .s-title { stroke: rgba(255, 255, 255, 0.5); stroke-dasharray: 6 4; }
.tvv__safe .s-face { stroke: rgba(255, 255, 255, 0.85); fill: rgba(255, 255, 255, 0.05); stroke-dasharray: 2 4; }
.tvv__safe text {
  fill: rgba(255, 255, 255, 0.82);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 120;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tvv__rawcap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.65rem;
}
.tvv__rawlabel { font-size: 0.72rem; color: var(--fg-2); letter-spacing: 0.02em; }

/* ---------- screen: the kiosk ---------- */
.tvv--screen { display: grid; place-items: center; background: #000; }
.tvv__screenbox { position: relative; background: #000; }

/* ---------- the switchers (createTVControls) ---------- */
.tv-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.6rem;
}
.tv-controls__group { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.tv-controls__group .t-label { min-width: 3.6rem; }
.tv-controls__group.is-off .seg { opacity: 0.45; }
.tv-controls__group.is-off .seg > button { cursor: not-allowed; }
.tv-controls__note { flex-basis: 100%; margin: 0; color: var(--fg-3); }
.tv-controls--compact .t-label { display: none; }
@media (max-width: 560px) {
  .tv-controls { gap: 0.6rem; }
  .tv-controls .seg > button { padding-left: 0.7em; padding-right: 0.7em; }
}

@media (prefers-reduced-motion: reduce) {
  .knob__rot, .tv-readout, .tvv__safe { transition: none; }
}
html[data-reduce-motion] .knob__rot, html[data-reduce-motion] .tv-readout { transition: none; }
