/**
 * Window chrome for basenative.com. Inlined into every page as well as
 * linked, so a stale cached stylesheet cannot unstyle the shell.
 * Every --bn-plat-* use carries a fallback so the inline copy does not
 * depend on tokens.css being fresh.
 */
@layer components {
  :root {
    color-scheme: light dark;
    --bn-shell-sidebar: 240px;
    /* Matches the tab bar's 62px frame. The lift is the gap under the floating capsule. */
    --bn-shell-tab: 62px;
    --bn-shell-tab-lift: 8px;
    --bn-shell-read: 880px;
  }

  body {
    display: grid;
    grid-template-columns: var(--bn-shell-sidebar) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: 'side main';
    min-block-size: 100dvh;
    margin: 0;
    background: #f2f2f7;
    color: var(--bn-plat-color-labels-primary, rgba(0, 0, 0, 0.97));
    font-family:
      -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
    font-size: var(--bn-plat-font-body-size, 17px);
    line-height: var(--bn-plat-font-body-leading, 22px);
  }

  [data-bn-platform='ios'] body {
    font-size: var(--bn-plat-font-body-size, 17px);
    line-height: var(--bn-plat-font-body-leading, 22px);
  }

  [data-bn-platform='macos'] body {
    font-size: var(--bn-content-size, 15px);
    line-height: var(--bn-content-leading, 22px);
  }

  body::before,
  body::after {
    content: none;
    display: none;
  }

  body > [data-bn='bn-sidebar'] {
    grid-area: side;
    min-block-size: 0;
    overflow: auto;
  }

  main {
    grid-area: main;
    max-inline-size: none;
    margin: 0;
    min-inline-size: 0;
    padding: 24px 32px 48px;
    background: transparent;
  }

  /* Pages that still use the previous dark type stay readable inside the new chrome. */
  body:not([data-active='home']) main {
    background: var(--surface-0, #0c0b09);
    color: var(--text-0, #f0ede4);
  }

  [data-theme='dark'] body {
    background: var(
      --bn-plat-color-backgrounds-grouped-primary,
      var(--bn-plat-color-window-background, #000)
    );
    color: var(--bn-plat-color-labels-primary, rgba(255, 255, 255, 0.85));
  }

  body[data-active='home'] main {
    padding: 56px 48px 32px;
    background: transparent;
    color: inherit;
  }

  body[data-active='home'] {
    background-color: var(--bn-glass-opaque, #f2f2f7);
    background-image:
      radial-gradient(
        28rem 16rem at 0% 0%,
        color-mix(in srgb, var(--bn-plat-color-accents-indigo, #5e5ce6) 22%, transparent),
        transparent 70%
      ),
      radial-gradient(
        22rem 12rem at 100% 0%,
        color-mix(in srgb, var(--bn-plat-color-accents-blue, #0088ff) 16%, transparent),
        transparent 68%
      );
    background-attachment: scroll;
  }

  body[data-active='home'] article {
    box-sizing: border-box;
    width: 100%;
    max-inline-size: 100%;
    margin-inline: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body[data-active='home'] article:hover {
    border-color: transparent;
    box-shadow: none;
  }

  body[data-active='home'] h1 {
    margin: 0;
    font-size: var(--bn-plat-font-large-title-size, 34px);
    line-height: var(--bn-plat-font-large-title-leading, 41px);
    font-weight: 700;
    letter-spacing: var(--bn-plat-font-large-title-tracking, 0.4px);
    color: var(--bn-plat-color-labels-primary, rgba(0, 0, 0, 0.97));
  }

  [data-bn-platform='ios'] body[data-active='home'] h1 {
    font-size: var(--bn-plat-font-large-title-size, 34px);
    line-height: var(--bn-plat-font-large-title-leading, 41px);
  }

  [data-bn-platform='macos'] body[data-active='home'] h1 {
    font-size: var(--bn-title-large, 28px);
    line-height: var(--bn-title-large-leading, 34px);
  }

  [data-bn-platform='macos'] body[data-active='home'] header > p,
  [data-bn-platform='macos'] body[data-active='home'] [data-bn='bn-list-title'],
  [data-bn-platform='macos'] body[data-active='home'] [data-bn='bn-list-detail'],
  [data-bn-platform='macos'] body[data-active='home'] section > h2 {
    font-size: var(--bn-content-size, 15px);
    line-height: var(--bn-content-leading, 22px);
  }

  body[data-active='home'] header > p:first-of-type {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 18px;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--bn-content-secondary, rgba(60, 60, 67, 0.88));
  }

  body[data-active='home'] header > p {
    margin: 12px 0 0;
    max-inline-size: none;
    font-size: 17px;
    line-height: 22px;
    font-weight: 400;
    letter-spacing: -0.43px;
    color: var(--bn-plat-color-labels-primary, rgba(0, 0, 0, 0.97));
  }

  body[data-active='home'] main > header,
  body[data-active='home'] main > section,
  body[data-active='home'] section {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body[data-active='home'] section > h2 {
    margin: 32px 16px 8px;
    font-size: max(13px, var(--bn-plat-font-footnote-size, 13px));
    line-height: 18px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--bn-content-secondary, rgba(60, 60, 67, 0.88));
  }

  [data-bn-platform='ios'] body[data-active='home'] [data-bn='bn-list-title'] {
    font-size: var(--bn-plat-font-body-size, 17px);
    line-height: var(--bn-plat-font-body-leading, 22px);
  }

  [data-theme='dark'] body:not([data-active='home']) [data-bn='bn-list'][data-grouped='true'] {
    background: var(--bn-plat-color-backgrounds-grouped-secondary, rgb(44, 44, 46));
  }

  [data-theme='dark'] body[data-active='home'] pre {
    background: var(--bn-list-surface, rgba(44, 44, 46, 0.94));
  }

  body[data-active='home'] pre {
    box-sizing: border-box;
    max-inline-size: 100%;
    min-inline-size: 0;
    margin: 0 0 24px;
    padding: 16px;
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    scrollbar-color: var(--bn-content-secondary, rgba(60, 60, 67, 0.88)) transparent;
    border-radius: var(--bn-radius-card, 22px);
    background: var(--bn-list-surface, rgba(255, 255, 255, 0.94));
    color: var(--bn-plat-color-labels-primary, rgba(0, 0, 0, 0.97));
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: var(--bn-content-size, 15px);
    line-height: 1.45;
    backdrop-filter: saturate(var(--bn-glass-saturate, 180%)) blur(var(--bn-glass-blur, 30px));
    box-shadow:
      var(--bn-glass-edge, 0 0 0 0.5px rgba(0, 0, 0, 0.12)),
      var(--bn-glass-shadow-overlay, 0 8px 48px rgba(0, 0, 0, 0.25));
  }

  body[data-active='home'] pre code {
    display: block;
    max-inline-size: 100%;
    min-inline-size: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  @media (min-width: 1100px) {
    body[data-active='home'] article {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      row-gap: 8px;
      align-items: start;
      inline-size: 100%;
    }

    body[data-active='home'] article > header,
    body[data-active='home'] article > section,
    body[data-active='home'] [data-bn='bn-list'],
    body[data-active='home'] [data-bn='bn-hero'] {
      inline-size: 100%;
      max-inline-size: 100%;
    }
  }

  @media (max-width: 767px) {
    body > [data-bn='bn-sidebar'] {
      display: none;
    }

    body > [data-bn='bn-tab-bar'] {
      display: flex;
      position: fixed;
      inset-inline: 12px;
      inset-block-end: calc(env(safe-area-inset-bottom, 0px) + var(--bn-shell-tab-lift));
      z-index: var(--bn-z-nav, 20);
      width: auto;
      margin: 0;
      border: 0;
      border-radius: var(--bn-radius-capsule, 999px);
    }

    body {
      box-sizing: border-box;
      height: 100dvh;
      max-height: 100dvh;
      padding-bottom: 0;
      overflow: hidden;
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr);
      grid-template-areas: 'main';
    }

    main {
      align-self: start;
      block-size: calc(
        100dvh - var(--bn-shell-tab) - var(--bn-shell-tab-lift) - env(safe-area-inset-bottom, 0px)
      );
      max-block-size: calc(
        100dvh - var(--bn-shell-tab) - var(--bn-shell-tab-lift) - env(safe-area-inset-bottom, 0px)
      );
      min-height: 0;
      overflow: auto;
      padding: 20px 16px 16px;
      mask-image: none;
    }

    body[data-active='home'] main {
      padding: 28px 16px 16px;
    }
  }

  @media (min-width: 768px) {
    body > [data-bn='bn-tab-bar'] {
      display: none;
    }
  }

  [data-theme='dark'] body,
  body[data-active='home'] {
    background-color: var(--bn-glass-opaque, #0c0b09);
    background-image: radial-gradient(
      28rem 12rem at 8% 0%,
      color-mix(in srgb, var(--bn-brand, #e8920a) 14%, transparent),
      transparent 74%
    );
    background-attachment: scroll;
  }

  body:not([data-active='home']) main {
    background: transparent;
    color: var(--bn-plat-color-labels-primary, rgba(255, 255, 255, 0.92));
  }

  section[data-hero],
  section[data-bn-page-hero],
  [data-bn-showcase-header],
  [data-bn-component-hero],
  body:not([data-active='home'])
    main
    > section:first-of-type:not(
      :has(
        article,
        [data-bn='bn-list'],
        [data-bn='bn-metric'],
        [data-bn='bn-card-grid'],
        [data-bn-component-card]
      )
    ) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 var(--bn-section-space, 12px);
    padding: 22px;
    border: 1px solid var(--bn-glass-rim, rgba(255, 255, 255, 0.35));
    border-radius: var(--bn-radius-card, 22px);
    background-color: var(--bn-list-surface, rgba(44, 44, 46, 0.58));
    background-image: var(
      --bn-glass-sheen,
      linear-gradient(to bottom, rgba(255, 255, 255, 0.22), transparent 46%)
    );
    box-shadow: var(--bn-elev-2, 0 8px 24px rgba(0, 0, 0, 0.16));
    backdrop-filter: saturate(var(--bn-glass-saturate, 180%)) blur(var(--bn-glass-blur, 30px));
    color: var(--bn-plat-color-labels-primary, rgba(255, 255, 255, 0.92));
  }

  /* A section that already holds cards is a stack, not another card. */
  body:not([data-active='home'])
    main
    > section:has(
      article,
      [data-bn='bn-list'],
      [data-bn='bn-metric'],
      [data-bn='bn-card-grid'],
      [data-bn-component-card]
    ) {
    margin: 0 0 var(--bn-section-space, 12px);
    padding: 0;
    border: 0;
    background: none;
    background-image: none;
    box-shadow: none;
    backdrop-filter: none;
  }

  main > section > article {
    margin-block: 0 var(--bn-section-space, 12px);
  }

  main > section > article:last-child {
    margin-block-end: 0;
  }

  main a {
    color: var(--bn-brand-text, #9a5f05);
  }

  [data-bn-cta='primary'],
  [data-hero] a[role='button']:not([data-variant='outline']) {
    background: var(--bn-brand, #e8920a);
    color: var(--bn-brand-ink, #0c0b09);
    border-radius: var(--bn-radius-capsule, 999px);
    text-decoration: none;
  }

  [data-bn-platform='macos'] body[data-active='home'] h1,
  [data-bn-platform='macos'] [data-bn='bn-hero'] h1 {
    font-size: var(--bn-title-large, 28px);
    line-height: var(--bn-title-large-leading, 34px);
  }

  [data-bn-platform='macos'] body[data-active='home'] header > p:not(:first-of-type),
  [data-bn-platform='macos'] body[data-active='home'] [data-bn='bn-list-title'],
  [data-bn-platform='macos'] body[data-active='home'] [data-bn='bn-list-detail'],
  [data-bn-platform='macos'] body[data-active='home'] section > h2,
  [data-bn-platform='macos'] body[data-active='home'] pre,
  [data-bn-platform='macos'] body[data-active='home'] pre code,
  [data-bn-platform='macos'] body[data-active='home'] p code {
    font-size: var(--bn-content-size, 15px);
    line-height: var(--bn-content-leading, 22px);
  }
}

/*
 * theme.css pins the dark palette on an unlayered :root, which beats every
 * layered rule. This file is enforced, so it cannot add another unlayered
 * rule. An important declaration in the first cascade layer (reset) beats
 * that unlayered normal rule, and the selector only matches light pages.
 */
@layer reset {
  [data-theme='light'] {
    color-scheme: light !important;
    --surface-0: #f2f2f7 !important;
    --surface-1: #ffffff !important;
    --surface-2: #f4f4f5 !important;
    --surface-3: #e7e7e8 !important;
    --surface-inset: #ffffff !important;
    --border: rgba(60, 60, 67, 0.18) !important;
    --border-accent: rgba(154, 95, 5, 0.4) !important;
    --text-0: #0c0b09 !important;
    --text-1: rgba(60, 60, 67, 0.88) !important;
    --text-2: rgba(60, 60, 67, 0.62) !important;
    --track-bg: #e4e4e6 !important;
    --table-header-bg: #f4f4f5 !important;
    --dialog-backdrop: rgba(12, 11, 9, 0.4) !important;
    --bn-color-surface: #f2f2f7 !important;
    --bn-color-surface-subtle: #ffffff !important;
    --bn-color-surface-muted: #f4f4f5 !important;
    --bn-color-surface-raised: #ffffff !important;
    --bn-color-surface-inset: #f2f2f7 !important;
    --bn-color-text: #0c0b09 !important;
    --bn-color-text-muted: rgba(60, 60, 67, 0.72) !important;
    --bn-color-text-subtle: rgba(60, 60, 67, 0.55) !important;
  }

  [data-theme='dark'] {
    color-scheme: dark !important;
    --surface-0: #0c0b09 !important;
    --surface-1: #151310 !important;
    --surface-2: #1c1916 !important;
    --surface-3: #26221c !important;
    --surface-inset: #080706 !important;
    --border: #2c2822 !important;
    --border-accent: #3f3930 !important;
    --text-0: #f0ede4 !important;
    --text-1: #b5ae9e !important;
    --text-2: #9a917f !important;
    --track-bg: #26221c !important;
    --table-header-bg: #1c1916 !important;
    --dialog-backdrop: rgba(12, 11, 9, 0.72) !important;
    --bn-color-surface: #0c0b09 !important;
    --bn-color-surface-subtle: #151310 !important;
    --bn-color-surface-muted: #1c1916 !important;
    --bn-color-surface-raised: #151310 !important;
    --bn-color-surface-inset: #080706 !important;
    --bn-color-text: #f0ede4 !important;
    --bn-color-text-muted: #b5ae9e !important;
    --bn-color-text-subtle: #857c6b !important;
  }
}
