/* The app switcher. Uses only the shared token names (packages/theme/TOKENS.md),
   so it takes on each app's palette. The button inherits the app's brand styling. */
.cn-switcher { position: relative; min-width: 0; }
.cn-switcher-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: 100%;
  margin: -4px -6px;
  padding: 4px 6px;
  border: none;
  border-radius: 7px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cn-switcher-button:hover, .cn-switcher-button[aria-expanded="true"] { background: var(--hover); }
.cn-switcher-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.cn-switcher-caret { flex: none; color: var(--muted); }

.cn-switcher-menu {
  position: absolute;
  z-index: 100;
  top: calc(100% + 8px);
  left: -6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 220px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--elevated);
  box-shadow: var(--pop-shadow);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: normal;
}
.cn-switcher-menu[hidden] { display: none; }
.cn-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
a.cn-switcher-item:hover, a.cn-switcher-item:focus-visible { outline: none; background: var(--hover); }
.cn-switcher-item .cn-app-icon { flex: none; color: var(--muted); }
.cn-switcher-item.current .cn-app-icon { color: var(--accent); }
.cn-switcher-name { flex: 1; }
.cn-switcher-check { color: var(--accent); }
.cn-switcher-item.soon { color: var(--faint); cursor: default; }
.cn-switcher-item.soon .cn-app-icon { color: var(--faint); }
.cn-switcher-soon { color: var(--faint); font-size: 11.5px; }
.cn-switcher-sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* The app bar: on a phone, every app along the bottom of the screen (wider screens use the
   switcher menu above). Pages leave room for it with padding-bottom: var(--cn-appbar-h). */
:root { --cn-appbar-h: 0px; }
.cn-appbar { display: none; }
@media (max-width: 820px) {
  :root { --cn-appbar-h: calc(58px + env(safe-area-inset-bottom)); }
  .cn-appbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    height: var(--cn-appbar-h);
    padding: 4px 4px env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    font-family: var(--font);
  }
  .cn-appbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    border-radius: 12px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .cn-appbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cn-appbar a[aria-current] { color: var(--accent); }
  .cn-appbar a[aria-current] .cn-app-icon { stroke-width: 2.2; }
  .cn-appbar a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -3px; }
  body:has(> .cn-appbar) { padding-bottom: var(--cn-appbar-h); }
}

/* Phones: the section tabs slide away while scrolling down (switcher.js). The masthead moves up by
   the tabs' height while what's beside them moves back down, so only the tabs leave. */
@media (max-width: 820px) {
  .cn-tabs-slide .masthead, .cn-tabs-slide .masthead .cn-keep, .cn-tabs-slide .masthead .tabs {
    transition: transform 0.22s cubic-bezier(.2,.8,.2,1), opacity 0.16s;
  }
  .cn-tabs-away .masthead { transform: translateY(calc(-1 * var(--cn-tabs-h, 0px))); }
  .cn-tabs-away .masthead .cn-keep { transform: translateY(var(--cn-tabs-h, 0px)); }
  .cn-tabs-away .masthead .tabs { opacity: 0; pointer-events: none; }
}
@media (max-width: 820px) and (prefers-reduced-motion: reduce) {
  .cn-tabs-slide .masthead, .cn-tabs-slide .masthead .cn-keep, .cn-tabs-slide .masthead .tabs { transition: none; }
}
