/* The hub: the sidebar of what's going on, and the pane with the open app. */

html,
body {
  height: 100%;
  overflow: hidden;
}
.hub {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  transition: opacity 0.2s ease;
}
/* Out of sight until hub.js has drawn the sidebar's skeleton (Start), so it
   never shows empty. If the script never gets there, it shows anyway after
   4 seconds. */
html.booting .hub {
  opacity: 0;
  animation: hub-show 0s 4s forwards;
}
@keyframes hub-show {
  to {
    opacity: 1;
  }
}
body[data-motion="off"] .hub {
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  .hub {
    transition: none;
  }
}

/* --- Sidebar ------------------------------------------------------------------ */

.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--shade) 16%, transparent);
}
:root[data-theme="light"] .side {
  background: color-mix(in srgb, var(--paper) 45%, transparent);
}
/* The logo sits in the middle of the sidebar. */
.side-head {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 66px;
  padding: 14px 12px 6px;
}
/* The logo opens Björn, like his row. It's Björn's own logo, drawn in the
   accent colour through a mask, as in the Björn app's nav. */
.side-head .brand {
  width: 78px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--accent);
  box-shadow: none;
  cursor: pointer;
  -webkit-mask: url("/shared/img/logo.svg") no-repeat center / contain;
  mask: url("/shared/img/logo.svg") no-repeat center / contain;
}
.side-head .brand:hover:not(:disabled) {
  background: var(--accent);
  opacity: 1;
}
/* Under the logo, a tab for each host that starts something new, with a line
   beneath and the app open in the pane underlined. */
.start-tabs {
  display: flex;
  margin-bottom: 10px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
}
.start-tabs button {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px 9px;
  border-radius: calc(0.4em * var(--brm)) calc(0.4em * var(--brm)) 0 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 600;
}
.start-tabs button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--paper) 40%, transparent);
  color: var(--ink);
  opacity: 1;
}
.start-tabs button.on {
  color: var(--ink);
}
.start-tabs button.on::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
/* Björn's search (the command palette's): a faint border; the fill follows
   its inputs, white at 0.4, 0.6 on hover, 0.8 with focus. */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 14px 10px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--ink) 5%, transparent);
  border-radius: calc(0.5em * var(--brm));
  corner-shape: superellipse(1.4);
  background: color-mix(in srgb, var(--paper) 40%, transparent);
  color: var(--ink-3);
  transition: background 200ms ease;
}
.search:hover {
  background: color-mix(in srgb, var(--paper) 60%, transparent);
}
.search input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.search:focus-within {
  background: color-mix(in srgb, var(--paper) 80%, transparent);
}

.rows {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 12px;
  scrollbar-width: thin;
}
.row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9.5px 10.5px;
  /* The highlight is drawn inside a clear 2px edge, so neighbouring rows show
     a gap between their highlights, but the edge still belongs to the row:
     no dead zone for the pointer between rows. */
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: calc(0.5em * var(--brm));
  corner-shape: superellipse(1.4);
  color: inherit;
  text-decoration: none;
  transition:
    background-color 150ms ease,
    transform 0.2s;
}
/* Björn's lists (the word manager's decks): white at 0.4 on hover, solid
   white for the open one; a press shrinks a little, as in its pickers. */
.row:hover {
  background-color: color-mix(in srgb, var(--paper) 40%, transparent);
}
.row.on {
  background-color: var(--paper);
}
/* The light sidebar is already paper-tinted, so paper alone barely shows:
   the open row takes the warmer UI tone, as the light mode switch does. */
:root[data-theme="light"] .row.on {
  background-color: color-mix(in srgb, var(--ui) 70%, transparent);
}
.row:active {
  transform: scale(0.995);
}
/* The rows' skeleton (hub.js, paintSkeleton) isn't something to point at. */
.row.row-sk {
  pointer-events: none;
}
.row {
  position: relative;
}
/* "⋯": pin, hide, delete. Shows on hover, over the time. */
.row-more {
  transition: opacity 0.15s;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  /* A small top control: colorUI with the bevel. */
  background: var(--ui);
  box-shadow: var(--bevel);
}
.row:hover .row-more,
.row-more:focus-visible {
  opacity: 1;
}
.row-top time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s;
}
/* The "⋯" button sits over the time: the time fades out to make room. */
.row:hover .row-top time,
.row:focus-within .row-top time {
  opacity: 0;
}
.row-top .pin {
  color: var(--ink-3);
}
.row.after-pins {
  margin-top: 13px;
}
.row.after-pins::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 12px;
  right: 12px;
  border-top: 1px solid var(--line);
}

