/* The iOS 27 top area. No header band: the wordmark is a large title on the canvas, the buttons
   float as Liquid Glass, content scrolls under a soft blurred edge, and Spaces is a glass capsule
   with a sliding lens. The glass reuses the Dock's tokens (chrome.css) so both bars match. */
:root {
  --top-glass: var(--bottom-nav-bg, oklch(1 0 0 / 0.62));
  --top-glass-shadow: var(
    --bottom-nav-shadow,
    0 0 0 0.5px oklch(0.2 0.02 260 / 0.12),
    inset 0 1px 0 oklch(1 0 0 / 0.85),
    0 14px 34px -12px oklch(0.2 0.03 260 / 0.3)
  );
  --top-blur: saturate(1.8) blur(18px);
  --top-lens: var(--bottom-nav-active-bg, oklch(0.53 0.25 263 / 0.12));
  --top-lens-text: var(--bottom-nav-active-text, oklch(0.48 0.24 263));
  --top-row: 44px;
  --top-pad: 10px;
}

/* The header is a transparent layer. It must not filter or transform, or the floating
   buttons would be positioned against it instead of the screen. */
.site-header,
[data-theme='dark'] .site-header {
  background: transparent;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.site-header .header-inner {
  position: relative;
  z-index: 31;
}

/* Liquid Glass surfaces: the button group, the Spaces capsule, the create circle and the
   desktop tab capsule. */
.top-actions,
.channel-bar nav,
.channel-tools .icon-button,
.desktop-nav {
  background: var(--top-glass);
  -webkit-backdrop-filter: var(--top-blur);
  backdrop-filter: var(--top-blur);
  box-shadow: var(--top-glass-shadow);
}
.top-actions {
  gap: 0;
  padding: 0;
  border-radius: 999px;
}
.top-actions .icon-button {
  width: var(--top-row);
  height: var(--top-row);
  min-width: var(--top-row);
  min-height: var(--top-row);
  color: var(--ink);
}
.top-actions .icon-button svg {
  width: 20px;
  height: 20px;
}
.top-actions .icon-button:hover,
[data-theme='dark'] .top-actions .icon-button:hover {
  background: color-mix(in oklch, var(--ink) 7%, transparent);
}
.top-title {
  display: none;
}
/* The avatar is a circle, like an account button. */
.site-header .brand-mark {
  border-radius: 50%;
}

/* The soft scroll edge: content blurs and fades as it passes under the floating bar. */
.top-edge {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 29;
  height: calc(env(safe-area-inset-top) + var(--top-pad) + var(--top-row) + 30px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  background: linear-gradient(
    to bottom,
    color-mix(in oklch, var(--paper) 94%, transparent) 0%,
    color-mix(in oklch, var(--paper) 70%, transparent) 58%,
    transparent 100%
  );
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
html[data-top-edge='on'] .top-edge {
  opacity: 1;
}

/* Tab capsules. The lens paints the chosen tab; until it is placed, the tab paints itself. */
.channel-bar {
  min-height: 0;
  padding-block: 2px 12px;
  gap: 10px;
}
.channel-bar nav,
.desktop-nav {
  position: relative;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
}
.channel-bar nav {
  overflow-x: auto;
  scrollbar-width: none;
}
.channel-bar nav::-webkit-scrollbar {
  display: none;
}
.channel-bar nav a,
.desktop-nav .nav-link {
  position: relative;
  z-index: 1;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: color 0.2s ease;
}
.channel-bar nav a[aria-current],
.desktop-nav .nav-link.active,
[data-theme='dark'] .desktop-nav .nav-link.active {
  color: var(--top-lens-text);
  background: var(--top-lens);
}
[data-lens-ready] > a[aria-current],
[data-lens-ready] > .nav-link.active,
[data-theme='dark'] [data-lens-ready] > .nav-link.active {
  background: transparent;
}
.channel-bar nav a[aria-current]::after {
  display: none;
}
.tab-lens {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--top-lens);
  pointer-events: none;
}
.channel-tools .icon-button {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border: 0;
  color: var(--ink);
}

/* Phones: the wordmark is a large title; the buttons float over the content. */
@media (max-width: 760px) {
  .site-header {
    position: relative;
  }
  .site-header .header-inner {
    min-height: 0;
    padding: var(--top-pad) 16px 8px;
  }
  .site-header .wordmark {
    min-height: var(--top-row);
    font-size: 27px;
    letter-spacing: -1.5px;
  }
  .site-header .wordmark small {
    font-size: 7px;
  }
  .site-header .brand-mark {
    width: var(--top-row);
    height: var(--top-row);
  }
  .top-actions {
    position: fixed;
    top: calc(env(safe-area-inset-top) + var(--top-pad));
    right: 16px;
    z-index: 31;
  }
  .top-title {
    position: fixed;
    top: calc(env(safe-area-inset-top) + var(--top-pad));
    left: 50%;
    z-index: 31;
    display: flex;
    align-items: center;
    height: var(--top-row);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.8px;
    color: var(--ink);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 6px);
    transition:
      opacity 0.22s ease,
      transform 0.22s ease;
  }
  html[data-top-title='on'] .top-title {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  .channel-bar {
    padding-inline: 16px;
  }
  .channel-bar nav {
    gap: 0;
  }
  .channel-bar nav a {
    padding: 0 12px;
    font-size: 12px;
  }
}
@media (max-width: 360px) {
  .site-header .header-inner,
  .channel-bar {
    padding-inline: 12px;
  }
  .site-header .wordmark {
    font-size: 23px;
  }
  .top-actions {
    right: 12px;
  }
}

/* Larger screens: one floating row with the wordmark, the tab capsule and the buttons. */
@media (min-width: 761px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .site-header .header-inner {
    min-height: 76px;
  }
  .top-edge {
    height: calc(env(safe-area-inset-top) + 96px);
  }
  .desktop-nav .nav-link:hover {
    color: var(--ink);
  }
}

/* Reduce transparency: every glass surface becomes solid, and the edge stops blurring. */
html[data-transparency='reduce'] :is(.top-actions, .channel-bar nav, .channel-tools .icon-button, .desktop-nav) {
  background: var(--white);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
html[data-transparency='reduce'] .top-edge {
  background: var(--paper);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  -webkit-mask-image: none;
  mask-image: none;
  height: calc(env(safe-area-inset-top) + var(--top-pad) + var(--top-row) + 8px);
}
@media (min-width: 761px) {
  html[data-transparency='reduce'] .top-edge {
    height: calc(env(safe-area-inset-top) + 76px);
  }
}
@media (prefers-reduced-transparency: reduce) {
  html:not([data-transparency]) :is(.top-actions, .channel-bar nav, .channel-tools .icon-button, .desktop-nav) {
    background: var(--white);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .top-edge,
  .top-title {
    transition: none;
  }
}
