/* =====================================================================
   General Access · components.css        owner: design-components
   Resting looks + :hover / :active / :focus-visible / :disabled.
   No transitions, animations or @keyframes here: those live in motion.css.

   HOOKS ADDED FOR OTHER FILES
   ---------------------------------------------------------------------
   index.html   #start .btn-finder      mini viewfinder, shown only in
                                         data-state="starting" (motion may
                                         animate its corners / dot)
                .heard-icon-on / -off    mic / mic-off, swapped by
                                         body[data-listening="false"]
   app.js       #code[aria-invalid="true"]          wrong code (field look)
   (optional)   #gateStatus[data-tone="error"]      error note look
                #typeToggle[aria-expanded="true"]   toggle "on" look
   Local props  --hud-solid  --halo  (defined below, components only)
   ===================================================================== */

:root {
  /* A HUD surface opaque enough to read over a white wall WITHOUT blur
     (white text on it over pure white: about 9:1). */
  --hud-solid: rgba(14, 14, 16, .76);
  /* Soft outer band around every focus ring: makes the 2px ring read as ~4px. */
  --halo: 0 0 0 7px color-mix(in srgb, var(--accent) 24%, transparent);
  --mix-hover: #fff;      /* hover lightens in dark */
  --mix-press: #000;
}
@media (prefers-color-scheme: light) {
  :root { --mix-hover: #000; }   /* hover deepens in light */
}
#call { --mix-hover: #fff; --halo: 0 0 0 4px rgba(255, 179, 64, .2); }

/* ---------- Buttons ------------------------------------------------- */

.btn {
  outline: 2px solid transparent;       /* shows in forced-colors mode */
  outline-offset: 2px;
  letter-spacing: -0.005em;
}
.btn:focus-visible { outline-color: transparent; box-shadow: var(--focus), var(--halo); }
.btn .icon { pointer-events: none; }

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--mix-hover)); }
  .btn-stop:hover:not(:disabled)    { background: color-mix(in srgb, var(--stop) 90%, #fff); }
}
/* Pressed = a deeper fill. The scale(.97) press lives in motion.css. */
.btn-primary:active:not(:disabled) { background: color-mix(in srgb, var(--accent) 84%, var(--mix-press)); }
.btn-stop:active:not(:disabled)    { background: color-mix(in srgb, var(--stop) 80%, #000); }

/* Disabled: a calm neutral surface instead of a faded accent. */
.btn:disabled {
  opacity: 1;
  background: var(--surface);
  color: var(--text-3);
  border-color: var(--border-strong);
}
@media (prefers-color-scheme: light) {
  .panel .btn:disabled { background: var(--bg-2); }
}

.btn-xl { font-weight: 600; letter-spacing: -0.012em; }
.btn-stop .icon { width: 26px; height: 26px; }

/* Start while starting: not "greyed out", but "working". The button goes
   quiet and a small amber viewfinder appears, the same mark that will lock
   onto the TV a moment later. */
#start .btn-finder { display: none; }
body[data-state="starting"] #start {
  cursor: progress;
  background: var(--surface);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
body[data-state="starting"] #start .btn-finder {
  display: block;
  --finder-size: 22px;
  color: var(--accent);
}
#start .btn-finder .finder-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; }
@media (prefers-color-scheme: light) {
  body[data-state="starting"] #start { background: var(--bg-2); }
}

/* ---------- Access code field --------------------------------------- */

.field {
  border-color: rgba(255, 255, 255, .34);   /* >= 3:1 against bg and fill */
  caret-color: var(--accent);
}
.field::placeholder { color: var(--text-3); opacity: 1; }
@media (hover: hover) {
  .field:hover:not(:focus) { border-color: rgba(255, 255, 255, .5); }
}
.field:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--halo);
}
@media (prefers-color-scheme: light) {
  .panel .field { background: var(--bg-2); border-color: rgba(0, 0, 0, .45); }
  .panel .field:hover:not(:focus) { border-color: rgba(0, 0, 0, .62); }
}

.field-code {
  font-family: var(--font-mono);
  font-weight: 500;
  padding: 0 var(--s-5);
}

/* Wrong code: amber edge and a faint warm fill. Never red: red means Stop. */
#code[aria-invalid="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
@media (prefers-color-scheme: light) {
  .panel #code[aria-invalid="true"] { background: color-mix(in srgb, var(--accent) 6%, #fff); }
}

/* ---------- Form status (gate + ready) ------------------------------ */
/* Neutral by default ("Checking…"). A problem becomes a soft amber note
   with a circle-alert mark; plain words, normal text colour. */

.form-status { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text-2); }

