/*
 * jarvis app.css — the browser app's own rules on top of the kit's theme.css
 * (go/rogr-kit/web/theme.css). Two parts:
 *   - the login and passkeys pages: the kit's layout as in vitals (.app-width);
 *   - the HUD (design round 3. 11. 2026, his pick „B HUD"): the visor — deep
 *     blue-black ink with faint scanlines and a soft ROGR-blue glow, corner
 *     brackets, telemetry in the corners, a curved horizon, the voice
 *     waveform, his question small and grey, Jarvis's answer large, result
 *     panels with clipped corners and the glowing talk button. Fully custom,
 *     always dark (no colour-mode switch on the visor), the kit's Open Sans.
 * No inline styles anywhere: the pages run under style-src 'self'; hud.js
 * only sets custom properties (--level, --i) through the CSSOM.
 */
.app-width { max-width: 760px; }

/* ===================================================================== HUD */
.hud-root {
  --ink: #04111a;
  --core: #008cd2;
  --glow: #6fd0ff;
  --steel: #3c4141;
  --mist: #9b9b9b;
  --paper: #e8f1f6;
  --bright: #f2f8fb;
  --hud-line: rgba(111, 208, 255, .35);
  --hud-faint: rgba(111, 208, 255, .12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* the bottom corners and controls may reach a little into the home
     indicator's area (his „zbytečně velká mezera" 3. 11. 2026) */
  --safe-b-tight: max(calc(var(--safe-b) - 14px), 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --pad-x: 34px;
  --frame-x: 16px;
  --frame-y: 14px;
  background: var(--ink);
  color-scheme: dark;
}
.hud {
  min-height: var(--app-h, 100dvh);
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* the visor: a soft ROGR-blue glow over faint scanlines */
.hud::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 70% at 50% 40%, rgba(0, 140, 210, .16), transparent 60%),
    repeating-linear-gradient(0deg, rgba(111, 208, 255, .035) 0 1px, transparent 1px 3px);
}
.hud ::selection { background: rgba(0, 140, 210, .45); color: #fff; }

/* corner brackets, inside the safe area */
/* --app-h: the real screen height, set by hud.js — an iOS home-screen app
   with the translucent status bar counts 100dvh without the status bar, which
   left an empty strip under the HUD (3. 11. 2026) */
.hud-frame {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  top: calc(var(--safe-t) + var(--frame-y));
  left: calc(var(--safe-l) + var(--frame-x));
  right: calc(var(--safe-r) + var(--frame-x));
  height: calc(var(--app-h, 100dvh) - var(--safe-t) - var(--safe-b-tight) - 2 * var(--frame-y));
}
.br { position: absolute; width: 34px; height: 34px; border: 2px solid var(--core); }
.br-tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.br-tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.br-bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.br-br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* the screen: top telemetry, the voice band, the status, the conversation
   (the only part that scrolls), the controls */
.hud-screen {
  position: relative;
  z-index: 1;
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  padding: calc(var(--safe-t) + var(--frame-y) + 14px) calc(var(--safe-r) + var(--pad-x)) calc(var(--safe-b-tight) + var(--frame-y) + 6px) calc(var(--safe-l) + var(--pad-x));
  overflow: hidden;
}

/* ---- telemetry */
.tele { margin: 0; font-size: 13px; line-height: 1.35; color: var(--mist); letter-spacing: .01em; }
.tele b { display: block; font-size: 22px; font-weight: 500; line-height: 1.25; color: var(--glow); letter-spacing: 0; }
.tele b.warn { color: var(--rogr-warn); }
.tele.fresh { animation: hud-in .5s ease-out both; }
.hud-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; column-gap: 8px; }
.tele-out { text-align: right; }
.hud-title { position: relative; display: flex; justify-content: center; }

/* the menu: „JARVIS" in the top centre */
.hud-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  padding: 6px 8px 6px calc(8px + .34em);
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--mist);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .34em;
  text-transform: uppercase;
  cursor: pointer;
}
.hud-menu-btn:hover, .hud-menu-btn[aria-expanded="true"] { color: var(--glow); }
.hud-menu-btn svg { flex: none; }
.hud-menu {
  --bs-menu-bg: #061b29;
  --bs-menu-color: var(--paper);
  --bs-menu-border-color: var(--hud-line);
  --bs-menu-border-radius: 2px;
  --bs-menu-item-border-radius: 2px;
  --bs-menu-item-color: var(--paper);
  --bs-menu-item-hover-color: var(--bright);
  --bs-menu-item-hover-bg: rgba(0, 140, 210, .2);
  --bs-menu-font-size: 14px;
  --bs-menu-box-shadow: 0 12px 40px rgba(0, 0, 0, .55), 0 0 24px rgba(0, 140, 210, .18);
  min-width: 14rem;
}
.hud-menu .menu-item:focus-visible { outline: 2px solid var(--glow); outline-offset: -2px; }
.hud-menu .menu-state { margin-left: auto; padding-left: 12px; color: var(--glow); font-size: 12px; }
.hud-menu [aria-pressed="false"] .menu-state { color: var(--mist); }
.hud-logout { display: contents; }

