/*
 * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
 * SPDX-License-Identifier: Apache-2.0
 *
 * Zephyr brand cues (color logo, the kite's purple) on a layout of its own, so
 * the catalog is not mistaken for the documentation. No web fonts or
 * third-party requests.
 *
 * Layout: white top bar with the logo, a tinted band with title, introduction
 * and search, category pills, then a full-width grid of module cards.
 */
:root {
  --bg: #ffffff;
  --band: #f5f0fc;
  --surface: #ffffff;
  --surface-2: #f6f4fa;
  --ink: #1f2129;
  --muted: #5b5f6d;
  --line: #e4dfec;
  --brand: #7929d2;
  --brand-ink: #ffffff;
  --brand-soft: #ece2fa;
  --link: #6420b8;
  --focus: #7929d2;
  --code-bg: #f4f2f8;
  --code-ink: #2b2d36;
  --code-key: #1d6b3a;
  --code-str: #2d5a88;
  --code-com: #5c7682;
  --term-bg: #1d1b26;
  --term-ink: #e2def0;
  --term-prompt: #c9a7f5;
  --ok: #1d7748;
  --warn: #9a5800;
  --warn-bg: #fdf0dc;
  --idle: #5f6372;
  --idle-bg: #eceaf2;
  --mark: #fff0a0;
  --tile-l: 94%;
  --tile-ink-l: 30%;
  --shadow: 0 1px 2px rgb(40 20 80 / 0.06), 0 8px 20px -10px rgb(40 20 80 / 0.25);
  --show-sun: none;
  --show-moon: inline;
  --show-logo-light: block;
  --show-logo-dark: none;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "SF Mono", Monaco, Inconsolata, "Fira Mono", "Droid Sans Mono", "Source Code Pro", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131217; --band: #1c1825; --surface: #1d1b24; --surface-2: #26232f; --ink: #ecebf1; --muted: #a9a6b6;
    --line: #34303f; --brand: #a879ee; --brand-ink: #160d26; --brand-soft: #2d2343; --link: #c3a3f6; --focus: #c3a3f6;
    --code-bg: #1a1822; --code-ink: #e2e0ea; --code-key: #7df0cb; --code-str: #ffe7a0; --code-com: #a8a4b8;
    --term-bg: #0f0e13; --ok: #6fd6a0; --warn: #f2b45c; --warn-bg: #3d2f1b; --idle: #a8a6b3; --idle-bg: #2c2a33;
    --mark: #5a4b18; --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 24px -12px rgb(0 0 0 / 0.7);
    --tile-l: 24%; --tile-ink-l: 82%;
    --show-sun: inline; --show-moon: none; --show-logo-light: none; --show-logo-dark: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131217; --band: #1c1825; --surface: #1d1b24; --surface-2: #26232f; --ink: #ecebf1; --muted: #a9a6b6;
  --line: #34303f; --brand: #a879ee; --brand-ink: #160d26; --brand-soft: #2d2343; --link: #c3a3f6; --focus: #c3a3f6;
  --code-bg: #1a1822; --code-ink: #e2e0ea; --code-key: #7df0cb; --code-str: #ffe7a0; --code-com: #a8a4b8;
  --term-bg: #0f0e13; --ok: #6fd6a0; --warn: #f2b45c; --warn-bg: #3d2f1b; --idle: #a8a6b3; --idle-bg: #2c2a33;
  --mark: #5a4b18; --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 24px -12px rgb(0 0 0 / 0.7);
  --tile-l: 24%; --tile-ink-l: 82%;
  --show-sun: inline; --show-moon: none; --show-logo-light: none; --show-logo-dark: block;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
img { max-width: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.55; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip {
  position: absolute; top: 8px; left: 8px; z-index: 20; padding: 8px 14px; border-radius: 8px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.skip:not(:focus) { transform: translateY(-200%); }
h1, h2, h3 { font-weight: 700; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }

.wrap {
  max-width: 1200px; margin: 0 auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { height: 44px; width: auto; }
.brand .logo-light { display: var(--show-logo-light); }
.brand .logo-dark { display: var(--show-logo-dark); }
.brand-name { font-size: 19px; font-weight: 700; padding-left: 14px; border-left: 1px solid var(--line); white-space: nowrap; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.tools { display: flex; align-items: center; gap: 4px; margin-left: -12px; }
.topbar nav a, .tools a, #theme {
  color: var(--muted); font-size: 15px; padding: 6px 10px; min-height: 36px; border-radius: 8px; display: inline-flex; align-items: center;
  background: none; border: 0; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.topbar nav a:hover, .tools a:hover, #theme:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.topbar nav a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
#theme .i-sun { display: var(--show-sun); }
#theme .i-moon { display: var(--show-moon); }

/* band */
.band { background: var(--band); border-bottom: 1px solid var(--line); }
.band .wrap { padding-block: 34px 30px; }
.band h1 { font-size: 34px; line-height: 1.15; color: var(--ink); }
.band .lead { margin: 10px 0 0; font-size: 18px; line-height: 1.5; color: var(--ink); max-width: 68ch; }
.band-page .wrap { padding-block: 22px 26px; }
.band-page h1 { font-size: 30px; }
.band-page .lead { color: var(--muted); }
.crumbs { display: flex; gap: 8px; align-items: baseline; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs a, .back { color: var(--muted); font-size: 14px; }
.crumbs a:hover, .back:hover { color: var(--ink); }
.band-page .back { display: inline-block; margin-bottom: 10px; }
.crumbs .back { margin-bottom: 0; }
.search {
  display: flex; align-items: center; gap: 10px; margin-top: 20px; max-width: 620px; padding: 4px 8px 4px 16px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--brand); }
.search svg { flex: none; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; padding: 9px 0; font-family: inherit; }
.search kbd { font-family: var(--font-mono); font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; margin-right: 4px; }
@media (hover: none) { .search kbd { display: none; } }
.search:focus-within kbd, .search:has(input:not(:placeholder-shown)) kbd { display: none; }

/* catalog */
main { padding-block: 22px 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.pills button, .segmented button { font-family: inherit; line-height: inherit; cursor: pointer; }
.pills button {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 13px; min-height: 34px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; white-space: nowrap;
}
.pills button:hover { border-color: var(--brand); }
.pills button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.pills button[aria-pressed="true"] .n { color: inherit; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; min-height: 36px; }
.count { color: var(--muted); font-size: 14px; }
.count b { color: var(--ink); }
.reset { font-size: 14px; background: none; border: 0; color: var(--link); cursor: pointer; padding: 4px 6px; min-height: 32px; font-family: inherit; }
.segmented { margin-left: auto; display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; min-height: 30px; border: 0; border-radius: 7px; background: none; font-size: 13px; color: var(--muted); white-space: nowrap; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 16px; position: relative; min-width: 0;
  display: grid; grid-template-rows: auto 1fr auto; gap: 10px; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { border-color: color-mix(in oklab, var(--brand) 55%, var(--line)); box-shadow: var(--shadow); }
:root:not([data-input="pointer"]) .card:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.card-title { flex: 1; min-width: 0; }
.thumb {
  width: 44px; height: 44px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: #ffffff; border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; display: block; }
.thumb:not(:has(img)) { background: hsl(var(--h) 55% var(--tile-l)); border-color: transparent; }
.thumb span { font-weight: 700; font-size: 16px; color: hsl(var(--h) 50% var(--tile-ink-l)); }
.card h2 { font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.card h2 a { color: var(--ink); }
.card h2 a:hover { text-decoration: none; }
.card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.card h2 a:focus-visible { outline: none; }
.owner { font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }
.card p { margin: 0; align-self: start; font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.meta > * { white-space: nowrap; }
.meta > .status + *::before { content: "·"; margin-right: 8px; }
.meta > .lic { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.flag { color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 0 6px; font-weight: 600; }
.badge { color: var(--brand); background: var(--brand-soft); border-radius: 4px; padding: 0 6px; font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.active { color: var(--ok); }
.status.quiet, .status.inactive { color: var(--idle); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

/* code */
.codebox { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--code-bg); min-width: 0; }
.codebox-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--surface-2); }
.codebox-head .path { font-family: var(--font-mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.copy { margin-left: auto; flex: none; font-family: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 12px; min-height: 28px; cursor: pointer; }
.copy:hover { border-color: var(--brand); }
.codebox pre { margin: 0; padding: 12px 14px; font-size: 12.5px; line-height: 1.6; color: var(--code-ink); overflow-x: auto; white-space: pre; }
.y-k { color: var(--code-key); }
.y-s { color: var(--code-str); }
.y-c { color: var(--code-com); font-style: italic; }
.os-switch { display: flex; gap: 2px; }
.os-switch button { font-family: inherit; font-size: 13px; color: var(--muted); background: none; border: 0; border-radius: 6px; padding: 3px 10px; min-height: 28px; cursor: pointer; }
.os-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

footer { margin-top: 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; padding-block: 20px 28px; }

/* detail: catalog panel and module page */
.panel {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0; width: min(640px, 100%); max-width: none; height: auto; max-height: none;
  background: var(--bg); color: var(--ink); overflow-y: auto; overscroll-behavior: contain; box-shadow: -20px 0 40px -20px rgb(0 0 0 / 0.4);
}
.panel[open] { transform: none; transition: transform 0.25s ease; }
@starting-style { .panel[open] { transform: translateX(102%); } }
.panel::backdrop { background: rgb(14 10 26 / 0.45); }
html:has(.panel[open]) { overflow: hidden; }
.panel-inner {
  min-height: 100%; display: grid; align-content: start; gap: 8px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(22px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) 22px;
}
.panel-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px;
  position: sticky; top: 0; z-index: 1; background: var(--bg); padding-block: 8px; margin-block: -8px;
}
.close { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; color: var(--ink); font-size: 18px; line-height: 1; }
.detail { display: grid; gap: 20px; min-width: 0; }
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head .thumb { width: 56px; height: 56px; border-radius: 12px; }
.band-head { display: flex; align-items: center; gap: 16px; }
.band-head .thumb { width: 64px; height: 64px; border-radius: 14px; }
.band-head .thumb span { font-size: 22px; }
.detail-head h2 { font-size: 26px; line-height: 1.15; }
.detail-head .owner, .band-head .owner { margin-top: 2px; font-size: 13px; }
.band-head > div { min-width: 0; }
.detail-summary { margin: -6px 0 0; font-size: 17px; color: var(--muted); }
.detail-page .detail-intro { display: none; }
.detail section h2 { font-size: 19px; margin-bottom: 10px; }
.install { display: grid; gap: 10px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; border: 1px solid var(--line); overflow-x: auto; }
.tabs button { flex: 1 0 auto; font-family: inherit; font-size: 14px; padding: 6px 10px; min-height: 32px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.tabpanel { display: grid; gap: 8px; min-width: 0; }
.hint { font-size: 14px; color: var(--muted); margin: 0; }
.cmd { display: flex; align-items: center; gap: 10px; background: var(--term-bg); color: var(--term-ink); border-radius: 10px; padding: 8px 8px 8px 14px; font-family: var(--font-mono); font-size: 14px; min-width: 0; }
.cmd .p { color: var(--term-prompt); }
.cmd code { overflow-x: auto; white-space: nowrap; min-width: 0; flex: 1; }
.cmd .copy { background: rgb(255 255 255 / 0.08); color: var(--term-ink); border-color: rgb(255 255 255 / 0.18); }
.hint code, .option code, .prose code, .checks code { background: var(--code-bg); color: var(--code-ink); padding: 1px 5px; border-radius: 4px; font-size: 0.88em; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.links a { display: inline-flex; align-items: center; padding: 5px 12px; min-height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.links a:hover { border-color: var(--brand); text-decoration: none; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 0; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.rev { font-family: var(--font-mono); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 15px; }
.checks li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; }
.checks .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 2px; }
.checks .warn .ic { background: var(--warn-bg); color: var(--warn); }
.checks-warn { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); }
.checks-warn .warn .ic { background: var(--warn); color: var(--warn-bg); }
.checks .info .ic { background: var(--idle-bg); color: var(--idle); }
.prose p { margin: 0 0 12px; max-width: 72ch; }
.prose ul { margin: 0 0 12px; padding-left: 22px; max-width: 70ch; }
.prose li { margin-bottom: 4px; }
.edit-links { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; border-top: 1px solid var(--line); padding-top: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--term-bg); color: var(--term-ink); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; transition: all 0.2s ease;
  max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* contribution page */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px; margin-bottom: 32px; align-items: stretch; }
.option { border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; background: var(--surface); display: grid; grid-template-rows: auto 1fr auto; gap: 12px; min-width: 0; }
.option code { overflow-wrap: anywhere; }
.option h2 { font-size: 21px; }
.option p { margin: 0; align-self: start; }
.option-main { background: var(--band); border-color: color-mix(in oklab, var(--brand) 45%, var(--line)); }
.btn {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; min-height: 44px; border-radius: 10px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: 15px;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-secondary { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.btn-secondary:hover { background: var(--brand-soft); filter: none; }
.example-title { font-size: 19px; margin-bottom: 12px; }

@media (max-width: 720px) {
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .topbar .wrap { flex-wrap: wrap; gap: 4px 12px; }
  .brand img { height: 36px; }
  .brand-name { font-size: 15px; padding-left: 12px; }
  .topbar nav { order: 3; margin-left: -10px; width: 100%; flex-wrap: wrap; }
  .tools { margin-left: auto; margin-right: -10px; }
  .band .wrap { padding-block: 20px 20px; }
  .band h1 { font-size: 26px; }
  .band .lead { font-size: 16px; }
  .search { margin-top: 14px; }
  .pills { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding-inline: 16px; padding-bottom: 4px; scrollbar-width: none; }
  .segmented { margin-left: 0; overflow-x: auto; max-width: 100%; }
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