/* Dragging a row to pin it where it's dropped. */
.row.dragging {
  opacity: 0.4;
}
.row.drop-before::after,
.row.drop-after::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.row.drop-before::after {
  top: -2px;
}
.row.drop-after::after {
  bottom: -2px;
}

.row-menu {
  position: fixed;
  z-index: 60;
  min-width: 230px;
}
.row-menu button.danger,
.modal-actions .danger {
  color: var(--bad);
}
.modal-actions .primary.danger {
  background: var(--bad);
  color: var(--on-accent);
}
/* Just started from a tab, with nothing to save yet. */
.row.fresh {
  outline: 1.5px dashed color-mix(in srgb, var(--ink) 24%, transparent);
  outline-offset: -2px;
  background-color: transparent;
  animation: row-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.row.fresh.on {
  background-color: color-mix(in srgb, var(--ink) 4%, transparent);
}
.row.fresh .char {
  opacity: 0.55;
  filter: saturate(0.6);
}
.row.fresh.on .char-alive {
  opacity: 1;
  filter: none;
}
.row.fresh .row-preview {
  color: var(--ink-3);
  font-style: italic;
}
@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.row-avatar {
  position: relative;
  display: grid;
  flex: none;
}
.row-avatar .dot {
  position: absolute;
  top: -1px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 2.5px var(--grad-l);
}
.row-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.row-top b {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row-top time {
  flex: none;
  color: var(--ink-3);
  font-size: 12.5px;
}
.row-preview {
  color: var(--ink-2);
  font-size: 14px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row.unread .row-top b,
.row.unread .row-preview {
  color: var(--ink);
}
.row.unread .row-top b {
  font-weight: 700;
}
.row-who {
  color: var(--ink-3);
}
.rows-empty {
  padding: 20px 12px;
  color: var(--ink-3);
  font-size: 14px;
}

.side-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}
.side-foot #account {
  flex: 1;
  min-width: 0;
}
.side-foot .lang-pill {
  white-space: nowrap;
}
/* Save progress, the settings pill and the theme switch stand the same height. */
.side-foot .account-btn,
.side-foot .lang-pill,
.side-foot #theme-btn {
  height: 40px;
  font-size: 14px;
}
.side-foot .account-btn {
  padding: 0 1.1em;
  box-shadow:
    inset 0 0 3px 0 color-mix(in srgb, var(--ai) 80%, transparent),
    inset 0 -2px 0 0 var(--ai);
}
/* The theme switch wears the pill's border and fill, so it reads as the same size. */
.side-foot #theme-btn {
  width: 40px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
/* With an account the pill is the way to settings and takes the room the
   account button had. */
.side-foot #account:empty {
  display: none;
}
.side-foot .lang-pill.profile {
  flex: 1;
  min-width: 0;
  padding-right: 0.7em;
  color: var(--ink);
  cursor: pointer;
}
.lang-pill.profile .name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.lang-pill.profile .i-dots {
  margin-left: auto;
  color: var(--ink-3);
}
.lang-pill.profile:hover .i-dots {
  color: var(--ink);
}
.usage-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}
.usage-dot.out {
  background: var(--bad);
}
.me {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.me span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --- Pane ---------------------------------------------------------------------- */

.pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
/* The frames stack: the one on screen, and the next page loading behind it
   until it has drawn (hub.js, load). */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}
