/*
 * Header of the pack site, ported from the Unisson model (docs/pack/modeles/unisson, rules of .top and .pal). The
 * colours are the --pack-* tokens; the fonts are the model's own stacks. The base sheet of every slice styles bare
 * buttons and links: each rule here restates what the model leaves to the browser.
 */
:host {
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: block;
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-dropdown);
  color: var(--pack-ink);
  font: 16px / 1.6 var(--sans);
  letter-spacing: normal;
  font-feature-settings: normal;
  -webkit-font-smoothing: antialiased;
}
/* First, so that each control's own radius wins over the ring's, as in the model. */
:focus-visible {
  outline: 2px solid var(--pack-focus);
  outline-offset: 3px;
  border-radius: 6px;
}
[part="root"] {
  background: color-mix(in oklch, var(--pack-bg) 90%, transparent);
  border-block-end: 1px solid var(--pack-line);
}
[part="bar"] {
  display: flex;
  align-items: center;
  gap: 14px;
  min-block-size: 64px;
  flex-wrap: wrap;
  padding-block: 8px;
  inline-size: min(1200px, 100% - 32px);
  margin-inline: auto;
}

/* Brand */
[part="brand"] {
  display: flex;
  align-items: center;
  gap: 10px;
  min-block-size: 0;
  text-decoration: none;
  color: var(--pack-ink);
  margin-inline-end: auto;
}
[part="mark"] {
  display: block;
  /* The circles keep the model's dark colours on a light page too. */
  color-scheme: dark;
}
[part="mark"] circle {
  fill-opacity: 0.8;
}
[part="mark"] .c1 {
  fill: var(--pack-c1);
  fill-opacity: 0.85;
}
[part="mark"] .c2 {
  /* The model's violet is the opaque colour of --pack-a2. */
  fill: oklch(from var(--pack-a2) l c h / 1);
  mix-blend-mode: screen;
}
[part="mark"] .c3 {
  fill: var(--pack-c3);
  mix-blend-mode: screen;
}
/* The page's theme, from the tokens' --bythium-scheme: the logo multiplies on a light page, and the theme button
   shows the sun there, the moon on a dark page. A style query, so the server tree needs no script to be right. */
