/* PARKER · HALO — holo-HUD interface. Deep navy, cyan array + orange accent.
   Rajdhani display / IBM Plex Mono labels. Rest ⇄ chat layout transition. */

:root {
  --bg: #05091c;
  --ink: #eaf3ff;
  --cyan: #58d3ff;
  --cyan-line: rgba(88, 211, 255, 0.24);
  --cyan-soft: #9fd6ff;
  --orange: #ff8a2a;
  --muted: #7a96be;
  --muted2: #6f9dc0;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Rajdhani", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(79, 184, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(255, 138, 42, 0.04), transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  padding: max(env(safe-area-inset-top), 0.6rem) 1.1rem env(safe-area-inset-bottom, 0.5rem);
}

#app { display: flex; flex-direction: column; width: 100%; height: 100%; max-width: 440px; }

/* --- App bar --- */
#appbar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; padding: 0.2rem 0.1rem 0.55rem; }
#appbar-left { display: flex; align-items: center; gap: 0.6rem; }
#back-btn {
  display: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--cyan-line); background: none; color: #b0e2ff; cursor: pointer;
}
#app.chat #back-btn { display: flex; }
#back-btn svg { width: 20px; height: 20px; }
#mode-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 10px var(--muted); transition: background 0.4s ease, box-shadow 0.4s ease; }
#brand { font-size: 1.28rem; font-weight: 700; letter-spacing: 0.14em; }
#status { font-family: "IBM Plex Mono", monospace; font-size: 0.58rem; letter-spacing: 0.12em; color: #5f7ba0; text-transform: uppercase; }
#status.error { color: var(--orange); }

.icon-round {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--cyan-line); background: none; color: #b0e2ff;
  display: grid; place-items: center; cursor: pointer;
}
.icon-round svg { width: 19px; height: 19px; }
#notif-btn.on { color: var(--orange); border-color: rgba(255, 138, 42, 0.5); }
/* Unread dot — shown when Parker has pushed something the user hasn't opened yet. */
#notif-btn.unread::after { content: ""; position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); border: 1.5px solid var(--bg); box-shadow: 0 0 9px var(--orange); }

/* --- Notifications panel (bell dropdown) --- */
#notif-panel {
  position: absolute; top: calc(env(safe-area-inset-top, 0.6rem) + 3rem); right: 1.1rem;
  z-index: 900; width: min(88vw, 340px); max-height: 62vh; display: flex; flex-direction: column;
  background: #0a1530; border: 1px solid rgba(88, 211, 255, 0.28); border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6); overflow: hidden;
}
#notif-panel.hidden { display: none; }
#notif-panel-head {
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
  padding: 0.7rem 0.9rem; border-bottom: 1px solid rgba(88, 211, 255, 0.16);
  font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--cyan-soft);
}
#notif-close { background: none; border: 0; color: #8fb4d8; display: grid; place-items: center; cursor: pointer; padding: 0.2rem; }
#notif-close svg { width: 17px; height: 17px; }
#notif-enable {
  flex-shrink: 0; margin: 0.7rem 0.9rem 0.2rem; padding: 0.65rem;
  border: 1px solid rgba(255, 138, 42, 0.5); border-radius: 12px; background: rgba(255, 138, 42, 0.1);
  color: #ffd8b0; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
}
#notif-enable.hidden { display: none; }
#notif-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0.4rem 0.5rem 0.6rem; }
.notif-item {
  padding: 0.6rem 0.55rem; border-bottom: 1px solid rgba(88, 211, 255, 0.1);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item .n-title { font-size: 0.9rem; font-weight: 600; color: #e7f2ff; }
.notif-item .n-body { font-size: 0.85rem; line-height: 1.4; color: #b9d2ee; margin-top: 0.12rem; white-space: pre-wrap; }
.notif-item .n-time { font-family: "IBM Plex Mono", monospace; font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; color: #6f8bad; margin-top: 0.25rem; }
.notif-item.unread .n-title::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); margin-right: 0.4rem; vertical-align: middle; box-shadow: 0 0 7px var(--orange); }
.notif-empty { padding: 1.3rem 0.6rem; text-align: center; color: #6f8bad; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; letter-spacing: 0.04em; }

/* --- Body: rest (orb centred) ⇄ chat (orb top, transcript open) --- */
#body { flex: 1; display: flex; flex-direction: column; align-items: center; width: 100%; min-height: 0; }
#app.rest #body { justify-content: center; padding-bottom: 6vh; }
#app.chat #body { justify-content: flex-start; }

#orbwrap {
  flex-shrink: 0;
  /* 80% of the previous size (78vw/296px) — smaller orb, more room for the transcript */
  width: min(62vw, 237px); height: min(62vw, 237px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 184, 255, 0.10), transparent 68%);
  display: flex; align-items: center; justify-content: center;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1), height 0.55s cubic-bezier(0.4, 0, 0.2, 1), margin 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
#app.chat #orbwrap { margin-top: 0.25rem; }  /* same size — just moved to the top */
#orb-canvas { width: 100%; height: 100%; display: block; }

#status-label {
  font-size: 1.42rem; font-weight: 600; letter-spacing: 0.03em; color: var(--muted);
  margin-top: 0.6rem; transition: font-size 0.4s ease, margin-top 0.4s ease;
}
#app.chat #status-label { font-size: 0.95rem; margin-top: 0.35rem; }
#status-sub {
  font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; letter-spacing: 0.06em;
  color: #7ea0c8; margin-top: 0.15rem; overflow: hidden;
  transition: opacity 0.4s ease, height 0.4s ease, margin-top 0.4s ease;
}
#app.chat #status-sub { opacity: 0; height: 0; margin-top: 0; }