.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.stage iframe.behind {
  opacity: 0;
  pointer-events: none;
}
/* The page on screen reloading by itself: out quickly, in once it has drawn. */
.stage.leaving iframe {
  opacity: 0;
  transition-duration: 0.15s;
}
/* Still loading after a moment: a light runs along the top of the pane. */
.stage::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat;
  background-size: 40% 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.stage.busy::before {
  opacity: 1;
  animation: pane-progress 1.1s ease-in-out infinite;
}
@keyframes pane-progress {
  from {
    background-position: -67% 0;
  }
  to {
    background-position: 167% 0;
  }
}
body[data-motion="off"] .stage iframe {
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  .stage iframe,
  .pane,
  body.pane-open .pane,
  body.pane-open .side {
    transition: none;
  }
  .stage.busy::before {
    animation: none;
    background: var(--accent);
    opacity: 0.5;
  }
}
.pane-bar {
  display: none;
}

/* A dialog open in the page (hub.js, frame-modal): the sidebar sits behind
   the same scrim and blur as the page, so the whole window steps back. */
.side,
.pane-bar {
  position: relative;
}
body.frame-modal .side::after,
body.frame-modal .pane-bar::after,
body.frame-modal-leaving .side::after,
body.frame-modal-leaving .pane-bar::after {
  content: "";
  position: absolute;
  inset: 0 -1px 0 0;
  z-index: 20;
  background: color-mix(in srgb, var(--shade) 14%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: scrim-in 0.2s ease-out;
}
/* The dialog closing (hub.js): the sidebar's scrim fades with the page's. */
body.frame-modal-leaving:not(.frame-modal) .side::after,
body.frame-modal-leaving:not(.frame-modal) .pane-bar::after {
  pointer-events: none;
  animation: scrim-out 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes scrim-out {
  to {
    opacity: 0;
  }
}
body[data-motion="off"].frame-modal .side::after,
body[data-motion="off"].frame-modal .pane-bar::after {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  body.frame-modal .side::after,
  body.frame-modal .pane-bar::after {
    animation: none;
  }
}

/* --- Phones: the list, then the open thing full screen, like Messages ----------------- */

/* The pane slides in over the list once its page has drawn, and out again on
   "All". It stays laid out while hidden, so a page loading in it has its size. */
@media (max-width: 760px) {
  .hub {
    grid-template-columns: minmax(0, 1fr);
  }
  .pane {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: linear-gradient(111deg, var(--grad-l) 0%, var(--grad-r) 100%);
    visibility: hidden;
    transform: translateX(100%);
    transition:
      transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
      visibility 0s 0.38s;
  }
  body.pane-open .pane {
    visibility: visible;
    transform: none;
    transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  body.pane-open .side {
    visibility: hidden;
    transition: visibility 0s 0.38s;
  }
  body[data-motion="off"] .pane,
  body[data-motion="off"].pane-open .pane,
  body[data-motion="off"].pane-open .side {
    transition: none;
  }
  .pane-bar {
    display: flex;
    padding: 6px 8px 0;
  }
  .pane-bar .back {
    padding: 6px 10px;
    font-size: 15px;
  }
}
.lang-pill.profile .fluent-mark {
  flex: none;
  color: var(--accent);
}
/* A guest's pill shares the row with "Save progress", which keeps its size. */
.side-foot #account:has(.account-btn) {
  flex: none;
}

/* --- "How's it going?" ------------------------------------------------------------------ */

/* Feedback, above the footer on every page: an accent-tinted card, so it
   reads as an invitation and not as one more row. */
/* A few lines for newcomers, with the way to the public pages. Gone for
   anyone signed in or with a few things on the go (html.regular, hub.js). */
.side-about {
  margin: 0 12px 12px;
  padding: 0 4px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}
.side-about p {
  margin: 0 0 6px;
}
.side-about a {
  margin-right: 14px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.side-about a:hover {
  text-decoration: underline;
}
.regular .side-about {
  display: none;
}
.feedback-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 12px 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: calc(0.6em * var(--brm));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: none;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
}
.feedback-card:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  opacity: 1;
}
.feedback-card svg {
  flex: none;
  color: var(--accent);
}
.feedback-card span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.feedback-card b {
  font-size: 15px;
  font-weight: 700;
}
.feedback-card small {
  color: var(--ink-2);
  font-size: 13px;
}
