/* The header's library segment and the slim secondary navigation (2026-11-23).

   Per-viewer library colours: .lib-color-N sets --lib-accent and its paired text colour --lib-on-accent from the switcher
   palette in tokens.css (--lib-color-N / --lib-ink-N). The palette is used ONLY here: the segment, the colour dots in
   the menu and calendar, and the underline and hairline of the secondary navigation. Never the ribbon colours.

   Row 1 inside a library: the wordmark's box becomes the segment. A hidden copy of the wordmark (.library-segment__sizer)
   gives the segment the wordmark's own width at every width where the wordmark shows, so the ribbon, Quick add and the
   avatar do not move. Below 45rem the wordmark is gone, so the segment takes what the ribbon's gap leaves (the ribbon is
   decoration and yields first); the name ellipsises, and Quick add keeps its label. */
.lib-color-1 { --lib-accent: var(--lib-color-1); --lib-on-accent: var(--lib-ink-1); }
.lib-color-2 { --lib-accent: var(--lib-color-2); --lib-on-accent: var(--lib-ink-2); }
.lib-color-3 { --lib-accent: var(--lib-color-3); --lib-on-accent: var(--lib-ink-3); }
.lib-color-4 { --lib-accent: var(--lib-color-4); --lib-on-accent: var(--lib-ink-4); }
.lib-color-5 { --lib-accent: var(--lib-color-5); --lib-on-accent: var(--lib-ink-5); }
.lib-color-6 { --lib-accent: var(--lib-color-6); --lib-on-accent: var(--lib-ink-6); }
.lib-color-7 { --lib-accent: var(--lib-color-7); --lib-on-accent: var(--lib-ink-7); }
.lib-color-8 { --lib-accent: var(--lib-color-8); --lib-on-accent: var(--lib-ink-8); }

.library-dot {
  display: inline-block;
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--lib-accent);
}

