/* mivari portal · one stylesheet. Leans on the Jarvis tokens (docs/design/v2/tokens.css); adds no tokens. */

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--c-ground);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--lh-normal);
}

a { color: inherit; }

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--c-text); outline-offset: 2px; }

.icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 20px; height: 20px; }

/* ---------- the orb (logo). portal.js mounts JarvisOrb in it; the background is the still fallback without script */
.orb {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  transition: width var(--d-grow) var(--ease-out), height var(--d-grow) var(--ease-out);
}
.orb:empty { border-radius: 50%; background: var(--orb-fallback); }
.orb--logo { width: 32px; height: 32px; }
.orb--start { width: 112px; height: 112px; }
.orb--busy,
[data-state="busy"] .orb { width: 168px; height: 168px; }

/* ---------- centred column: login, opening, link a tv */
.page-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-6) var(--s-6) 72px;
}
.column { width: 100%; max-width: 288px; display: flex; flex-direction: column; gap: var(--s-5); }
.column--wide { max-width: 320px; gap: var(--s-6); }

.brand { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); text-align: center; }
.brand--busy,
[data-state="busy"] .brand { gap: 28px; }

.wordmark { margin: 0; font-size: 22px; font-weight: var(--fw-light); letter-spacing: 0.01em; line-height: var(--lh-tight); }
.title { margin: 0; font-size: 24px; font-weight: var(--fw-light); line-height: var(--lh-tight); }
.status-text { margin: 0; font-size: 20px; font-weight: var(--fw-light); line-height: var(--lh-tight); color: var(--c-text-2); text-align: center; }
.body-text { margin: 0; font-size: 17px; line-height: 1.4; color: var(--c-text-2); text-align: center; }
.hint { margin: 0; font-size: 14px; line-height: 1.45; color: var(--c-text-3); text-align: center; }

/* login: while busy the fields and the wordmark leave, the orb grows, the status line shows */
/* the name and the status line share one spot and cross-fade */
.brand-line { display: grid; justify-items: center; align-items: center; }
.brand-line > * { grid-area: 1 / 1; transition: opacity var(--d-fast) var(--ease-std), visibility 0s; }
.login-status,
[data-state="busy"] .wordmark {
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--d-fast) var(--ease-std), visibility 0s linear var(--d-fast);
}
[data-state="busy"] .login-status {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--d-fast) var(--ease-std) var(--d-fast), visibility 0s linear var(--d-fast);
}

/* the form folds away (and back) instead of jumping; the 2 px inset keeps focus rings from being clipped */
.login-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--d-grow) var(--ease-out), opacity var(--d-fast) var(--ease-std) var(--d-fast), visibility 0s;
}
.login-inner { min-height: 0; overflow: hidden; margin: -2px; padding: 2px; display: flex; flex-direction: column; gap: var(--s-4); }
[data-state="busy"] .login-body {
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows var(--d-grow) var(--ease-out), opacity var(--d-fast) var(--ease-std), visibility 0s linear var(--d-fast);
}

.message-slot { min-height: var(--hit-min); display: flex; flex-direction: column; justify-content: flex-end; }
.message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--hit-min);
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-button);
  background: var(--c-key);
  box-shadow: inset 0 0 0 1px var(--c-off);
  font-size: 15px;
}
.message .icon { color: var(--c-text-2); }
.message--alert { background: rgba(224, 83, 58, .14); box-shadow: inset 0 0 0 1px rgba(224, 83, 58, .45); }
.message--alert .icon { color: var(--c-alert); }
.message--plain { justify-content: center; background: none; box-shadow: none; color: var(--c-text-2); text-align: center; }

.form { display: flex; flex-direction: column; gap: var(--s-3); margin: 0; }
.form .button { margin-top: var(--s-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--c-text-3); }

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-button);
  background: var(--c-panel);
  box-shadow: var(--sh-hairline);
  color: var(--c-text);
  font: inherit;
  font-size: 16px;
}
.input:focus-visible { outline: 2px solid var(--c-text); outline-offset: 0; }
.input:disabled { opacity: .5; }
.input--code { height: 56px; font-family: var(--font-mono); font-size: 24px; letter-spacing: 8px; text-align: center; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 48px;
  padding: 0 var(--s-5);
  border: 0;
  border-radius: var(--r-button);
  background: var(--c-primary);
  color: var(--c-on-primary);
  font: inherit;
  font-size: 16px;
  font-weight: var(--fw-medium);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--d-instant) var(--ease-std);
}
.button:active { transform: scale(.97); }
.button:disabled { background: var(--c-key); color: var(--c-text-3); cursor: default; transform: none; }
.button--narrow { align-self: center; width: 100%; max-width: 240px; }