#readyStatus:not(:empty),
#gateStatus[data-tone="error"]:not(:empty),
.gate-form:has(#code[aria-invalid="true"]) #gateStatus:not(:empty) {
  position: relative;
  padding: var(--s-3) var(--s-4) var(--s-3) calc(var(--s-4) + 20px + var(--s-3));
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
  text-wrap: pretty;
}
#readyStatus:not(:empty)::before,
#gateStatus[data-tone="error"]:not(:empty)::before,
.gate-form:has(#code[aria-invalid="true"]) #gateStatus:not(:empty)::before {
  content: "";
  position: absolute; left: var(--s-4); top: calc(var(--s-3) + (1.47em - 20px) / 2);
  width: 20px; height: 20px;
  background: var(--accent);
  /* Lucide circle-alert */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
}

.starting-hint { text-wrap: pretty; }

/* ---------- Over the camera: cheap, opaque-enough surfaces ---------- */
/* No backdrop blur on the call screen: the phone is busy with the camera
   and detection. The surfaces are dark enough to stand on their own. */

:where(#call) .glass {
  -webkit-backdrop-filter: none; backdrop-filter: none;
  background: var(--hud-solid);
  border-color: var(--hud-border);
  box-shadow: var(--glass-hl);
}

/* ---------- Status chip --------------------------------------------- */

.status-chip {
  margin-top: var(--s-1);                 /* centres a one-line chip on the 48px toggle */
  border-radius: var(--r-lg);             /* pill on one line, soft box on two */
  padding: var(--s-2) var(--s-4) var(--s-2) var(--s-3);
  color: var(--hud-text);
  text-wrap: balance;
}

/* view = none (or not set yet): a hollow ring, "nothing to hold on to". */
.status-dot {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  background: transparent;
}
.status-dot::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--hud-text-2);
}

/* view = full: a filled amber dot, "I see the whole picture". */
body[data-view="full"] .status-dot::before {
  box-shadow: none;
  background: var(--accent-media);
}

/* view = screen: the dot becomes the viewfinder, the same four corners that
   now frame the TV. (Signature: the brand mark, at chip size.) */
body[data-view="screen"] .status-dot::before {
  width: 16px; height: 16px; border-radius: 0;
  box-shadow: none;
  background: var(--accent-media);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M4 11V6a2 2 0 0 1 2-2h5M21 4h5a2 2 0 0 1 2 2v5M28 21v5a2 2 0 0 1-2 2h-5M11 28H6a2 2 0 0 1-2-2v-5'/%3E%3Ccircle cx='16' cy='16' r='4' fill='%23000' stroke='none'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M4 11V6a2 2 0 0 1 2-2h5M21 4h5a2 2 0 0 1 2 2v5M28 21v5a2 2 0 0 1-2 2h-5M11 28H6a2 2 0 0 1-2-2v-5'/%3E%3Ccircle cx='16' cy='16' r='4' fill='%23000' stroke='none'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* trouble: a gentle warning. Warm tint + amber edge + circle-alert.
   Wins over every view look. */
body[data-trouble="blurry"] .status-chip,
body[data-trouble="dark"] .status-chip,
body[data-trouble="no_screen"] .status-chip {
  background:
    linear-gradient(rgba(255, 179, 64, .16), rgba(255, 179, 64, .16)),
    rgba(14, 14, 16, .8);
  border-color: rgba(255, 179, 64, .55);
}
body[data-trouble="blurry"] .status-dot::before,
body[data-trouble="dark"] .status-dot::before,
body[data-trouble="no_screen"] .status-dot::before {
  width: 16px; height: 16px; border-radius: 0;
  box-shadow: none;
  background: var(--accent-media);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Type-a-message toggle ----------------------------------- */

#typeToggle {
  color: var(--hud-text);
  border: 1px solid var(--hud-border);
}
@media (hover: hover) {
  #typeToggle:hover { background: rgba(44, 44, 48, .86); }
}
#typeToggle:active { background: rgba(60, 60, 66, .9); }
#typeToggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, .94);
  border-color: transparent;
  color: #000;
}

/* ---------- Caption: the words Claude is saying ---------------------- */

/* The readability band. It sits behind the whole bottom group and grows with
   it, so a 200-character caption is as readable as a short one, over a white
   wall or a dark room. Plain gradient: no blur, no per-frame cost. */
.hud-bottom { position: relative; isolation: isolate; }
.hud-bottom:has(#caption:not(:empty), #heard:not(:empty))::before {
  content: "";
  position: absolute; z-index: -1;
  top: calc(-1 * var(--s-8)); bottom: -100vh;
  left: -100vw; right: -100vw;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .56) var(--s-7));
  pointer-events: none;
}

