/* tera UI kit 1.0.0. Generated by `make ui-kit` from web/ui/src/shell.css. Do not edit: pkg/uikit's drift test fails on a hand edit. */

@layer tera.tokens, tera.base, tera.patterns, tera.shell;

@layer tera.shell {

/* tera UI kit — the shell's sheet (ADR-186 D4, D5 item 2).

   One sheet, two hosts:
     - <tera-shell> adopts it into its shadow root (the element's script
       carries it), so the shell looks the same whatever CSS an app ships;
     - a page tera renders on the server links it beside tera-ui.css and
       emits the same markup in light DOM, with no script.
   So every rule here is scoped to `.tera-shell` and its `.tera-shell-*`
   parts, and sets every property the base styles would otherwise give a
   button, a link, a heading or a rule in light DOM. The colours are the
   UI kit's tokens, which reach into the shadow root from <html>.
   The build puts the sheet in the `tera.shell` cascade layer, after the
   kit's base and patterns, so in light DOM it beats the base styles it
   restates without depending on which sheet a page links first.

   The menus are `[popover]`s in the top layer, under the button that opens
   them: by anchor where the browser positions by anchor, else at the bar's
   ends, where the buttons are.

   On a phone the bar keeps tera's mark, the app's tile, a "More" button
   and the person's avatar. The app's nav and actions live in
   `.tera-shell-overflow`, itself a `[popover]`: while the bar is wide that
   box is `display: contents`, so its children sit in the bar as they always
   did; on a phone it is hidden until "More" opens it as a menu. Width alone
   decides, so the element and a page with no script behave alike, and the
   names the bar stops showing stay each button's accessible name.

   An app whose slots fit the bar at every width says so with `keep-in-bar`
   on <tera-shell>: they stay in the bar on a phone, there is no "More", and
   making them fit is the app's. A page tera renders has no host to mark. */

:host { display: block; position: sticky; top: 0; z-index: 50; }

.tera-shell, .tera-shell * { box-sizing: border-box; }

.tera-shell {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 6px;
  height: 52px; padding: 0 14px;
  background: var(--tera-raised); border-bottom: 1px solid var(--tera-hairline);
  color: var(--tera-surface-fg);
  font: 400 14px/1.5 var(--tera-font-ui); letter-spacing: normal; text-align: left;
  -webkit-font-smoothing: antialiased;
}

/* What a button and a link are in the shell, whatever the page's base styles say. */
.tera-shell-home, .tera-shell-switch, .tera-shell-more, .tera-shell-me, .tera-shell-app-row, .tera-shell-row, .tera-shell-seg > button {
  display: flex; align-items: center; margin: 0;
  border: 0; background: none; box-shadow: none; color: inherit;
  font: inherit; text-decoration: none; text-align: left; white-space: nowrap;
  cursor: pointer; transform: none;
}
.tera-shell-home:focus-visible, .tera-shell-switch:focus-visible, .tera-shell-more:focus-visible, .tera-shell-me:focus-visible,
.tera-shell-app-row:focus-visible, .tera-shell-row:focus-visible, .tera-shell-seg > button:focus-visible {
  outline: 2px solid var(--tera-focus); outline-offset: 2px;
}

.tera-shell-home { height: auto; padding: 4px 6px; border-radius: 8px; color: var(--tera-brand); cursor: default; }
a.tera-shell-home { cursor: pointer; }
a.tera-shell-home:hover { background: var(--tera-hover); }
/* On tera's front page the name is the current page, lit as a nav link is. */
a.tera-shell-home[aria-current="page"] { background: var(--tera-hover); }
.tera-shell-home > b { font-size: 19px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; }
.tera-shell-slash { margin: 0 2px; color: var(--tera-hairline); font-size: 22px; font-weight: 300; line-height: 1; }

.tera-shell-switch { gap: 8px; min-width: 0; height: 34px; padding: 0 8px 0 5px; border-radius: 8px; font-size: 14px; font-weight: 650; }
/* Squeezed, the app's title gives way first, before the nav or the actions. */
.tera-shell-app { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tera-shell-switch:hover, .tera-shell-switch[aria-expanded="true"],
.tera-shell-more:hover, .tera-shell-more[aria-expanded="true"],
.tera-shell-me:hover, .tera-shell-me[aria-expanded="true"] { background: var(--tera-hover); }
/* A menu's button stays lit while its menu is open, with or without the script. */
.tera-shell-switch:has(~ .tera-shell-pop[data-pop="apps"]:popover-open),
.tera-shell:has(> .tera-shell-overflow:popover-open) > .tera-shell-more,
.tera-shell-me:has(~ .tera-shell-pop[data-pop="account"]:popover-open) { background: var(--tera-hover); }
.tera-shell-tile {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 6px;
  background: var(--tera-running); color: var(--tera-running-fg);
  font-size: 12px; font-weight: 750; line-height: 1;
}
svg.tera-shell-tile { padding: 3px; }
/* An app's icon is an `<img alt="">` over the tile's letter (ADR-186 D8
   Amendment 1). It is sized only by the tile's height and its own aspect
   ratio, bounded by the tile's width and contained, so it fills the tile
   inside its radius and paints the tile's background over the letter. An
   image that fails to load has no aspect ratio and so no box: it draws
   nothing, and the tile is its letter, with no script. Every tile is
   positioned, icon or not, so a tile whose image failed is painted exactly
   as one that never had an image: Chromium antialiases a positioned box's
   rounded corner at a fractional offset otherwise than an unpositioned one's. */
.tera-shell-tile { position: relative; }
.tera-shell-tile > img {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  height: 100%; max-width: 100%; object-fit: contain;
  border-radius: inherit; background: inherit;
}
.tera-shell-caret { flex: none; color: var(--tera-muted); }

.tera-shell-nav { display: flex; flex: none; align-items: center; gap: 2px; margin-left: 14px; }
/* A slotted link stays in the app's light DOM, where the page's own CSS
   beats `::slotted()` for every property it sets, whatever its layer or
   specificity. These rules are the look of a link with no class, which the
   kit's base styles leave alone; a link that must keep the look under an
   app's reset (Tailwind's preflight) carries `.tera-shell-link`, the same
   look in tera-ui.css, which an app's own layers still override. */
.tera-shell-nav > a, ::slotted(a[slot="nav"]) {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 7px; color: var(--tera-muted); font-size: 13.5px; font-weight: 550; text-decoration: none; white-space: nowrap;
}
.tera-shell-nav > a:hover, ::slotted(a[slot="nav"]:hover) { background: var(--tera-hover); color: var(--tera-surface-fg); }
.tera-shell-nav > a[aria-current="page"], ::slotted(a[slot="nav"][aria-current="page"]) { background: var(--tera-hover); color: var(--tera-surface-fg); font-weight: 600; }
.tera-shell-spacer { flex: 1; }
.tera-shell-actions { display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.tera-shell-nav[hidden], .tera-shell-actions[hidden] { display: none; }

/* The nav and the actions, in the bar while it is wide: the box is no box. */
.tera-shell-overflow { display: contents; color: inherit; }
.tera-shell-more {
  display: none; place-items: center; flex: none; width: 36px; height: 36px; padding: 0;
  border-radius: 8px; color: var(--tera-muted); anchor-name: --tera-shell-more;
}

.tera-shell-me { gap: 8px; height: 38px; padding: 0 5px; border-radius: 10px; }
.tera-shell-me > .tera-shell-caret { display: none; }
.tera-shell-avatar {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--tera-running); color: var(--tera-running-fg);
  font-size: 11px; font-weight: 750; line-height: 1;
}
.tera-shell-avatar[data-size="lg"] { width: 38px; height: 38px; font-size: 14px; }
/* The person is their avatar at every width: the name is in the account menu.
   It is clipped, not removed, so the button keeps its accessible name. */
.tera-shell-name {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* The menus. */
.tera-shell-pop, .tera-shell-overflow:popover-open {
  position: fixed; inset: auto; top: 48px; margin: 0; padding: 6px;
  max-height: calc(100vh - 64px); overflow: auto;
  border: 1px solid var(--tera-hairline); border-radius: 12px;
  background: var(--tera-raised); color: var(--tera-surface-fg); box-shadow: var(--tera-pop-shadow);
  font: 400 14px/1.5 var(--tera-font-ui);
}
.tera-shell-pop:not(:popover-open) { display: none; }
.tera-shell-pop[data-pop="apps"] { left: 92px; width: 360px; }
.tera-shell-pop[data-pop="account"] { right: 12px; width: 300px; }
.tera-shell-overflow:popover-open { display: grid; right: 12px; width: min(280px, calc(100vw - 24px)); }
.tera-shell-switch { anchor-name: --tera-shell-switch; }
.tera-shell-me { anchor-name: --tera-shell-me; }
@supports (position-anchor: --tera-shell-switch) {
  .tera-shell-pop[data-pop="apps"] { position-anchor: --tera-shell-switch; top: calc(anchor(bottom) + 3px); left: calc(anchor(left) - 18px); }
  .tera-shell-pop[data-pop="account"] { position-anchor: --tera-shell-me; top: calc(anchor(bottom) + 3px); right: max(12px, calc(anchor(right) - 2px)); }
  .tera-shell-overflow:popover-open { position-anchor: --tera-shell-more; top: calc(anchor(bottom) + 3px); right: max(12px, calc(anchor(right) - 2px)); }
}

.tera-shell-pop-title {
  margin: 8px 10px 6px; color: var(--tera-muted);
  font: 650 11px/1.4 var(--tera-font-ui); letter-spacing: .06em; text-transform: uppercase;
}
.tera-shell-app-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 8px 10px; border-radius: 8px; white-space: normal; }
.tera-shell-app-row:hover { background: var(--tera-hover); }
.tera-shell-app-row[aria-current="page"] { background: color-mix(in oklab, var(--tera-running) 35%, transparent); }
.tera-shell-app-row > .tera-shell-tile { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.tera-shell-app-text { display: grid; min-width: 0; }
.tera-shell-app-title { font-size: 13.5px; font-weight: 600; }
.tera-shell-app-summary { color: var(--tera-muted); font-size: 12px; }
.tera-shell-check { color: var(--tera-muted); }
.tera-shell-sep { height: 0; margin: 6px 4px; border: 0; border-top: 1px solid var(--tera-hairline); }
.tera-shell-pop-foot { margin: 0; padding: 6px 10px 4px; color: var(--tera-muted); font-size: 12px; }

.tera-shell-who { display: flex; align-items: center; gap: 10px; padding: 10px 10px 8px; }
.tera-shell-who-text { display: grid; min-width: 0; }
.tera-shell-who-name { font-size: 14px; font-weight: 700; }
.tera-shell-who-email { overflow: hidden; color: var(--tera-muted); font-size: 12px; line-height: 1.75; text-overflow: ellipsis; }
.tera-shell-row { gap: 10px; width: 100%; height: auto; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.tera-shell-row:hover { background: var(--tera-hover); }
.tera-shell-row > svg { flex: none; color: var(--tera-muted); }

.tera-shell-appearance { display: grid; gap: 8px; margin: 0; padding: 6px 10px 8px; }
.tera-shell-pref { display: grid; gap: 4px; }
.tera-shell-pref-label { color: var(--tera-muted); font-size: 12px; }
.tera-shell-seg { display: flex; overflow: hidden; border: 1px solid var(--tera-field-border); border-radius: 7px; }
.tera-shell-seg > button {
  flex: 1; justify-content: center; height: 28px; padding: 0 8px; border-radius: 0;
  background: var(--tera-control); color: var(--tera-control-fg); font-size: 12px; font-weight: 600;
}
.tera-shell-seg > button + button { border-left: 1px solid var(--tera-field-border); }
.tera-shell-seg > button:hover { background: color-mix(in oklab, var(--tera-control), var(--tera-control-fg) 8%); }
.tera-shell-seg > button[aria-pressed="true"] { background: var(--tera-accent); color: var(--tera-accent-fg); }
.tera-shell-seg > button:focus-visible { outline-offset: -2px; }

/* The "More" menu: the app's pages as rows, its actions under them. */
.tera-shell-overflow:popover-open > .tera-shell-nav:not([hidden]) { display: grid; gap: 2px; margin: 0; }
.tera-shell-overflow:popover-open > .tera-shell-nav > a, .tera-shell-overflow:popover-open ::slotted(a[slot="nav"]) { height: 36px; font-size: 14px; }
.tera-shell-overflow:popover-open > .tera-shell-spacer { display: none; }
.tera-shell-overflow:popover-open > .tera-shell-actions:not([hidden]) { display: grid; gap: 6px; margin: 0; padding: 4px; }
.tera-shell-overflow:popover-open > .tera-shell-nav:not([hidden]) ~ .tera-shell-actions:not([hidden]) {
  margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--tera-hairline);
}

/* An app that fits its own slots measures the bar's real width, so the
   switcher never gives way under them. */
:host([keep-in-bar]) .tera-shell-switch { flex: none; }

/* Narrowing, on a phone the bar gives up the app's title (its tile stays) and
   the nav and actions, which move into "More". A name the bar stops showing is
   clipped, not removed, so each button keeps its accessible name. */
@media (max-width: 720px) {
  .tera-shell { gap: 4px; padding: 0 10px; }
  .tera-shell-app {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .tera-shell-me { margin-left: auto; }
  .tera-shell-overflow:not(:popover-open) { display: none; }
  .tera-shell-more:not([hidden]) { display: grid; margin-left: auto; }
  .tera-shell-more:not([hidden]) ~ .tera-shell-me { margin-left: 0; }
  /* An app that fits its own slots says so, and they stay in the bar. */
  :host([keep-in-bar]) .tera-shell-overflow:not(:popover-open) { display: contents; }
  :host([keep-in-bar]) .tera-shell-more:not([hidden]) { display: none; }
  :host([keep-in-bar]) .tera-shell-me { margin-left: 0; }
  .tera-shell-pop[data-pop="apps"] { left: 10px; width: min(360px, calc(100vw - 20px)); }
  .tera-shell-pop[data-pop="account"] { width: min(300px, calc(100vw - 20px)); }
}
/* What an app that fits its own slots gives up early, while the bar still has
   room to spare, so no later rule hands room back and the slots never win back
   what they parked as the bar narrows. */
@media (max-width: 960px) {
  :host([keep-in-bar]) .tera-shell-app {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  :host([keep-in-bar]) .tera-shell-switch { padding: 0 3px; }
  :host([keep-in-bar]) .tera-shell-switch > .tera-shell-caret { display: none; }
  :host([keep-in-bar]) .tera-shell-slash { margin: 0; }
  :host([keep-in-bar]) .tera-shell-nav { margin-left: 4px; }
  :host([keep-in-bar]) .tera-shell-actions { margin-right: 0; }
}

}