@media screen {
  .member-shell .member-nav__brand--library {
    --seg-pl: 18px;
    --seg-pr: 16px;
    --seg-slant: 16px;
  }

  .member-shell .member-nav__logo {
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex: none;
    border-radius: 50%;
  }

  .member-shell .member-nav__logo:focus-visible {
    outline: 2px solid var(--chrome-focus);
    outline-offset: 2px;
  }

  .member-shell .library-segment {
    position: relative;
    z-index: 1;
    display: flex;
    align-self: stretch;
    min-width: 0;
    /* The segment runs to the zone's slanted right edge (the zone reaches pad-end past the wordmark). */
    margin-right: calc(var(--member-zone-pad-end) * -1);
  }

  .member-shell .library-segment__button {
    position: relative;
    isolation: isolate;
    box-sizing: border-box;
    display: block;
    height: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0 var(--seg-pr) 0 var(--seg-pl);
    border: 0;
    border-radius: 0;
    color: var(--lib-on-accent);
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  /* The coloured shape is a layer behind the button, so the focus ring (on the button) is never clipped by the slant. */
  .member-shell .library-segment__button::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    background: var(--lib-accent);
    clip-path: polygon(var(--seg-slant) 0, 100% 0, calc(100% - var(--seg-slant)) 100%, 0 100%);
  }

  .member-shell .library-segment__button:hover::before,
  .member-shell .library-segment__button[aria-expanded="true"]::before { filter: brightness(1.08); }

  .member-shell .library-segment__button:focus-visible {
    outline: 2px solid var(--chrome-focus);
    outline-offset: -4px;
  }

  .member-shell .library-segment__sizer.member-nav__brand-label {
    display: block;
    height: 0;
    visibility: hidden;
    overflow: hidden;
    margin-right: calc(var(--member-zone-pad-end) - var(--seg-pl) - var(--seg-pr));
  }

  .member-shell .library-segment__face {
    position: absolute;
    inset: 0;
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.45rem;
    padding: 0 var(--seg-pr) 0 var(--seg-pl);
  }

  .member-shell .library-segment__name {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .member-shell .library-segment .library-switcher__chevron {
    width: 0.5rem;
    height: 0.5rem;
    margin-top: -0.2rem;
    border-color: var(--lib-on-accent);
  }

  .member-shell .library-segment .library-switcher__button[aria-expanded="true"] .library-switcher__chevron {
    margin-top: 0.15rem;
  }

  /* The menu: a chrome panel like the account menu. */
  .member-shell .library-segment .library-switcher__menu {
    top: calc(100% - 0.35rem);
    left: 0;
    z-index: 330;
    width: min(20rem, calc(100vw - 1.5rem));
    border: 1px solid var(--chrome-outline);
    color: var(--chrome-ink);
    background: var(--chrome-raised);
    box-shadow: 0 8px 18px var(--chrome-shadow);
  }

  .member-shell .library-segment .library-switcher__item {
    gap: 0.6rem;
    color: var(--chrome-ink);
    background: var(--chrome-raised);
    font-family: var(--font-ui);
    font-weight: 600;
  }

  .member-shell .library-segment .library-switcher__item:hover { background: var(--chrome-raised-hover); }

  .member-shell .library-segment .library-switcher__item[aria-current="page"] {
    border-color: transparent;
    color: var(--chrome-ink-strong);
    background: var(--chrome-raised-hover);
  }

  .member-shell .library-segment .library-switcher__item:focus-visible { outline: 2px solid var(--chrome-focus); outline-offset: -2px; }

  .member-shell .library-switcher__item-name { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .member-shell .library-segment .library-switcher__item[aria-current="page"]::after {
    content: "\2713" / "";
    flex: none;
  }

  .member-shell .library-switcher__divider {
    height: 0;
    margin: 0.3rem 0.4rem;
    border-top: 1px solid var(--chrome-rule);
  }

  .member-shell .library-segment__hint {
    position: absolute;
    z-index: 320;
    top: calc(100% + 0.5rem);
    left: 0;
    display: grid;
    width: min(18rem, calc(100vw - 1.5rem));
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--chrome-outline);
    border-radius: 0.5rem;
    color: var(--chrome-ink);
    background: var(--chrome-raised);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 400;
  }

  .member-shell .library-segment__hint[hidden] { display: none; }

  .member-shell .library-segment__hint-dismiss {
    justify-self: start;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid var(--chrome-outline);
    border-radius: 0.4rem;
    color: var(--chrome-ink);
    background: var(--chrome-raised);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }
}

/* Phone: the wordmark is gone below 45rem, so the segment takes the room the ribbon's gap leaves and shrinks to fit. The
   only permitted yield is the name's size (14px); the ribbon, Quick add and the avatar keep their place. */
@media screen and (max-width: 44.99rem) {
  .member-shell .member-nav__brand--library {
    --seg-pl: 16px;
    --seg-pr: 10px;
    flex: 1 1 0;
    min-width: 0;
  }

  /* No overlap into the ribbon's gap here (it is only 8px on a phone): the segment must never paint over the links box. */
  .member-shell .library-segment { flex: 1 1 0; margin-right: 0; }
  .member-shell .library-segment__button { width: 100%; }
  .member-shell .library-segment__sizer.member-nav__brand-label { display: none; }
  .member-shell .library-segment__name { font-size: 0.875rem; }

  .member-shell .library-segment .library-switcher__menu {
    position: fixed;
    top: calc(var(--member-bar-height) + 0.4rem);
    left: 0.75rem;
    width: calc(100vw - 1.5rem);
  }

  .member-shell .library-segment__hint {
    position: fixed;
    top: calc(var(--member-bar-height) + 0.4rem);
    left: 0.75rem;
  }
}

/* THE SECONDARY NAVIGATION (all three modes): slimmer than before, 40px on a desktop, a 44px tap box on a phone. It sits
   on the same charcoal as the header, so the library colour is guaranteed 5:1 against it in both appearances. The active
   tab is brighter and bolder (aria-current carries it; the underline is an enhancement), with a 2px underline in the
   library colour inside a library and in neutral off-white elsewhere, plus a hairline in the library colour under the row. */
@media screen {
  .member-shell--slim-strip { --library-strip-height: 2.5rem; }

  .member-shell .library-strip--nav {
    --nav-line: var(--chrome-ink);
    /* Position comes from context_bar.css: fixed under the bar; it also anchors the phone More menu. */
    box-sizing: border-box;
    max-width: 100vw;
    min-height: 2.5rem;
    height: 2.5rem;
    padding-top: 0;
    padding-bottom: 0;
    gap: 0;
    border-bottom: 1px solid var(--nav-line);
    color: var(--chrome-ink-dim);
    background: var(--chrome-bg);
  }

  .member-shell .library-strip--nav[class*="lib-color-"] { --nav-line: var(--lib-accent); }

  .member-shell .library-strip--nav .library-strip__tabs {
    height: 100%;
    gap: 0.25rem;
    /* Room on the right for future links: the row scrolls (or folds into More later), it never wraps. */
    scrollbar-width: none;
  }

  .member-shell .library-strip--nav .library-strip__tab {
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    padding: 0 0.7rem;
    border-bottom: 2px solid transparent;
    color: var(--chrome-ink-dim);
    background: var(--chrome-bg);
    font-size: 0.875rem;
    font-weight: 400;
  }

  .member-shell .library-strip--nav .library-strip__tab:hover { color: var(--chrome-ink-strong); background: var(--chrome-bg); }

  .member-shell .library-strip--nav .library-strip__tab[aria-current="page"] {
    border-bottom-color: var(--nav-line);
    color: var(--chrome-ink-strong);
    background: var(--chrome-bg);
    font-weight: 700;
  }

  .member-shell .library-strip--nav .library-strip__tab:focus-visible {
    outline: 2px solid var(--chrome-focus);
    outline-offset: -4px;
  }

  .member-shell .library-strip--nav .library-strip__more { display: none; }
}

@media screen and (max-width: 44.99rem) {
  .member-shell--slim-strip { --library-strip-height: 2.75rem; }

  .member-shell .library-strip--nav { min-height: 2.75rem; height: 2.75rem; padding: 0 0 0 1rem; flex-wrap: nowrap; }

  .member-shell .library-strip--nav .library-strip__tabs {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    flex-basis: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .member-shell .library-strip--nav .library-strip__tabs::-webkit-scrollbar { display: none; }

  .member-shell .library-strip--nav .library-strip__tab:nth-of-type(n + 5) { display: none; }

  .member-shell .library-strip--nav .library-strip__more {
    display: block;
    flex: none;
  }

  .member-shell .library-strip--nav .library-strip__tab { padding-inline: 0.5rem; }

  .member-shell .library-strip--nav .library-strip__more-summary {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.5rem;
    border-bottom: 2px solid transparent;
    color: var(--chrome-ink-dim);
    background: var(--chrome-bg);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 400;
    list-style: none;
    white-space: nowrap;
  }

  .member-shell .library-strip--nav .library-strip__more-summary::-webkit-details-marker { display: none; }

  .member-shell .library-strip--nav .library-strip__more-summary--current {
    border-bottom-color: var(--nav-line);
    color: var(--chrome-ink-strong);
    background: var(--chrome-bg);
    font-weight: 700;
  }

  .member-shell .library-strip--nav .library-strip__more-summary:focus-visible {
    outline: 2px solid var(--chrome-focus);
    outline-offset: -4px;
  }

  .member-shell .library-strip--nav .library-strip__more-menu {
    position: absolute;
    z-index: 330;
    top: calc(100% + 0.25rem);
    right: 0;
    display: grid;
    width: min(14rem, calc(100vw - 1.5rem));
    padding: 0.25rem;
    border: 1px solid var(--chrome-outline);
    border-radius: 0.4rem;
    color: var(--chrome-ink);
    background: var(--chrome-raised);
    box-shadow: 0 8px 18px var(--chrome-shadow);
  }

  .member-shell .library-strip--nav .library-strip__more:not([open]) .library-strip__more-menu { display: none; }

  .member-shell .library-strip--nav .library-strip__more-item {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding: 0 0.7rem;
    border-radius: 0.3rem;
    color: var(--chrome-ink);
    background: var(--chrome-raised);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
  }

  .member-shell .library-strip--nav .library-strip__more-item:hover,
  .member-shell .library-strip--nav .library-strip__more-item[aria-current="page"] {
    color: var(--chrome-ink-strong);
    background: var(--chrome-raised-hover);
  }

  .member-shell .library-strip--nav .library-strip__more-item:focus-visible {
    outline: 2px solid var(--chrome-focus);
    outline-offset: -2px;
  }
}