.caption-wrap { padding-left: calc(var(--s-4) + 2px); }
.caption-mark { width: 4px; border-radius: 2px; background: rgba(255, 255, 255, .5); }
body[data-speaking="true"] .caption-mark { background: var(--accent-media); }

/* Always full white: the bar carries speaking vs idle, the words stay
   at full strength for a reader who glances back. */
#caption {
  color: var(--hud-text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  hyphens: manual;
}

/* Thinking: three amber dots, resting shape only (motion animates them). */
.thinking-mark { gap: var(--s-2); height: 1.75rem; }
.thinking-mark i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-media);
  opacity: .9;
}
.caption-wrap:has(#caption:not(:empty)) .thinking-mark { margin-top: var(--s-1); }

/* ---------- Heard row ------------------------------------------------ */

.heard-row { color: var(--hud-text-2); text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.heard-icon { width: 18px; height: 18px; }
.heard-icon-off { display: none; }

/* Mic live: the icon warms up. */
body[data-listening="true"] .heard-icon-on { color: var(--accent-media); }
/* The person is talking right now: their words come forward. */
body[data-hearing="true"] .heard-row { color: var(--hud-text); }
body[data-hearing="true"] .heard-icon-on { color: var(--accent-media); }
/* Mic off: crossed-out mic, the last words step back (still >= 4.5:1). */
body[data-listening="false"] .heard-icon-on { display: none; }
body[data-listening="false"] .heard-icon-off { display: block; }
body[data-listening="false"] .heard-row { color: rgba(255, 255, 255, .7); }

/* ---------- Screen outline (#box) ----------------------------------- */

#box {
  --c-len: 28px; --c-w: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 179, 64, .38);
}
/* A dark hairline under each corner keeps amber visible on a white wall. */
.box-corner { filter: drop-shadow(0 0 1px rgba(0, 0, 0, .55)); }

/* ---------- Typed message row --------------------------------------- */

#typed {
  background: var(--hud-solid);
  border-color: var(--hud-border);
  color: var(--hud-text);
}
#typed::placeholder { color: var(--hud-text-2); }
@media (hover: hover) {
  #typed:hover:not(:focus) { border-color: rgba(255, 255, 255, .32); }
}
#typed:focus-visible { border-color: var(--accent-media); box-shadow: 0 0 0 1px var(--accent-media), var(--halo); }

.type-send .icon { stroke-width: 2.25; }
/* Nothing typed yet: Send waits quietly; it turns amber with the first letter. */
.type-form:has(#typed:placeholder-shown) .type-send {
  background: var(--hud-solid);
  border-color: var(--hud-border);
  color: var(--hud-text-2);
}

/* ---------- Ended: the finder at rest -------------------------------- */

.finder.is-resting .finder-dot {
  background: transparent;
  box-shadow: inset 0 0 0 2px currentColor;   /* the lamp is off */
}

/* ---------- Debug panel --------------------------------------------- */
/* Top-left under the chip, short, never reaches the caption or Stop. */

body[data-debug="true"] #debug {
  max-height: min(30dvh, 15rem);
  max-width: min(calc(100vw - 2 * var(--s-5)), 26rem);
  background: rgba(0, 0, 0, .78);
  border: 1px solid rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .88);
  line-height: 1.4;
  tab-size: 2;
}
@media (orientation: landscape) and (max-height: 520px) {
  body[data-debug="true"] #debug { max-height: 34dvh; max-width: 22rem; }
}

/* ---------- Forced colours (Windows high contrast) ------------------- */

@media (forced-colors: active) {
  .btn:focus-visible, .field:focus-visible { outline-color: Highlight; }
  .status-dot::before, .form-status::before, .finder-dot { forced-color-adjust: none; }
}

/* Starting: the hint replaces the lead, which still says "Tap Start". */
body[data-state="starting"] #ready .lead { display: none; }

/* Language switch: two words in the header, the chosen one filled.
   Shown on the gate, ready and ended screens, never during a call. */
.lang-switch {
  margin-left: auto;
  display: inline-flex; gap: 2px; padding: 3px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}
.lang-btn {
  min-height: 42px; padding: 0 16px;
  border: 0; border-radius: 999px; background: transparent;
  font: inherit; font-size: var(--fs-small); font-weight: 500; color: var(--text-2);
  cursor: pointer;
}
.lang-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.lang-btn:focus-visible { outline: none; box-shadow: var(--focus), var(--halo); }
body[data-state="starting"] .lang-switch { visibility: hidden; }
/* The brand name stays on one line next to the language switch. */
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lang-switch { flex: none; }
.lang-btn { padding: 0 12px; }
