/* =============================================================================
   Jarvis UI — styles.css
   Holographic dark interface. Three.js orb lives at z-index 0.
   ============================================================================= */

/* ── Reset ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Prevent text-selection highlight on any canvas (hold-to-speak) */
canvas {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Auth screen ─────────────────────────────────────────────────────────────
   Full black. Mini orb behind J.A.R.V.I.S wordmark in top section.
   z-index 100 covers the Three.js canvas (z 0) and app UI (z 10).         */

#pin-modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  /* children use absolute positioning within this fixed container */
}

#pin-modal.hidden {
  display: none;
}

/* ── Auth header: occupies top 40% — mini orb and wordmark overlap-centered ── */

#auth-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40vh;
  /* mini-orb-wrap and jarvis-wordmark both position:absolute inside here */
}

/* 190×190 container centered in the top-40% zone */
#mini-orb-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 190px;
  height: 190px;
}

#mini-orb-wrap canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

/* ── JARVIS wordmark ─────────────────────────────────────────────────────── */

@keyframes jarvis-glow {
  0%, 100% {
    text-shadow:
      0 0 8px  rgba(0, 191, 255, 0.9),
      0 0 20px rgba(0, 191, 255, 0.6),
      0 0 45px rgba(0, 191, 255, 0.35),
      0 0 90px rgba(0, 191, 255, 0.15);
    opacity: 0.92;
  }
  50% {
    text-shadow:
      0 0 12px rgba(0, 191, 255, 1.0),
      0 0 30px rgba(0, 191, 255, 0.8),
      0 0 65px rgba(0, 191, 255, 0.5),
      0 0 120px rgba(0, 191, 255, 0.25);
    opacity: 1.0;
  }
}

#jarvis-wordmark {
  font-size: clamp(52px, 13vw, 88px);
  font-weight: 100;
  letter-spacing: 0.42em;
  /* Compensate trailing letter-spacing gap so text looks optically centered */
  padding-left: 0.42em;
  color: #00BFFF;
  text-transform: uppercase;
  animation: jarvis-glow 3.2s ease-in-out infinite;
  line-height: 1;
  white-space: nowrap;
  /* Centered on top of mini orb — passes through orb's horizontal midline */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* ── Auth spacer — not used in absolute layout ───────────────────────────── */

#auth-spacer {
  display: none;
}

/* ── Unlock button: centered in full screen ──────────────────────────────── */

#auth-lower {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Unlock / retry button ───────────────────────────────────────────────── */

#pin-submit {
  background: transparent;
  border: 1px solid rgba(0, 191, 255, 0.25);
  border-radius: 3px;
  color: rgba(0, 191, 255, 0.55);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 9px 26px 9px 30px;
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 12px;
}

#pin-submit:hover,
#pin-submit:active {
  border-color: rgba(0, 191, 255, 0.65);
  color: rgba(0, 191, 255, 0.9);
}

/* ── Auth error text ─────────────────────────────────────────────────────── */

#pin-error {
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: rgba(255, 80, 80, 0.75);
  min-height: 16px;
  text-align: center;
}

/* ── Main app container ─────────────────────────────────────────────────── */

#app {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: transparent;
  pointer-events: none;
}

#app.hidden {
  display: none;
}

/* ── Status corner (top right) ──────────────────────────────────────────── */

#status-corner {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 20;
}

/* ── Connection / activity dot ──────────────────────────────────────────── */

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 4px 1px rgba(0, 191, 255, 0.5); }
  50%       { box-shadow: 0 0 8px 3px rgba(0, 191, 255, 0.85); }
}

@keyframes dot-connecting {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

#connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

#connection-dot.connected {
  background: #00BFFF;
  box-shadow: 0 0 4px 1px rgba(0, 191, 255, 0.4);
}

#connection-dot.connected.active {
  background: #00BFFF;
  animation: dot-pulse 1.8s ease-in-out infinite;
}

#connection-dot.disconnected {
  background: #3a3a3a;
  box-shadow: none;
}

#connection-dot.connecting {
  background: rgba(255, 160, 0, 0.6);
  animation: dot-connecting 1s ease-in-out infinite;
}

/* ── Tool name label (below dot) ────────────────────────────────────────── */

#status-text {
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: rgba(0, 191, 255, 0.45);
  text-align: center;
  min-height: 14px;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── State label — just above orb center ────────────────────────────────── */

#orb-state-label {
  position: fixed;
  top: 18%;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 0.2em;
  font-family: Verdana, sans-serif;
  text-transform: lowercase;
  color: #4FC3F7;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

#orb-state-label.visible {
  opacity: 1;
}

/* ── Transcript — last assistant response, below orb center ─────────────── */

@keyframes transcript-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#transcript-area {
  display: none !important;
}

/* ── Scanline overlay ────────────────────────────────────────────────────── */

#scanline-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 191, 255, 0.018) 2px,
    rgba(0, 191, 255, 0.018) 4px
  );
}

/* ── Sonar ripple rings (speaking state) ─────────────────────────────────── */

@keyframes sonar-expand {
  from { transform: translate(-50%, -50%) scale(1); opacity: 0.45; }
  to   { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.sonar-ring {
  position: fixed;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  border: 1px solid #00BFFF;
  pointer-events: none;
  z-index: 5;
  animation: sonar-expand 1.8s ease-out forwards;
}

/* ── HUD status bar (top strip) ──────────────────────────────────────────── */

#hud-status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  z-index: 25;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 16px;
}

#hud-status-icons {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: Verdana, sans-serif;
  color: #4FC3F7;
  opacity: 0.5;
  letter-spacing: 0.05em;
}

/* ── HUD clock (top left) ────────────────────────────────────────────────── */

#hud-clock {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  pointer-events: none;
}

#hud-time {
  font-size: 18px;
  font-family: Verdana, sans-serif;
  color: #00BFFF;
  font-weight: 300;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

#hud-date {
  font-size: 11px;
  font-family: Verdana, sans-serif;
  color: #4FC3F7;
  font-weight: 300;
  letter-spacing: 0.2em;
  opacity: 0.6;
  margin-top: 3px;
}

/* ── Utility ────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

#scanlines {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 191, 255, 0.018) 2px,
    rgba(0, 191, 255, 0.018) 4px
  );
}

/* ── Idle breathing glow (Feature 1) ────────────────────────────────────── */

@keyframes orb-breathe {
  0%, 100% { box-shadow: 0 0 30px 8px rgba(0, 191, 255, 0.08); }
  50%       { box-shadow: 0 0 60px 20px rgba(0, 191, 255, 0.18); }
}

#orb-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 49vh;
  height: 49vh;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#orb-glow.active {
  opacity: 1;
  animation: orb-breathe 3s ease-in-out infinite;
}

/* ── Reconnect indicator (Feature 4) ────────────────────────────────────── */

#reconnect-label {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-family: Verdana, sans-serif;
  color: #888888;
  letter-spacing: 0.15em;
  pointer-events: none;
  z-index: 50;
  display: none;
}

#reconnect-label.visible {
  display: block;
}