/* ---- the voice band: the horizon arc and the waveform */
.hud-band { position: relative; height: 112px; margin-top: 20px; }
.horizon {
  position: absolute;
  top: 0;
  left: -34%;
  right: -34%;
  height: 140px;
  border-top: 1px solid var(--hud-line);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  pointer-events: none;
}
.wave { position: absolute; left: 0; top: 34px; display: block; width: 100%; height: 72px; }

/* ---- the state line under the band */
.hud-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--mist);
}
.hud-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--core); box-shadow: 0 0 8px var(--core); }
[data-state="arming"] .hud-dot, [data-state="listening"] .hud-dot { background: var(--glow); box-shadow: 0 0 10px var(--glow); animation: hud-blink 1s ease-in-out infinite; }
[data-state="thinking"] .hud-dot { animation: hud-blink .7s ease-in-out infinite; }
[data-state="listening"] .hud-status, [data-state="speaking"] .hud-status { color: var(--glow); }

/* ---- the conversation */
.hud-main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 0 18px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 18px), transparent 100%);
}
.hud-main::-webkit-scrollbar { display: none; }
.q { margin: 0 0 12px; font-size: 15px; line-height: 1.45; color: var(--mist); }
.q:empty:not(.pending) { display: none; }
.q.pending::after { content: "…"; }
.a { margin: 0; font-size: 21px; line-height: 1.4; font-weight: 500; color: var(--bright); text-wrap: pretty; overflow-wrap: break-word; }
.a.long { font-size: 18px; }
.a.fresh { animation: hud-in .45s ease-out both; }
/* while Jarvis thinks, the previous answer and its panels step back */
.a, .hud-panels { transition: opacity .3s; }
[data-state="thinking"] .a, [data-state="thinking"] .hud-panels { opacity: .4; }
.hud-error {
  margin: 16px 0 0;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--rogr-warn);
  color: var(--rogr-warn);
  font-size: 15px;
  line-height: 1.45;
}

/* ---- result panels: clipped corners, a 1 px edge drawn by the outer layer */
.hud-panels { display: grid; gap: 12px; align-content: start; }
.panel {
  --cut: 18px;
  padding: 1px;
  background: rgba(111, 208, 255, .45);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.panel.enter { animation: hud-in .4s ease-out both; animation-delay: calc(var(--i, 0) * 80ms); }
.panel-in {
  --cut-in: calc(var(--cut) - .59px);
  padding: 15px 18px 15px;
  background: linear-gradient(135deg, #052a3f, #051925);
  clip-path: polygon(0 0, calc(100% - var(--cut-in)) 0, 100% var(--cut-in), 100% 100%, var(--cut-in) 100%, 0 calc(100% - var(--cut-in)));
}
.panel h2 { margin: 0 0 9px; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--glow); letter-spacing: .02em; }
.panel-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 5px 0; border-top: 1px solid var(--hud-faint); font-size: 15px; line-height: 1.4; }
/* the label keeps its width (up to 45 %), the value wraps between words */
.panel-row .l { flex: 0 0 auto; max-width: 45%; color: var(--paper); }
.panel-row .v { flex: 1 1 0; min-width: 0; color: var(--glow); text-align: right; overflow-wrap: break-word; }
.panel-row.full .v { color: var(--paper); text-align: left; }

/* ---- the controls: (house, tram), the typed question, the talk button */
.hud-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "house tram" "ask ask" "talk talk" "hint hint";
  column-gap: 16px;
  align-items: end;
}
.tele-house { grid-area: house; }
.tele-tram { grid-area: tram; text-align: right; }
.tele-house b, .tele-tram b { font-size: 17px; }
.tele-house span, .tele-tram span { font-size: 12px; }

.ask-form { grid-area: ask; display: none; align-items: center; gap: 6px; margin-top: 14px; border-bottom: 1px solid var(--hud-line); }
.hud-screen.typing .ask-form { display: flex; }
.ask-form:focus-within { border-bottom-color: var(--glow); box-shadow: 0 1px 0 var(--glow); }
.ask-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 16px; /* 16 px: iOS does not zoom into the field */
  outline: none;
}
.ask-input::placeholder { color: var(--mist); opacity: .85; }
.ask-send { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--glow); cursor: pointer; }
.ask-send:hover { background: rgba(0, 140, 210, .18); }

.talk-row { grid-area: talk; display: flex; justify-content: center; align-items: center; gap: 32px; margin-top: 16px; }
.hud-icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--hud-line);
  border-radius: 50%;
  background: rgba(4, 17, 26, .5);
  color: var(--glow);
  cursor: pointer;
}
.hud-icon-btn:hover, .hud-icon-btn[aria-expanded="true"] { background: rgba(0, 140, 210, .22); border-color: var(--glow); }
.kbd-spacer { width: 44px; height: 44px; }

