/* J.A.R.V.I.S. HUD v3 — cinematic Iron Man movie aesthetic */

:root {
  --bg:        #000510;
  --bg-soft:   #001028;
  /* Default theme = cyan. JS swaps these vars when Jarvis changes the theme. */
  --cyan:      #00d8ff;
  --cyan-dim:  #007fa3;
  --cyan-glow: rgba(0, 216, 255, 0.7);
  --cyan-soft: rgba(0, 216, 255, 0.15);
  --amber:     #ffb200;
  --amber-glow:rgba(255, 178, 0, 0.7);
  --red:       #ff3838;
  --text:      #c7e6f5;
  --text-dim:  #5a8da5;
  --text-mute: #2f5a73;
  --grid:      rgba(0, 216, 255, 0.07);
  --grid-bold: rgba(0, 216, 255, 0.18);
  --panel-bg:  rgba(0, 20, 40, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
  font-weight: 400;
  cursor: none;
  -webkit-font-smoothing: antialiased;
}

/* ───── Backgrounds ───── */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid-bold) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-bold) 1px, transparent 1px);
  background-size: 30px 30px, 30px 30px, 150px 150px, 150px 150px;
}
.ambient {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, rgba(0, 100, 160, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 50% 100%, rgba(0, 130, 200, 0.10) 0%, transparent 60%);
}
.scanlines {
  position: fixed; inset: 0; z-index: 998; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 216, 255, 0.025) 3px 4px);
  mix-blend-mode: screen;
}
.vignette {
  position: fixed; inset: 0; z-index: 999; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.85) 100%);
}