.steps { margin: 0; padding: 0 0 0 22px; display: flex; flex-direction: column; gap: var(--s-2); color: var(--c-text-2); line-height: 1.4; }

/* ---------- top bar: logo left, profile right */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px var(--s-4);
}
.topbar--end { justify-content: flex-end; }

.logo { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: var(--fw-light); letter-spacing: 0.01em; text-decoration: none; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--hit-min);
  padding: 0 var(--s-3) 0 6px;
  border-radius: var(--r-button);
  color: var(--c-text-2);
  text-decoration: none;
}

.profile { position: relative; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c-key);
  box-shadow: inset 0 0 0 1px var(--c-off);
  color: var(--c-text);
  font: inherit;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  cursor: pointer;
}
/* the button stays 40 px to look light; this pads the tap area to 44 px */
button.avatar { position: relative; }
button.avatar::after { content: ''; position: absolute; inset: -2px; }

.profile-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + var(--s-2));
  right: 0;
  width: 248px;
  padding: var(--s-2);
  border-radius: 16px;
  background: var(--c-panel);
  box-shadow: var(--sh-raised);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  transition: opacity var(--d-fast) var(--ease-std), transform var(--d-fast) var(--ease-std), visibility 0s linear var(--d-fast);
}
.profile-panel[data-open] {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--d-pop) var(--ease-out), transform var(--d-pop) var(--ease-out), visibility 0s;
}
.profile-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) 10px; font-size: 17px; }
.profile-sep { height: 1px; margin: 0 var(--s-3) 6px; background: var(--c-key-2); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 48px;
  padding: 0 var(--s-3);
  border-radius: var(--r-chip);
  text-decoration: none;
  transition: background var(--d-fast) var(--ease-std);
}
.menu-item:hover { background: var(--c-key); }

/* ---------- floating bar with the entries: bottom on a phone, top centre on a wide screen */
.dock {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: calc(var(--s-6) + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: var(--s-1);
  width: fit-content;
  max-width: calc(100vw - 24px);
  margin: 0 auto;
  padding: 6px;
  border-radius: var(--r-pill);
  background: var(--c-key);
  box-shadow: var(--sh-raised);
}
.dock a {
  flex: 0 1 104px;
  width: 104px;
  min-width: 0;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--r-pill);
  color: var(--c-text-3);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--d-fast) var(--ease-std), color var(--d-fast) var(--ease-std);
}
.dock a[aria-current="page"] { background: var(--c-off); color: var(--c-text); }
.dock .icon { width: 22px; height: 22px; }

/* stand-in for the service itself; not part of the real page */
.service-placeholder {
  flex: 1;
  margin: var(--s-1) var(--s-4) 100px;
  border: 1px dashed var(--c-off);
  border-radius: var(--r-card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: var(--ls-label);
  color: var(--c-text-4);
  text-align: center;
}

/* switching entries: the orb stays in the top bar and speeds up; only this line shows in the content area */
.service-placeholder--loading .status-text { font-family: var(--font-sans); letter-spacing: 0; animation: rise var(--d-text-in) var(--ease-out) backwards; }

/* ---------- start screen: orb in the middle, entries as round icons */
.start {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-10);
  padding: 0 var(--s-6) 120px;
}
.start-head { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); }
.greeting { margin: 0; font-size: 22px; font-weight: var(--fw-light); line-height: var(--lh-tight); }

.launcher { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-4) 10px; max-width: 560px; margin: 0; padding: 0; list-style: none; }
.launcher a { width: 76px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; text-align: center; text-decoration: none; }
.launcher .disc {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--c-panel);
  box-shadow: var(--sh-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--d-fast) var(--ease-std), transform var(--d-instant) var(--ease-std);
}
.launcher a:hover .disc { background: var(--c-key); }
.launcher a:active .disc { transform: scale(.97); }
.launcher .icon { width: 28px; height: 28px; }