.talk {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 92px;
  height: 92px;
  padding: 0;
  border: 2px solid var(--core);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 140, 210, .12), rgba(4, 17, 26, .65) 70%);
  box-shadow: 0 0 0 8px rgba(0, 140, 210, .12), 0 0 40px rgba(0, 140, 210, .45);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: box-shadow .2s, border-color .2s, transform .15s;
}
.talk-orb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, #e8faff, #6fd0ff 55%, #008cd2);
  box-shadow: 0 0 18px rgba(111, 208, 255, .55);
  transform: scale(calc(1 + var(--level, 0) * .32));
  transition: transform .08s linear;
}
.talk-ring { position: absolute; inset: -14px; border-radius: 50%; pointer-events: none; }
.talk:hover { box-shadow: 0 0 0 9px rgba(0, 140, 210, .16), 0 0 48px rgba(0, 140, 210, .55); }
[data-state="arming"] .talk, [data-state="listening"] .talk {
  border-color: var(--glow);
  transform: scale(1.04);
  box-shadow: 0 0 0 calc(8px + var(--level, 0) * 16px) rgba(111, 208, 255, .16), 0 0 64px rgba(111, 208, 255, .55);
}
[data-state="speaking"] .talk { box-shadow: 0 0 0 calc(8px + var(--level, 0) * 14px) rgba(0, 140, 210, .18), 0 0 56px rgba(0, 140, 210, .6); }
/* thinking: a bright arc running round the button — the reactor at work */
[data-state="thinking"] .talk-ring {
  background: conic-gradient(from 0deg, transparent 0 62%, rgba(111, 208, 255, .9) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: hud-spin 1.6s linear infinite;
}
.hint { grid-area: hint; margin: 10px 0 0; min-height: 1.35em; text-align: center; font-size: 13px; line-height: 1.35; color: var(--mist); }

/* visible focus on every control of the visor */
.hud :focus { outline: none; }
.hud :focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }
.talk:focus-visible { outline-offset: 8px; }
.ask-input:focus-visible { outline: none; }

/* ---- phones: the bottom corners hide on a short screen (Safari with its bars) */
@media (max-width: 767.98px) and (max-height: 740px) {
  .tele-house, .tele-tram { display: none; }
}

/* ---- tablets in portrait */
@media (min-width: 768px) {
  .hud-root { --pad-x: 48px; --frame-x: 22px; --frame-y: 20px; }
  .hud-band { height: 132px; }
  .horizon { height: 170px; left: -20%; right: -20%; }
  .wave { top: 40px; height: 86px; }
  .q { font-size: 17px; }
  .a { font-size: 26px; line-height: 1.36; font-weight: 400; }
  .a.long { font-size: 22px; }
  .hud-panels { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .hud-bottom {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "ask ask ask" "house talk tram" "house hint tram";
  }
  .ask-form { justify-self: center; width: min(520px, 100%); margin-bottom: 4px; }
  .tele-house, .tele-tram { align-self: end; padding-bottom: 6px; }
  .tele-house b, .tele-tram b { font-size: 22px; }
  .tele-house span, .tele-tram span { font-size: 13px; }
}

/* ---- Mac and iPad landscape: the mock-up's desk layout */
@media (min-width: 1024px) {
  .hud-root { --pad-x: 56px; --frame-x: 28px; --frame-y: 24px; }
  .hud-screen { padding-top: calc(var(--safe-t) + var(--frame-y) + 16px); padding-bottom: calc(var(--safe-b-tight) + var(--frame-y) + 8px); }
  .hud-band { height: 150px; margin-top: 10px; }
  .horizon { height: 200px; left: -12%; right: -12%; }
  .wave { top: 46px; height: 92px; }
  .hud-main { display: grid; grid-template-columns: minmax(0, 1fr) 400px; column-gap: 56px; align-items: start; padding-top: 24px; }
  .hud-dialogue { max-width: 680px; }
  .q { font-size: 18px; margin-bottom: 14px; }
  .a { font-size: 30px; line-height: 1.34; }
  .a.long { font-size: 24px; }
  .hud-panels { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .hud-bottom { grid-template-areas: "house ask tram" "house talk tram" "house hint tram"; }
  .ask-form { display: flex; width: 440px; margin: 0 0 6px; }
  .kbd-btn, .kbd-spacer { display: none; }
  .talk-row { margin-top: 18px; }
}

/* ---- landscape phones and small windows: a slimmer band, a smaller button */
@media (max-height: 560px) {
  .hud-band { height: 72px; margin-top: 6px; }
  .horizon { height: 90px; }
  .wave { top: 18px; height: 52px; }
  .talk { width: 70px; height: 70px; }
  .talk-orb { width: 34px; height: 34px; }
  .talk-row { margin-top: 8px; }
  .hint, .tele-house, .tele-tram { display: none; }
}

@keyframes hud-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes hud-spin { to { transform: rotate(1turn); } }
@keyframes hud-blink { 50% { opacity: .3; } }

@media (prefers-reduced-motion: reduce) {
  .hud *, .hud *::before, .hud *::after { animation: none !important; transition: none !important; }
  [data-state="thinking"] .talk-ring { background: conic-gradient(rgba(111, 208, 255, .55) 0 100%); }
}
