/* Page frame: base type, the navigation rail and the main column.
   Colours come only from tokens.css. */

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

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

body {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100dvh;
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 500 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

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

.ui-skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--btn);
  color: var(--btn-ink);
  font-weight: 700;
}

.ui-skip:focus {
  top: 12px;
}

/* ---- Rail ---- */

bl-shell {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 30px;
  align-self: start;
  height: 100dvh;
  padding: 22px 18px 16px;
  border-right: 1px solid var(--hair);
  overflow-y: auto;
}

.ui-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.ui-brand i {
  flex: none;
  width: 34px;
  height: 34px;
  background: var(--mark) center / contain no-repeat;
}

.ui-brand b {
  display: block;
  font: 800 14px/1 var(--sans);
  letter-spacing: 0.14em;
}

.ui-brand small {
  display: block;
  margin-top: 6px;
  color: var(--text-3);
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Opens the command bar; reads like an empty field so it is found without the shortcut. */
.ui-find {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: none;
  color: var(--text-3);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.ui-find:hover {
  border-color: var(--line);
  color: var(--text);
}

.ui-find svg {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.ui-find span,
.ui-find kbd {
  white-space: nowrap;
}

.ui-find span {
  letter-spacing: 0.04em;
}

/* "Ctrl K" is wider than "⌘K"; it must still fit the rail beside the label. */
.ui-find kbd {
  margin-left: auto;
  font: 500 10px/1 var(--mono);
  letter-spacing: 0;
}

.ui-nav {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ui-nav-group {
  display: grid;
  gap: 2px;
}

.ui-nav-group > span {
  margin-bottom: 6px;
  color: var(--text-3);
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.ui-nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  margin: 0 -18px;
  padding: 0 18px 0 16px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.ui-nav a:hover {
  background: var(--panel);
  color: var(--text);
}

.ui-nav a[aria-current="page"] {
  border-left-color: var(--accent);
  background: var(--panel);
  color: var(--text);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: auto;
}

.ui-theme,
.ui-action {
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--text-3);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.ui-theme:hover,
.ui-action:hover {
  color: var(--text);
}

/* ---- Main column ---- */

.ui-main {
  width: 100%;
  min-width: 0;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  padding: 30px var(--gutter) 72px;
}

.ui-main:focus {
  outline: 0;
}

/* ---- Phones and narrow windows: the rail becomes a header with a scrolling strip ---- */

@media (max-width: 900px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  bl-shell {
    z-index: 5;
    flex-flow: row wrap;
    align-items: center;
    gap: 0 12px;
    height: auto;
    padding: 10px var(--gutter) 0;
    border-right: 0;
    border-bottom: 1px solid var(--hair);
    background: var(--ground);
    overflow: visible;
  }

  .ui-brand {
    flex: 1;
  }

  .ui-brand small {
    display: none;
  }

  /* A phone header holds search, BleendAI, the inbox, lock and theme; the monogram alone names the studio. */
  @media (max-width: 480px) {
    .ui-brand b {
      display: none;
    }
  }

  .top-actions {
    margin: 0;
  }

  /* No room for words in the header strip, and phones have no shortcut to show. */
  .ui-find {
    width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
  }

  .ui-find span,
  .ui-find kbd {
    display: none;
  }

  .ui-nav {
    flex: 0 0 calc(100% + var(--gutter) * 2);
    flex-direction: row;
    gap: 2px;
    order: 3;
    margin: 6px calc(var(--gutter) * -1) 0;
    padding: 0 var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .ui-nav::-webkit-scrollbar {
    display: none;
  }

  /* Groups only matter in the tall rail; in the strip every link sits in one row. */
  .ui-nav-group {
    display: contents;
  }

  .ui-nav-group > span {
    display: none;
  }

  .ui-nav a {
    flex: none;
    min-height: 44px;
    margin: 0;
    padding: 0 12px;
    border-bottom: 2px solid transparent;
    border-left: 0;
  }

  .ui-nav a:hover,
  .ui-nav a[aria-current="page"] {
    background: none;
  }

  .ui-nav a[aria-current="page"] {
    border-bottom-color: var(--accent);
  }

  .ui-main {
    padding-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