/* ───── TOP BAR ───── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 28px;
}
.top-left { flex: 1; }
.brand { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; }
.brand-mark { color: var(--amber); font-size: 22px; text-shadow: 0 0 12px var(--amber-glow); }
.brand-name { font-family: 'Orbitron'; font-weight: 900; font-size: 22px; letter-spacing: 5px;
              color: var(--text); text-shadow: 0 0 12px var(--cyan-glow); }
.brand-tag { font-family: 'Share Tech Mono'; font-size: 10px; letter-spacing: 3px; color: var(--text-dim); }
.objective { font-family: 'Share Tech Mono'; font-size: 11px; letter-spacing: 2px;
             color: var(--text-dim); margin-bottom: 6px; }
.chevron { color: var(--amber); margin-right: 4px; }
.status-pills { display: flex; gap: 8px; }
.pill { font-family: 'Share Tech Mono'; font-size: 9px; letter-spacing: 2px;
        padding: 3px 9px; border: 1px solid var(--cyan-dim);
        background: rgba(0, 25, 50, 0.6); color: var(--cyan); }
.pill.ok { color: #00ff88; border-color: #00ff88; box-shadow: 0 0 6px rgba(0,255,136,0.3); }
.pill.amber { color: var(--amber); border-color: var(--amber); box-shadow: 0 0 6px var(--amber-glow); animation: pulse 2s infinite; }

.top-right { text-align: right; font-family: 'Share Tech Mono'; }
.big-time { font-size: 26px; font-weight: 700; color: var(--cyan); letter-spacing: 4px;
            text-shadow: 0 0 10px var(--cyan-glow); }
.meta-line { font-size: 10px; color: var(--text-dim); letter-spacing: 2px; margin-top: 2px; }

/* ───── PANELS (shared) ───── */
.panel {
  position: relative;
  border: 1px solid var(--cyan-dim);
  background: var(--panel-bg);
  padding: 14px 16px;
}
.panel-tall { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-corner { position: absolute; width: 10px; height: 10px; border: 1px solid var(--cyan); }
.panel-corner.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel-corner.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.panel-corner.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.panel-corner.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.panel-title { font-family: 'Share Tech Mono'; font-size: 11px; letter-spacing: 3px;
               color: var(--cyan); border-bottom: 1px solid var(--cyan-soft);
               padding-bottom: 6px; margin-bottom: 10px; }

/* ───── LEFT RAIL ───── */
.left-rail {
  position: fixed; top: 130px; bottom: 120px; left: 28px; width: 260px;
  z-index: 5; display: flex; flex-direction: column; gap: 14px;
  font-family: 'Share Tech Mono';
}
.right-rail {
  position: fixed; top: 130px; bottom: 120px; right: 28px; width: 260px;
  z-index: 5; display: flex; flex-direction: column; gap: 14px;
  font-family: 'Share Tech Mono';
}

.vital { display: flex; justify-content: space-between; font-size: 11px;
         color: var(--text-dim); letter-spacing: 1.5px; }
.vital-val { color: var(--cyan); font-weight: 700; }
.bar { height: 3px; background: rgba(0, 216, 255, 0.1); margin: 3px 0 9px;
       position: relative; }
.bar > span { display: block; height: 100%; background: var(--cyan);
              box-shadow: 0 0 6px var(--cyan-glow); }

/* Scrolling log */
.log { flex: 1; overflow: hidden; font-family: 'Share Tech Mono'; font-size: 10px;
       color: var(--text-mute); letter-spacing: 0.5px; line-height: 1.45; }
.log .entry { padding: 1px 0; }
.log .entry .ts { color: var(--cyan-dim); margin-right: 6px; }
.log .entry .ev { color: var(--text-dim); }
.log .entry.amber .ev { color: var(--amber); }
.log .entry.ok .ev { color: #00ff88; }

/* ───── RIGHT RAIL — radar & waveform ───── */
.radar { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%;
         border: 1px solid var(--cyan); overflow: hidden;
         box-shadow: 0 0 20px var(--cyan-soft), inset 0 0 20px var(--cyan-soft); margin-bottom: 6px; }
.radar-grid {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at center, transparent 33%, rgba(0,216,255,0.2) 33.5%, transparent 34%),
    radial-gradient(circle at center, transparent 66%, rgba(0,216,255,0.2) 66.5%, transparent 67%),
    linear-gradient(0deg, transparent 49.7%, rgba(0,216,255,0.2) 50%, transparent 50.3%),
    linear-gradient(90deg, transparent 49.7%, rgba(0,216,255,0.2) 50%, transparent 50.3%);
}
.radar-sweep {
  position: absolute; inset: 0;
  background: conic-gradient(from 0deg, transparent 0%, var(--cyan-glow) 5%, transparent 25%);
  animation: spin 3s linear infinite; mix-blend-mode: screen;
}
.radar-dot {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 8px var(--amber-glow);
  top: var(--y); left: var(--x); transform: translate(-50%, -50%);
  animation: pulse 1.5s infinite;
}
.rh-row { display: flex; justify-content: space-between; font-size: 10px;
          color: var(--text-dim); letter-spacing: 2px; margin-top: 4px; }

.waveform { display: flex; align-items: flex-end; gap: 2px;
            height: 60px; padding: 4px 0; margin-bottom: 4px; }
.waveform > span { flex: 1; background: var(--cyan); box-shadow: 0 0 4px var(--cyan-glow);
                    transition: height 0.15s; }

/* ───── STAGE (center sphere) ───── */
.stage {
  position: fixed; top: 130px; bottom: 200px; left: 320px; right: 320px;
  z-index: 2; display: flex; flex-direction: column; align-items: center;
  justify-content: center;
}
/* Square frame so the canvas is square — no rectangular dark fill peeking out */
.stage-frame {
  position: relative;
  width: min(68vh, 64vw, 760px);
  height: min(68vh, 64vw, 760px);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
#sphere { width: 100%; height: 100%; display: block; }
.hud-ring {
  position: absolute; border-radius: 50%;
  border: 1px dashed var(--cyan); pointer-events: none;
}
.hud-ring.r1 { width: 86%; aspect-ratio: 1; opacity: 0.45; animation: spin 30s linear infinite; }
.hud-ring.r2 { width: 100%; aspect-ratio: 1; opacity: 0.3; border-style: dotted; border-color: var(--amber); animation: spin 50s linear infinite reverse; }
.hud-ring.r3 { width: 115%; aspect-ratio: 1; opacity: 0.15; border-color: var(--amber); }
/* Compass ticks now hug the OUTER ring (r3, 115%) — visually frame the sphere */
.hud-tick {
  position: absolute; width: 14px; height: 14px;
  border: 2px solid var(--cyan); box-shadow: 0 0 6px var(--cyan-glow);
  background: var(--bg);
}
.hud-tick.t-n { top: -7%;   left: 50%;  transform: translateX(-50%); border-bottom: 0; border-left: 0; }
.hud-tick.t-s { bottom: -7%;left: 50%;  transform: translateX(-50%); border-top: 0;   border-right: 0; }
.hud-tick.t-e { right: -7%; top: 50%;   transform: translateY(-50%); border-right: 0; border-top: 0; }
.hud-tick.t-w { left: -7%;  top: 50%;   transform: translateY(-50%); border-left: 0;  border-bottom: 0; }

/* Goals panel — replaces roll call */
.goals {
  position: relative; width: 100%; max-width: 720px; margin-top: 10px;
  border: 1px solid var(--cyan-dim); background: var(--panel-bg);
  padding: 14px 20px;
}
.goals-head { display: flex; justify-content: space-between; align-items: center;
              border-bottom: 1px solid var(--cyan-soft); padding-bottom: 8px; margin-bottom: 14px; }
.goals-title { font-family: 'Share Tech Mono'; font-size: 11px; letter-spacing: 3px; color: var(--cyan); }
.goals-meta { font-family: 'Share Tech Mono'; font-size: 9px; color: var(--text-mute); letter-spacing: 2px; }
.goals-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.goal { text-align: center; font-family: 'Share Tech Mono'; }
.goal-label { font-size: 10px; color: var(--text-dim); letter-spacing: 4px; margin-bottom: 6px; }
.goal-numbers { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-bottom: 6px; }
.goal-actual { font-family: 'Orbitron'; font-weight: 700; font-size: 22px; color: #fff;
               text-shadow: 0 0 10px var(--cyan-glow); }
.goal-target { font-family: 'Share Tech Mono'; font-size: 11px; color: var(--text-mute); letter-spacing: 1px; }
.goal-bar { height: 5px; background: rgba(0, 216, 255, 0.12);
            position: relative; overflow: hidden; margin-bottom: 4px; border-radius: 1px; }
.goal-bar > span { display: block; height: 100%; width: 0%;
                   background: linear-gradient(90deg, var(--cyan) 0%, #00ff88 100%);
                   box-shadow: 0 0 8px var(--cyan-glow);
                   transition: width 0.6s ease-out; }
.goal-bar > span.over { background: linear-gradient(90deg, var(--cyan) 0%, var(--amber) 100%);
                         box-shadow: 0 0 8px var(--amber-glow); }
.goal-pct { font-family: 'Share Tech Mono'; font-size: 11px; color: var(--cyan);
            letter-spacing: 2px; font-weight: 700; }
.goal-pct.over { color: var(--amber); text-shadow: 0 0 6px var(--amber-glow); }

/* ───── BOTTOM BAR ───── */
.bottombar {
  position: fixed; bottom: 36px; left: 28px; right: 28px; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  gap: 30px; padding: 12px 24px;
  border-top: 1px solid var(--cyan-soft); border-bottom: 1px solid var(--cyan-soft);
  background: linear-gradient(180deg, rgba(0,28,55,0.3) 0%, rgba(0,10,20,0.5) 100%);
  font-family: 'Share Tech Mono';
}
.bb-left, .bb-right { display: flex; flex-direction: column; gap: 4px; font-size: 10px;
                       color: var(--text-dim); letter-spacing: 2px; flex: 0 0 auto; }
.bb-right { align-items: flex-end; }
.kv { display: flex; justify-content: space-between; gap: 12px; min-width: 220px; }
.kv-val { color: var(--cyan); }
.kv-val.ok { color: #00ff88; }
.bb-center {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 28px;
  align-items: center;
  flex: 1 1 auto;
  justify-content: center;
}
.bb-stat {
  display: inline-flex !important;
  flex-direction: column !important;
  align-items: center;
  text-align: center;
  flex: 0 0 auto;
  min-width: 110px;
}
.bb-label { display: block; font-size: 9px; color: var(--text-mute);
            letter-spacing: 3px; margin-bottom: 4px; white-space: nowrap; }
.bb-val { display: block; font-family: 'Orbitron'; font-weight: 700; font-size: 20px;
          color: var(--cyan); text-shadow: 0 0 8px var(--cyan-glow); white-space: nowrap; }
.bb-val.alert { color: var(--amber); text-shadow: 0 0 8px var(--amber-glow); }

/* ───── VOICE BAR ───── */
.voicebar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 28px; height: 32px;
  background: rgba(0, 8, 20, 0.92);
  border-top: 1px solid var(--cyan-dim);
  font-family: 'Share Tech Mono'; font-size: 11px;
  color: var(--text-dim); letter-spacing: 2px;
  transition: border-color 0.4s, box-shadow 0.4s;
}
.voicebar.listening { border-top-color: var(--cyan); box-shadow: 0 -8px 24px var(--cyan-glow); }
.voicebar.thinking { border-top-color: var(--cyan); box-shadow: 0 -8px 24px var(--cyan-glow); }
.voicebar.speaking { border-top-color: var(--cyan); box-shadow: 0 -8px 28px var(--cyan-glow); }
.vb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-mute); transition: all 0.3s; }
.voicebar.idle .vb-dot { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.voicebar.listening .vb-dot { background: var(--cyan); box-shadow: 0 0 14px var(--cyan-glow); animation: pulse 0.8s infinite; }
.voicebar.thinking .vb-dot { background: var(--cyan); box-shadow: 0 0 14px var(--cyan-glow); animation: pulse 0.8s infinite; }
.voicebar.speaking .vb-dot { background: var(--cyan); box-shadow: 0 0 16px var(--cyan-glow); animation: pulse 0.4s infinite; }
.vb-status { color: var(--cyan); font-weight: 700; min-width: 100px; }
.vb-sep { color: var(--text-mute); opacity: 0.5; }
.vb-line { display: flex; gap: 6px; flex: 1; min-width: 0; align-items: center; overflow: hidden; }
.vb-line span:last-child { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.vb-tag { font-size: 9px; color: var(--text-mute); }
.vb-tag.jarvis { color: var(--cyan); }

/* Animations */
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Hide scrollbars in logs */
.log::-webkit-scrollbar { display: none; }

/* Layout-toggle: when Jarvis hides a panel via the layout config */
[data-panel].hidden { display: none !important; }

/* Custom panels (Jarvis can create these) */
.custom-content { font-family: 'Share Tech Mono'; font-size: 11px; color: var(--text-dim); }
.cp-empty { color: var(--text-mute); padding: 6px 0; font-size: 11px; }
.cp-text { padding: 4px 0; line-height: 1.5; color: var(--text); white-space: pre-wrap; }
.cp-weather { text-align: center; padding: 4px 0; }
.cp-weather-temp { font-family: 'Orbitron'; font-weight: 900; font-size: 38px; color: #fff;
                    text-shadow: 0 0 12px var(--cyan-glow); }
.cp-unit { font-size: 18px; color: var(--cyan); margin-left: 2px; }
.cp-weather-cond { font-size: 12px; color: var(--cyan); letter-spacing: 2px;
                    text-shadow: 0 0 6px var(--cyan-glow); margin: 4px 0 10px; }
.cp-weather-row { display: flex; justify-content: space-between; font-size: 10px;
                   color: var(--text-dim); padding: 2px 4px; letter-spacing: 1px; }
.cp-weather-loc { font-size: 9px; color: var(--text-mute); letter-spacing: 2px;
                   margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--cyan-soft); }