[part="theme"] .sun {
  display: none;
}
@container style(--bythium-scheme: light) {
  [part="mark"] circle[class] {
    mix-blend-mode: multiply;
  }
  [part="theme"] .moon {
    display: none;
  }
  [part="theme"] .sun {
    display: block;
  }
}
[part="brand"]:is(:hover, :focus-visible) .c1 {
  transform: translate(3px, 2px);
}
[part="brand"]:is(:hover, :focus-visible) .c2 {
  transform: translate(-3px, 2px);
}
[part="brand"]:is(:hover, :focus-visible) .c3 {
  transform: translate(0, -3px);
}
[part="word"] {
  font: 800 22px / 1 var(--sans);
  letter-spacing: -0.03em;
  background: linear-gradient(in srgb 100deg, var(--pack-wm1), var(--pack-wm2) 55%, var(--pack-wm3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Navigation */
[part="nav"] {
  display: flex;
  gap: 4px;
  align-items: center;
}
/* The Studio button; the next rules, more specific, give it the nav links' size and padding. */
[part="studio-button"] {
  --button-bg: transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  font: inherit;
}
/* The model's ".nav a" also reaches the Studio links, which restate what differs further down. */
[part="nav"] a {
  display: inline;
}
[part="nav"] a,
[part="nav"] [part="studio-button"] {
  min-block-size: 0;
  color: var(--pack-mut);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}
[part="nav"] a:hover {
  color: var(--pack-ink);
  background: var(--pack-panel2);
}
[part="nav"] a[aria-current="page"] {
  color: var(--pack-ink);
  background: var(--pack-panel2);
  box-shadow: 0 0 0 1px var(--pack-line2) inset;
}

/* Studio disclosure */
[part="studio"] {
  position: relative;
}
[part="studio-button"]:is(:hover, [aria-expanded="true"]) {
  --button-bg: var(--pack-panel2);
  color: var(--pack-ink);
}
[part="studio-button"][aria-expanded="true"] svg {
  transform: rotate(180deg);
}
[part="studio-menu"] {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-start: 0;
  min-inline-size: 220px;
  padding: 6px;
  margin: 0;
  list-style: none;
  border-radius: 14px;
  background: var(--pack-bg);
  border: 1px solid var(--pack-line2);
  box-shadow: var(--pack-shadow);
}
/* `current` naming a Studio item: the button reads as the current section (framed), the item as the current page,
   as on the model's Studio pages. */
[part="nav"] [part="studio-button"][data-current] {
  --button-bg: var(--pack-panel2);
  color: var(--pack-ink);
  box-shadow: 0 0 0 1px var(--pack-line2) inset;
}
[part="sr"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
[part="studio-menu"][hidden] {
  display: none;
}
[part="studio-menu"] a {
  display: flex;
  align-items: normal;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  color: var(--pack-ink);
}
[part="studio-badge"] {
  font: 600 11px var(--mono);
  color: var(--pack-mut);
}
[part="studio-menu"] a[aria-current="page"] {
  background: linear-gradient(90deg, var(--pack-a1), transparent);
  box-shadow: inset 3px 0 0 var(--pack-c1);
  font-weight: 700;
}

/* Buttons: the base sheet's hover and active backgrounds give way to each button's own. */
button[part] {
  background: var(--button-bg);
}
button[part]:not(:disabled):is(:hover, :active) {
  background: var(--button-bg);
}
[part="search"] {
  --button-bg: var(--pack-panel2);
  display: flex;
  align-items: center;
  gap: 10px;
  min-block-size: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--pack-line2);
  border-radius: 10px;
  color: var(--pack-mut);
  font: inherit;
  font-size: 14px;
}
[part="search"]:hover {
  border-color: var(--pack-c1);
  color: var(--pack-ink);
}
.lbl {
  min-inline-size: 70px;
  text-align: start;
}
kbd {
  font: 600 11px / 1 var(--mono);
  padding: 4px 6px;
  border: 1px solid var(--pack-line2);
  border-block-end-width: 2px;
  border-radius: 6px;
  color: var(--pack-mut);
  background: var(--pack-panel2);
}
[part="frameworks"] {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--pack-line2);
  border-radius: 12px;
  background: var(--pack-panel2);
  backdrop-filter: blur(10px);
}
[part="framework"] {
  --button-bg: transparent;
  min-block-size: 34px;
  min-inline-size: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  color: var(--pack-mut);
  font: 600 13px var(--mono);
}
[part="framework"]:hover {
  color: var(--pack-ink);
}
[part="framework"][aria-checked="true"] {
  --button-bg: linear-gradient(in srgb 120deg, var(--pack-btn1), var(--pack-btn2));
  color: var(--pack-btnink);
  box-shadow: 0 0 18px -2px var(--pack-a2);
}
/* The model's .icon-btn: the theme button, and the menu button that only shows under 1100 px. */
[part="theme"],
[part="menu"] {
  --button-bg: var(--pack-panel2);
  display: grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  min-block-size: 0;
  padding: 0;
  border: 1px solid var(--pack-line2);
  border-radius: 10px;
  color: var(--pack-ink);
}
[part="theme"]:hover,
[part="menu"]:hover {
  border-color: var(--pack-c1);
}
[part="menu"] {
  display: none;
}

/* Compact variant: a frosted bar, and tighter links so six of them and the Studio disclosure fit beside the tools. */
[part="root"].compact {
  backdrop-filter: blur(12px);
}
[part="root"].compact [part="bar"] {
  inline-size: min(1408px, 100% - 32px);
  gap: 12px;
}
[part="root"].compact [part="nav"] {
  gap: 2px;
  margin-inline-end: auto;
}
[part="root"].compact [part="nav"] a,
[part="root"].compact [part="nav"] [part="studio-button"] {
  padding: 6px 9px;
}
[part="root"].compact [part="brand"] {
  margin-inline-end: 12px;
}

/* Action: the model's .btn.sm */
[part="cta"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-block-size: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  font: 700 14px var(--sans);
  text-decoration: none;
  color: var(--pack-btnink);
  background: linear-gradient(in srgb 120deg, var(--pack-btn1), var(--pack-btn2) 60%, var(--pack-btn3));
  background-size: 160% 100%;
  box-shadow:
    0 0 0 1px color-mix(in oklch, light-dark(var(--pack-btnink), var(--pack-ink)) 18%, transparent) inset,
    0 10px 30px -10px var(--pack-a2),
    0 0 28px -6px var(--pack-a1);
}
[part="cta"]:hover {
  background-position: 100% 0;
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px color-mix(in oklch, light-dark(var(--pack-btnink), var(--pack-ink)) 30%, transparent) inset,
    0 14px 36px -10px var(--pack-a2),
    0 0 40px -4px var(--pack-a1);
}

/* Palette */
[part="palette"] {
  inline-size: min(560px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--pack-line2);
  border-radius: 16px;
  background: var(--pack-bg);
  color: var(--pack-ink);
  font: 16px / 1.6 var(--sans);
  /* The model's black shadow: the token's lightness and chroma brought to zero, in both themes. */
  box-shadow: 0 30px 90px -20px oklch(from var(--pack-bg) 0 0 0);
}
/* The model dims the page with the same near-black veil in both themes: the dark page colour at 60 %. */
[part="palette"]::backdrop {
  color-scheme: dark;
  background: color-mix(in oklch, var(--pack-bg) 60%, transparent);
}
[part="palette-input"] {
  inline-size: 100%;
  max-inline-size: none;
  min-block-size: 52px;
  padding: 0 18px;
  border: 0;
  border-block-end: 1px solid var(--pack-line);
  border-radius: 0;
  background: transparent;
  color: var(--pack-ink);
  font: 16px var(--sans);
}
/* The model leaves the placeholder to the browser: the base sheet's colour is reverted. */
[part="palette-input"]::placeholder {
  color: revert;
}
[part="palette-input"]:focus-visible {
  outline: 2px solid var(--pack-focus);
  outline-offset: -2px;
  border-radius: 14px 14px 0 0;
}
[part="palette-list"] {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-block-size: 50vh;
  overflow: auto;
}
[part="palette-link"] {
  display: flex;
  align-items: normal;
  justify-content: space-between;
  gap: 12px;
  min-block-size: 0;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--pack-ink);
  text-decoration: none;
}
[part="palette-link"]:is(:hover, :focus-visible) {
  background: var(--pack-panel2);
  outline-offset: -2px;
}
[part="palette-list"] li span {
  color: var(--pack-mut);
  font: 12px var(--mono);
}
[part="palette-list"] .none {
  display: block;
  padding: 10px 12px;
}

/* Compact tiers: the six links stay on one row from 1440 down to 1100. */
@media (width <= 1420px) {
  [part="root"].compact kbd {
    display: none;
  }
  [part="root"].compact .lbl {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    min-inline-size: 0;
  }
  [part="root"].compact [part="search"] {
    padding: 0;
    inline-size: 40px;
    justify-content: center;
  }
}
@media (width <= 1285px) {
  [part="root"].compact [part="cta"] {
    display: none;
  }
  [part="root"].compact [part="nav"] a,
  [part="root"].compact [part="nav"] [part="studio-button"] {
    padding: 6px 7px;
    font-size: 13.5px;
  }
  [part="root"].compact [part="bar"] {
    gap: 10px;
  }
  [part="root"].compact [part="brand"] {
    margin-inline-end: 6px;
  }
}
@media (width <= 1150px) {
  [part="root"].compact [part="framework"] {
    min-inline-size: 40px;
    padding: 0 8px;
  }
  [part="root"].compact [part="nav"] a,
  [part="root"].compact [part="nav"] [part="studio-button"] {
    padding: 6px 6px;
    font-size: 13px;
  }
  [part="root"].compact [part="bar"] {
    gap: 8px;
  }
}
/* Under 1100 px the navigation folds behind the menu button, in both variants; the format switch stays visible. */
@media (width < 1100px) {
  [part="nav"] {
    display: none;
  }
  [part="menu"] {
    display: grid;
  }
  [part="root"].compact [part="brand"] {
    margin-inline-end: auto;
  }
  [part="root"] [part="nav"].open {
    display: flex;
    order: 10;
    flex-direction: column;
    align-items: stretch;
    inline-size: 100%;
    gap: 2px;
    padding: 8px 0 6px;
    border-block-start: 1px solid var(--pack-line);
    margin: 0;
  }
  [part="root"] [part="nav"].open a,
  [part="root"] [part="nav"].open [part="studio-button"] {
    padding: 10px 12px;
    font-size: 15px;
    inline-size: 100%;
  }
  [part="root"] [part="nav"].open [part="studio-menu"] {
    position: static;
    margin-block-start: 4px;
    box-shadow: none;
    background: var(--pack-panel2);
  }
}
@media (width <= 700px) {
  [part="bar"] {
    gap: 10px;
  }
  [part="cta"],
  kbd {
    display: none;
  }
  .lbl {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    min-inline-size: 0;
  }
  [part="search"] {
    padding: 0;
    inline-size: 40px;
    justify-content: center;
  }
  [part="frameworks"] {
    order: 5;
    inline-size: 100%;
    justify-content: space-between;
  }
  [part="framework"] {
    flex: 1;
  }
  [part="root"] [part="nav"].open {
    order: 11;
  }
}

@media (prefers-reduced-motion: no-preference) {
  [part="mark"] circle {
    transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  [part="studio-button"] svg {
    transition: transform 200ms;
  }
  [part="cta"] {
    transition:
      background-position 300ms,
      transform 200ms,
      box-shadow 300ms;
  }
}

@media (forced-colors: active) {
  [part="word"] {
    background: none;
    color: CanvasText;
  }
  [part="framework"][aria-checked="true"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  [part="cta"] {
    border: 1px solid LinkText;
  }
  /* The inset ring that marks the current page is dropped in forced colours: an outline stands in for it. */
  [part="nav"] a[aria-current="page"] {
    outline: 1px solid CanvasText;
    outline-offset: -1px;
  }
}
