/* ARC Autopilot operator controls + delegation view (substrate W2).
 * Idiom: the site's dark glass (arc-guided.js .gd-* / noetica-guide.css) —
 * deep navy glass, Geist, accent var(--acc) with #8fb4ff fallback. Class
 * prefix ai- (arc-interaction) avoids collisions with gd-/ng-/wd- surfaces.
 * Targets are >= 44px; layout holds 320-430px portrait and landscape phones
 * (landscape mini form collapses secondary controls behind "More"). */

.ai-root {
  --ai-acc: var(--acc, #8fb4ff);
  --ai-ink: #eef1fa;
  --ai-dim: #9aa3d6;
  --ai-line: rgba(255, 255, 255, .16);
  --ai-glass: linear-gradient(160deg, rgba(16, 26, 48, .94), rgba(8, 12, 24, .96));
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--ai-bottom, 16px) + env(safe-area-inset-bottom));
  z-index: 8800;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(430px, calc(100vw - 16px));
  font-family: Geist, system-ui, sans-serif;
  color: var(--ai-ink);
  box-sizing: border-box;
}
.ai-root *, .ai-sheet-wrap * { box-sizing: border-box; }

.ai-cluster {
  background: var(--ai-glass);
  border: 1px solid color-mix(in srgb, var(--ai-acc) 38%, transparent);
  border-radius: 22px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}
.ai-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-row.ai-primary { flex-wrap: nowrap; }
.ai-status {
  font: 600 .72rem/1.35 "Geist Mono", ui-monospace, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ai-acc);
  min-width: 0;
  overflow-wrap: anywhere;
}
.ai-note { font: 400 .8rem/1.45 Geist, sans-serif; color: #cfd5f2; margin: 0; }
.ai-note[hidden] { display: none; }

.ai-seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
}
.ai-seg button {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #cfd5f2;
  font: 600 .8rem Geist, sans-serif;
  cursor: pointer;
}
.ai-seg button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--ai-acc) 26%, transparent);
  color: #fff;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ai-acc) 60%, transparent);
}

.ai-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--ai-line);
  background: rgba(255, 255, 255, .05);
  color: #e8ecf8;
  font: 600 .82rem Geist, sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ai-btn:hover { border-color: color-mix(in srgb, var(--ai-acc) 55%, transparent); }