/* --- Transcript (conversation) --- */
#transcript {
  width: 100%; display: flex; flex-direction: column; gap: 0.6rem;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-height: 0; opacity: 0; pointer-events: none; padding: 0 0.15rem;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#app.chat #transcript { flex: 1; max-height: none; opacity: 1; pointer-events: auto; padding: 0.9rem 0.15rem 0.4rem; }
/* Collapsing back to rest: fade + drop the transcript before the orb re-centres. */
#app.chat.leaving #transcript { opacity: 0; transform: translateY(10px); pointer-events: none; }

.msg {
  max-width: 84%; padding: 0.68rem 0.85rem; font-size: 0.93rem; line-height: 1.45; font-weight: 500;
  white-space: pre-wrap; border: 1px solid transparent;
}
.msg.user { align-self: flex-end; background: rgba(88, 211, 255, 0.10); border-color: rgba(88, 211, 255, 0.26); border-radius: 16px 16px 5px 16px; color: #dcefff; }
.msg.parker { align-self: flex-start; background: rgba(255, 138, 42, 0.10); border-color: rgba(255, 138, 42, 0.28); border-radius: 16px 16px 16px 5px; color: #ffe4cc; }
.msg.system { align-self: center; background: none; color: #6f8bad; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; letter-spacing: 0.03em; }

#latency { display: none; }

/* --- Input bar --- */
#inputbar {
  display: flex; align-items: center; gap: 0.7rem; flex-shrink: 0;
  margin-top: 0.5rem;
  padding: 0.6rem; border-radius: 20px;
  background: rgba(6, 16, 41, 0.55); border: 1px solid rgba(88, 211, 255, 0.2);
}
#text-input {
  flex: 1; min-width: 0; background: none; border: 0; color: #dcefff; caret-color: var(--cyan);
  font-family: "IBM Plex Mono", monospace; font-size: 0.9rem; letter-spacing: 0.01em;
  padding: 0 0.35rem; outline: none;
}
#text-input::placeholder { color: var(--muted2); }

.io-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 14px;
  border: 1px solid rgba(88, 211, 255, 0.26); background: none; color: var(--cyan-soft);
  display: grid; place-items: center; cursor: pointer;
}
.io-btn svg { width: 20px; height: 20px; }
.io-btn:active { background: rgba(88, 211, 255, 0.08); }
#send-btn.send {
  border: 0; background: linear-gradient(135deg, #ff9a3a, #ff7a18);
  color: #1a0e02; box-shadow: 0 0 22px rgba(255, 138, 42, 0.5);
}

/* Capture popover */
#capture { position: relative; flex-shrink: 0; }
#camera-btn.open { border-color: var(--cyan); color: var(--cyan); }
#capture-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  display: flex; flex-direction: column; min-width: 142px;
  background: #0a1530; border: 1px solid rgba(88, 211, 255, 0.28); border-radius: 12px;
  overflow: hidden; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
#capture-menu.hidden { display: none; }
#capture-menu button {
  background: none; border: 0; border-bottom: 1px solid rgba(88, 211, 255, 0.14);
  color: #cfe4f7; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem;
  letter-spacing: 0.12em; text-transform: uppercase; text-align: left;
  padding: 0.75rem 0.9rem; cursor: pointer;
}
#capture-menu button:last-child { border-bottom: 0; }
#capture-menu button:active { background: rgba(88, 211, 255, 0.12); color: var(--cyan-soft); }

/* --- Barcode scanner overlay --- */
#scanner { position: fixed; inset: 0; z-index: 1000; background: #000; display: flex; align-items: center; justify-content: center; }
#scanner.hidden { display: none; }
#scanner-video { width: 100%; height: 100%; object-fit: cover; }
#scanner-cancel {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 1rem) + 1.5rem); left: 50%; transform: translateX(-50%);
  background: rgba(6, 16, 41, 0.7); border: 1px solid rgba(88, 211, 255, 0.4); border-radius: 14px;
  color: var(--cyan-soft); font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  letter-spacing: 0.16em; text-transform: uppercase; padding: 0.7rem 1.9rem; cursor: pointer;
}

/* --- Taint indicator: shown while an action traces back to foreign content
   Parker read (an email, web page, scanned product) and is awaiting approval.
   Ambient amber cue so a confirmation is never approved without context. --- */
body.tainted::after {
  content: "🔶 reading external content — verify before approving";
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0.5rem) + 0.5rem);
  background: rgba(41, 26, 6, 0.92); border: 1px solid rgba(255, 176, 59, 0.55);
  color: #ffb03b; font-family: "IBM Plex Mono", monospace; font-size: 0.7rem;
  letter-spacing: 0.08em; padding: 0.5rem 1rem; border-radius: 12px;
  z-index: 1100; pointer-events: none; max-width: 90vw; text-align: center;
}

/* Print-mode reply (TASK-019): Parker printed this instead of speaking it.
   Subtle "printed, not spoken" marker so it doesn't read as a TTS failure. */
.msg.parker.printed::after {
  content: "🖨 printed";
  display: block; margin-top: 0.35rem;
  font-family: "IBM Plex Mono", monospace; font-size: 0.62rem;
  letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.45;
}