@media (min-width: 768px) {
  .orb { width: 104px; height: 104px; }
  .orb--logo { width: 32px; height: 32px; }
  .orb--start { width: 132px; height: 132px; }
  .orb--busy,
  [data-state="busy"] .orb { width: 200px; height: 200px; }

  .topbar { padding: 14px var(--s-8); }

  .dock { top: 10px; bottom: auto; }
  .dock a { flex: none; width: auto; height: var(--hit-min); flex-direction: row; gap: 10px; padding: 0 18px; font-size: 15px; }
  .dock .icon { width: 20px; height: 20px; }

  .service-placeholder { margin: var(--s-4) var(--s-8) var(--s-8); }

  .launcher { gap: var(--s-4) var(--s-8); }
  .launcher a { width: 88px; }
}

/* ---------- press, hover and focus. Hover only where a pointer can hover, so nothing sticks after a tap */
.button { transition: transform var(--d-instant) var(--ease-std), filter var(--d-fast) var(--ease-std), background var(--d-fast) var(--ease-std), color var(--d-fast) var(--ease-std); }
.input { transition: box-shadow var(--d-fast) var(--ease-std), background var(--d-fast) var(--ease-std), opacity var(--d-fast) var(--ease-std); }
.avatar, .back { transition: background var(--d-fast) var(--ease-std), color var(--d-fast) var(--ease-std), transform var(--d-instant) var(--ease-std); }
.launcher a { transition: color var(--d-fast) var(--ease-std); }
.logo { transition: opacity var(--d-fast) var(--ease-std); }

button.avatar:active, .back:active, .dock a:active, .menu-item:active { transform: scale(.97); }
.dock a, .menu-item { transition: background var(--d-fast) var(--ease-std), color var(--d-fast) var(--ease-std), transform var(--d-instant) var(--ease-std); }
button.avatar[aria-expanded="true"] { background: var(--c-key-on); }

/* the ring sits on the round disc, not on the label under it */
.launcher a:focus-visible { outline: none; }
.launcher a:focus-visible .disc { outline: 2px solid var(--c-text); outline-offset: 2px; }

@media (hover: hover) {
  .button:hover:not(:disabled) { filter: brightness(1.06); }
  .input:hover:not(:disabled):not(:focus-visible) { box-shadow: inset 0 0 0 1px var(--c-off); }
  button.avatar:hover { background: var(--c-key-on); }
  .back:hover { background: var(--c-key); color: var(--c-text); }
  .dock a:hover:not([aria-current="page"]) { background: var(--c-key-2); color: var(--c-text); }
  .launcher a:hover { color: var(--c-text); }
  a.logo:hover { opacity: .8; }
}

/* ---------- arriving on a page: the texts rise in, the orb does not (it carries over between pages) */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.brand-line,
.brand > .title,
.brand > .status-text,
.login-body,
.column > .steps,
.column > .form,
.column > .message,
.column > .hint,
.column > .body-text,
.column > .button,
.greeting,
.launcher,
.start > .body-text {
  animation: rise var(--d-text-in) var(--ease-out) backwards;
}
.login-body, .column > .steps, .launcher, .start > .body-text { animation-delay: 60ms; }
.column > .form, .column > .button { animation-delay: 120ms; }
.column > .hint { animation-delay: 180ms; }

/* ---------- moving between pages (browsers with cross-document view transitions; others just load the page).
   The orb, the bar, the lit item in the bar and the profile keep their identity, so they glide instead of blinking. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.orb { view-transition-name: orb; }
.dock { view-transition-name: dock; }
.dock a[aria-current="page"] { view-transition-name: dock-current; }
button.avatar { view-transition-name: profile; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--d-fast); }
::view-transition-group(orb) { animation-duration: var(--d-grow); animation-timing-function: var(--ease-out); }
::view-transition-group(dock), ::view-transition-group(dock-current), ::view-transition-group(profile) { animation-duration: var(--d-sheet); animation-timing-function: var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