.ai-btn:active { transform: scale(.97); }
.ai-btn[aria-pressed="true"] {
  border-color: var(--ai-acc);
  background: color-mix(in srgb, var(--ai-acc) 20%, transparent);
  color: #fff;
}
.ai-btn.ai-pri {
  border: 0;
  background: linear-gradient(135deg, var(--ai-acc), color-mix(in srgb, var(--ai-acc) 50%, #fff));
  color: #0b0d14;
  font-weight: 700;
}
.ai-btn.ai-takeover {
  border-color: color-mix(in srgb, var(--ai-acc) 70%, transparent);
  background: color-mix(in srgb, var(--ai-acc) 16%, transparent);
  color: #fff;
  font-weight: 700;
}
.ai-btn.ai-takeover.ai-prominent {
  background: linear-gradient(135deg, var(--ai-acc), color-mix(in srgb, var(--ai-acc) 50%, #fff));
  color: #0b0d14;
  border: 0;
}
.ai-btn:disabled, .ai-btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
}
.ai-btn[hidden], .ai-seg[hidden] { display: none; }

.ai-vol { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.ai-vol label { font: 600 .74rem Geist, sans-serif; color: var(--ai-dim); }
.ai-vol input[type="range"] {
  width: 96px;
  height: 44px;
  accent-color: var(--ai-acc);
  cursor: pointer;
}
.ai-vol output { font: 600 .72rem "Geist Mono", monospace; color: #cfd5f2; min-width: 3ch; }

.ai-chapters { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.ai-chapters select {
  min-height: 44px;
  max-width: 170px;
  border-radius: 999px;
  border: 1px solid var(--ai-line);
  background: rgba(255, 255, 255, .05);
  color: #e8ecf8;
  font: 600 .8rem Geist, sans-serif;
  padding: 0 10px;
}
.ai-chapters select:disabled { opacity: .45; }

/* Subtitle band: the single narration text surface when subtitles are
 * on. Bottom-anchored and centered over the dock area, at most two
 * lines, high contrast on a scrim, safe-area aware. In immersive mode
 * the dock is gone and the band sits at the screen bottom; otherwise it
 * floats just above the dock reserve. The band never rises into the
 * centerpiece focal area. */
.ai-subtitle {
  --ai-acc: var(--acc, #8fb4ff);
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--ai-subtitle-bottom, 12px) + env(safe-area-inset-bottom));
  z-index: 8790;
  width: min(640px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  background: rgba(4, 8, 16, .9);
  border: 1px solid color-mix(in srgb, var(--ai-acc) 30%, transparent);
  border-radius: 14px;
  padding: 10px 18px;
  font: 500 calc(1.02rem * var(--ai-text-scale, 1))/1.45 Geist, system-ui, sans-serif;
  color: #ffffff;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
  box-sizing: border-box;
  pointer-events: none;
}
.ai-subtitle[hidden] { display: none; }
.ai-subtitle-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.ai-subtitle-note {
  display: block;
  margin-top: 4px;
  font: 600 .72rem/1.4 "Geist Mono", ui-monospace, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #ffd9a8;
}
.ai-subtitle-note[hidden] { display: none; }
body.arc-immersive .ai-subtitle {
  bottom: calc(12px + env(safe-area-inset-bottom));
}

/* Narration panel: carries the line only when subtitles are off. */
.ai-narration-panel {
  position: relative;
  background: var(--ai-glass);
  border: 1px solid color-mix(in srgb, var(--ai-acc) 38%, transparent);
  border-radius: 18px;
  padding: 12px 48px 12px 14px;
  max-width: 100%;
  max-height: 24dvh;
  overflow-y: auto;
  font: 500 calc(.95rem * var(--ai-text-scale, 1))/1.5 Geist, sans-serif;
  color: #f4f6ff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.ai-narration-panel[hidden] { display: none; }
.ai-panel-close { position: absolute; top: 2px; right: 2px; }

/* Presence pill: the one affordance left while chrome is hidden.
 * 44px target, low contrast until hover or focus. */
.ai-presence {
  --ai-acc: var(--acc, #8fb4ff);
  position: fixed;
  top: calc(var(--arc-pub-header-h, 0px) + env(safe-area-inset-top) + 10px);
  right: max(12px, env(safe-area-inset-right));
  z-index: 8810;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ai-acc) 40%, transparent);
  background: rgba(8, 12, 24, .72);
  color: #cfd5f2;
  font: 600 .74rem Geist, system-ui, sans-serif;
  cursor: pointer;
  opacity: .62;
  box-sizing: border-box;
}
.ai-presence[hidden] { display: none; }
.ai-presence:hover, .ai-presence:focus-visible { opacity: 1; color: #fff; }
.ai-presence:focus-visible { outline: 2px solid var(--ai-acc); outline-offset: 2px; }

/* Note dismiss + chip close */
.ai-note-wrap { display: flex; align-items: flex-start; gap: 4px; }
.ai-note-wrap[hidden] { display: none; }
.ai-note-wrap .ai-note { flex: 1; min-width: 0; }
.ai-note-close { flex: none; }
.ai-chip { position: relative; }
.ai-chip-close { position: absolute; top: 2px; right: 2px; }

/* Immersive chrome hiding. Transitions are removed under reduced
 * motion by the .ai-rm / media-query guards at the end of this file. */
.ai-cluster, .ai-chip, .ai-consent, .ai-narration-panel {
  transition: opacity .4s ease, transform .4s ease, visibility .4s;
}
.ai-root.ai-chrome-hidden .ai-cluster,
.ai-root.ai-chrome-hidden .ai-chip,
.ai-root.ai-chrome-hidden .ai-consent,
.ai-root.ai-chrome-hidden .ai-narration-panel {
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  visibility: hidden;
}
body.arc-immersive .arc-pub-dock,
body.arc-immersive #nchat .nc-dock,
body.arc-immersive .arc-autopilot-bar {
  transform: translateY(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.arc-pub-dock, #nchat .nc-dock, .arc-autopilot-bar {
  transition: transform .45s ease, opacity .45s ease, visibility .45s;
}

/* Narration channel: while the substrate channel renders the line,
 * the journey card's own narration text never duplicates it. The card
 * remains for choices and continue controls; with neither visible it
 * leaves the screen entirely. */
body.arc-narration-channel .ap-narration,
body.arc-narration-channel .ap-caption-line { display: none; }
body.arc-narration-channel .ap-caption-card:not(:has(.ap-choices:not([hidden]), .ap-continue-row:not([hidden]))) {
  display: none;
}

.ai-chip, .ai-consent {
  background: var(--ai-glass);
  border: 1px solid color-mix(in srgb, var(--ai-acc) 55%, transparent);
  border-radius: 18px;
  padding: 12px 14px;
  max-width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
}
.ai-chip[hidden], .ai-consent[hidden] { display: none; }
.ai-chip p, .ai-consent p { margin: 0 0 10px; font: 500 .88rem/1.5 Geist, sans-serif; }
.ai-chip .ai-row, .ai-consent .ai-row { justify-content: flex-end; }

.ai-sheet-wrap {
  --ai-acc: var(--acc, #8fb4ff);
  position: fixed;
  inset: 0;
  z-index: 8940;
  background: rgba(3, 6, 12, .66);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: Geist, system-ui, sans-serif;
  color: #eef1fa;
}
.ai-sheet-wrap[hidden] { display: none; }
.ai-sheet {
  width: 100%;
  max-width: 620px;
  max-height: min(88dvh, 720px);
  overflow-y: auto;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(160deg, #101a30, #080c18);
  border: 1px solid color-mix(in srgb, var(--ai-acc) 40%, transparent);
  border-bottom: 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 60px rgba(0, 0, 0, .6);
}
.ai-grab { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); margin: 6px auto 10px; }
.ai-sheet h2 {
  margin: 4px 0 2px;
  font: 400 1.5rem/1.15 "Instrument Serif", Georgia, serif;
  color: #fff;
}
.ai-sheet .ai-mode-words { margin: 0 0 6px; font: 600 1rem/1.4 Geist, sans-serif; color: var(--ai-acc); }
.ai-sheet .ai-sub { margin: 0 0 12px; color: #9aa3d6; font: 400 .86rem/1.5 Geist, sans-serif; }
.ai-sheet h3 {
  margin: 16px 0 6px;
  color: var(--ai-acc);
  font: 600 .64rem "Geist Mono", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.ai-scope-list { list-style: none; margin: 0; padding: 0; }
.ai-scope-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  margin: 0 0 6px;
}
.ai-scope-list .ai-scope-name { flex: 1; min-width: 0; font: 600 .9rem/1.3 Geist, sans-serif; }
.ai-scope-list .ai-scope-state {
  font: 600 .68rem "Geist Mono", monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #cfd5f2;
}
.ai-scope-list li[data-delegated="true"] .ai-scope-state { color: var(--ai-acc); }
.ai-scope-list li[data-admitted="false"] .ai-scope-state { color: #ffb4c8; }
.ai-sheet .ai-retain {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--ai-acc) 45%, transparent);
  background: color-mix(in srgb, var(--ai-acc) 9%, transparent);
  font: 600 .9rem/1.5 Geist, sans-serif;
}
.ai-sheet .ai-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.ai-sheet .ai-close-row { display: flex; justify-content: flex-end; }
.ai-x {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: none;
  color: #9aa3d6;
  font: 700 16px system-ui, sans-serif;
  cursor: pointer;
}

.ai-root :focus-visible, .ai-sheet-wrap :focus-visible {
  outline: 2px solid var(--ai-acc);
  outline-offset: 2px;
}
.ai-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.ai-more { display: none; }

/* Phones (any orientation): mini form. Secondary controls sit behind "More", so the panel is a single row, not half the screen. */
@media (min-width: 0px) {
  .ai-root { max-width: min(520px, calc(100vw - 16px)); }
  .ai-more { display: inline-flex; }
  .ai-secondary { display: none; }
  .ai-root.ai-expanded .ai-secondary { display: flex; }
  .ai-cluster { padding: 8px; border-radius: 18px; }
  .ai-subtitle { width: min(560px, calc(100vw - 16px)); }
  .ai-sheet { max-height: 92dvh; }
}

/* Narrow portrait: let the primary row wrap rather than overflow.
 * The Hide control joined the primary row in the immersive revision,
 * so the wrap breakpoint covers the full phone range. */
@media (max-width: 430px) {
  .ai-row.ai-primary { flex-wrap: wrap; }
  .ai-seg button { padding: 0 9px; }
  .ai-chapters select { max-width: 140px; }
}

/* Daylight atmosphere keeps the glass readable on light pages. */
html[data-atmosphere="daylight"] .ai-cluster,
html[data-atmosphere="daylight"] .ai-chip,
html[data-atmosphere="daylight"] .ai-consent {
  background: linear-gradient(160deg, rgba(255, 252, 244, .96), rgba(244, 238, 226, .97));
  color: #241f16;
  border-color: rgba(60, 48, 30, .3);
}
html[data-atmosphere="daylight"] .ai-btn,
html[data-atmosphere="daylight"] .ai-seg button { color: #3f382f; border-color: rgba(60, 48, 30, .25); }
html[data-atmosphere="daylight"] .ai-status { color: #7a4b00; }
html[data-atmosphere="daylight"] .ai-note,
html[data-atmosphere="daylight"] .ai-chip p,
html[data-atmosphere="daylight"] .ai-consent p { color: #3f382f; }

/* Reduced motion: OS preference or WonderModes motion=reduced (.ai-rm). */
@media (prefers-reduced-motion: reduce) {
  .ai-btn:active { transform: none; }
  .ai-root *, .ai-sheet-wrap *, .ai-subtitle, .ai-presence { animation: none !important; transition: none !important; }
  body.arc-immersive .arc-pub-dock, body.arc-immersive #nchat .nc-dock,
  body.arc-immersive .arc-autopilot-bar, .arc-pub-dock, #nchat .nc-dock,
  .arc-autopilot-bar { transition: none !important; }
}
.ai-rm .ai-btn:active { transform: none; }
.ai-rm *, .ai-sheet-wrap.ai-rm * { animation: none !important; transition: none !important; }
body.arc-immersive .ai-root.ai-rm .ai-cluster { transition: none !important; }

/* Phones: the panel stays small and never crowds the page. */
@media (max-width: 640px) {
  .ai-root { right: max(8px, env(safe-area-inset-right)); max-width: calc(100vw - 16px); }
  .ai-cluster { padding: 6px; gap: 4px; border-radius: 16px; }
  .ai-root .ai-btn, .ai-root .ai-seg button { min-height: 40px; }
  .ai-status { display: none; }
  .ai-root.ai-expanded .ai-status { display: block; }
}

/* Landing 2026-12-03: on desktop the operator panel sits to the left of the
   Noetica orb so it never covers it (the orb must always be clickable). */
@media (min-width: 761px) {
  .ai-root { right: max(92px, env(safe-area-inset-right)); }
  .ai-presence { right: 92px; }
}
