@import url("fonts.css");

/* =============================================================================
   Swaymoon Docs — Apple Developer Documentation (DocC) layout
   ========================================================================== */

:root {
  --font-mono: "SF Mono", Menlo, Monaco, "Courier New", monospace;

  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --link: #0066cc;
  --link-hover: #0077ed;
  --accent: #0071e3;

  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-code: #f6f6f6;
  --bg-nav: #f9f9f9;
  --surface: #ffffff;

  --hairline: #d2d2d7;
  --hairline-soft: rgba(0, 0, 0, 0.08);
  --nav-active-bg: rgba(0, 113, 227, 0.08);
  --nav-hover-bg: rgba(0, 0, 0, 0.04);

  --topnav-height: 52px;
  --sidebar-width: 260px;
  --toc-width: 200px;
  --content-max: 740px;
  --shell-max: 1600px;

  --radius-code: 8px;
  --focus-ring: 0 0 0 4px rgba(0, 125, 250, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --link: #2997ff;
    --link-hover: #6cb6ff;
    --accent: #0a84ff;

    --bg: #000000;
    --bg-secondary: #1d1d1f;
    --bg-code: #1c1c1e;
    --bg-nav: #161617;
    --surface: #1d1d1f;

    --hairline: #424245;
    --hairline-soft: rgba(255, 255, 255, 0.12);
    --nav-active-bg: rgba(10, 132, 255, 0.16);
    --nav-hover-bg: rgba(255, 255, 255, 0.06);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47059;
  letter-spacing: -0.022em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

button {
  font-family: inherit;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top nav ---------- */

.docs-topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topnav-height);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline-soft);
}

@media (prefers-color-scheme: dark) {
  .docs-topnav {
    background: rgba(22, 22, 23, 0.72);
  }
}

.docs-topnav-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.docs-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.docs-brand:hover {
  text-decoration: none;
  color: var(--text);
}

.docs-brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.021em;
}

.docs-brand-short {
  display: none;
}

.docs-brand-sub {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

.docs-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.docs-menu-btn:hover {
  background: var(--nav-hover-bg);
}

.docs-search {
  flex: 1 1 auto;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.docs-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.docs-search input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--bg);
}

.docs-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.docs-account {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.docs-dev-toggle {
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.docs-dev-toggle:hover {
  color: var(--text);
  border-color: var(--text-tertiary);
}

.docs-dev-toggle.is-on {
  color: var(--accent);
  border-color: rgba(0, 113, 227, 0.45);
  background: var(--nav-active-bg);
}

.docs-dev-toggle.is-only {
  color: #0b4f8a;
  border-color: rgba(11, 79, 138, 0.5);
  background: rgba(0, 113, 227, 0.12);
}

.docs-dev-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  color: var(--accent);
  background: var(--nav-active-bg);
}

.docs-dev-badge.hero {
  font-size: 12px;
  padding: 3px 8px;
  vertical-align: 0.2em;
}

.docs-inline-dev-btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.docs-inline-dev-btn:hover {
  background: var(--link-hover);
}

.docs-home-card.is-developer {
  border-color: rgba(0, 113, 227, 0.28);
}

.docs-account a {
  color: var(--text-secondary);
  text-decoration: none;
}

.docs-account a:hover {
  color: var(--link);
}

.docs-account-name {
  color: var(--text-secondary);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Shell ---------- */

.docs-shell {
  flex: 1 1 auto;
  max-width: var(--shell-max);
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  gap: 0;
  min-height: calc(100vh - var(--topnav-height));
  min-height: calc(100dvh - var(--topnav-height));
}

.docs-shell.no-toc {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* ---------- Navigator ---------- */

.docs-nav {
  position: sticky;
  top: var(--topnav-height);
  align-self: start;
  height: calc(100vh - var(--topnav-height));
  height: calc(100dvh - var(--topnav-height));
  overflow: auto;
  padding: 16px 12px 32px;
  border-right: 1px solid var(--hairline-soft);
  background: var(--bg);
}

.docs-nav-filter {
  width: 100%;
  height: 32px;
  margin-bottom: 12px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.docs-nav-filter:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.docs-nav-list,
.docs-nav-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-nav-children {
  padding-left: 14px;
  border-left: 1px solid var(--hairline-soft);
  margin-left: 8px;
}

.docs-nav-item {
  margin: 2px 0;
}

.docs-nav-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-height: 30px;
  padding: 0;
  border-radius: 6px;
}

.docs-nav-row:hover {
  background: var(--nav-hover-bg);
}

.docs-nav-row.active {
  background: var(--nav-active-bg);
}

.docs-nav-toggle {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.docs-nav-toggle:hover {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.docs-nav-toggle .chev {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 0.15s ease;
}

.docs-nav-item.open > .docs-nav-row .chev {
  transform: rotate(90deg);
}

.docs-nav-item:not(.open) > .docs-nav-children {
  display: none;
}

.docs-nav-link,
.docs-nav-label {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px 5px 4px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.docs-nav-link:hover {
  text-decoration: none;
  color: var(--text);
}

.docs-nav-row.active .docs-nav-link {
  color: var(--accent);
  font-weight: 600;
}

.docs-nav-label {
  color: var(--text-secondary);
  font-weight: 600;
  cursor: default;
}

.docs-nav-item.hidden-by-filter {
  display: none;
}

/* ---------- Main ---------- */

.docs-main {
  min-width: 0;
  padding: 28px 40px 80px;
}

.docs-main-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.docs-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.docs-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.docs-breadcrumb a:hover {
  color: var(--link);
}

.docs-breadcrumb .sep {
  color: var(--hairline);
}

.docs-hero-title {
  margin: 0 0 8px;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.docs-hero-desc {
  margin: 0 0 28px;
  font-size: 19px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.docs-last-updated {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-tertiary, var(--text-secondary));
}

.docs-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}

.docs-page-action {
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.docs-page-action:hover {
  color: var(--text);
  border-color: var(--text-tertiary);
}

.docs-page-action.is-done {
  color: #008009;
  border-color: rgba(0, 128, 9, 0.35);
}

@media (prefers-color-scheme: dark) {
  .docs-page-action.is-done {
    color: #30d158;
  }
}

.docs-highlight-banner {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 214, 10, 0.18);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

mark.docs-search-hit {
  background: rgba(255, 214, 10, 0.55);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
  scroll-margin-top: calc(var(--topnav-height) + 24px);
}

mark.docs-search-hit.is-current {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: rgba(255, 204, 0, 0.75);
}

.docs-mermaid {
  margin: 1.4em 0;
  padding: 16px 12px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-code);
  background: var(--bg-secondary);
  overflow-x: auto;
}

.docs-mermaid .mermaid {
  display: flex;
  justify-content: center;
  min-width: min-content;
}

.docs-mermaid svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Article (markdown) ---------- */

.docs-article {
  font-size: 17px;
  line-height: 1.7;
}

.docs-article > :first-child {
  margin-top: 0;
}

.docs-article h1 {
  display: none; /* hero title already shown */
}

.docs-article h2 {
  margin: 2.2em 0 0.7em;
  padding-top: 0.4em;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  scroll-margin-top: calc(var(--topnav-height) + 16px);
  border-top: 1px solid var(--hairline-soft);
}

.docs-article h2:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.docs-article h3 {
  margin: 1.8em 0 0.55em;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.016em;
  scroll-margin-top: calc(var(--topnav-height) + 16px);
}

.docs-article h4 {
  margin: 1.4em 0 0.45em;
  font-size: 17px;
  font-weight: 650;
  scroll-margin-top: calc(var(--topnav-height) + 16px);
}

.docs-article p,
.docs-article ul,
.docs-article ol {
  margin: 0 0 1.15em;
}

.docs-article ul,
.docs-article ol {
  padding-left: 1.35em;
}

.docs-article li {
  margin: 0.45em 0;
}

.docs-article blockquote {
  margin: 1.2em 0;
  padding: 0.2em 0 0.2em 1em;
  border-left: 3px solid var(--hairline);
  color: var(--text-secondary);
}

.docs-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 15px;
}

.docs-article th,
.docs-article td {
  border: 1px solid var(--hairline);
  padding: 8px 12px;
  text-align: left;
}

.docs-article th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.docs-article :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: 4px;
  background: var(--bg-code);
  color: var(--text);
}

.docs-article pre {
  margin: 1.2em 0;
  position: relative;
}

.docs-codeblock {
  position: relative;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-code);
  background: var(--bg-code);
  overflow: hidden;
}

.docs-codeblock-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--hairline-soft);
  background: var(--bg-secondary);
}

.docs-codeblock-lang {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.docs-copy-btn {
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.docs-copy-btn:hover {
  color: var(--text);
  border-color: var(--text-tertiary);
}

.docs-copy-btn.copied {
  color: #008009;
  border-color: rgba(0, 128, 9, 0.35);
}

@media (prefers-color-scheme: dark) {
  .docs-copy-btn.copied {
    color: #30d158;
  }
}

.docs-codeblock pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  background: transparent;
}

.docs-codeblock code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.85;
  letter-spacing: 0;
  background: transparent !important;
  padding: 0 !important;
}

.docs-article .katex-display {
  margin: 1.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.docs-article img {
  max-width: 100%;
  height: auto;
}

.docs-article hr {
  border: 0;
  border-top: 1px solid var(--hairline-soft);
  margin: 2em 0;
}

/* ---------- On This Page ---------- */

.docs-toc {
  position: sticky;
  top: var(--topnav-height);
  align-self: start;
  height: calc(100vh - var(--topnav-height));
  height: calc(100dvh - var(--topnav-height));
  overflow: auto;
  padding: 28px 16px 32px 12px;
  border-left: 1px solid var(--hairline-soft);
}

.docs-toc-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.docs-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-toc-list a {
  display: block;
  padding: 4px 0 4px 10px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
}

.docs-toc-list a:hover {
  color: var(--text);
}

.docs-toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.docs-toc-list .toc-h3 {
  padding-left: 20px;
}

/* ---------- Home / search ---------- */

.docs-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.docs-home-card {
  display: block;
  padding: 18px 18px 16px;
  border: 1px solid var(--hairline-soft);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.docs-home-card:hover {
  text-decoration: none;
  border-color: var(--hairline);
  background: var(--bg-secondary);
  color: var(--text);
}

.docs-home-card h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 650;
}

.docs-home-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.docs-ssr-related {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline-soft);
}

.docs-ssr-related h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 650;
}

.docs-ssr-related ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-ssr-related li {
  margin: 0 0 8px;
}

.docs-search-results {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
}

.docs-search-results li {
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline-soft);
}

.docs-search-results a {
  font-size: 19px;
  font-weight: 600;
  text-decoration: none;
}

.docs-search-results a:hover {
  text-decoration: underline;
}

.docs-search-path {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.docs-search-snippet {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.docs-search-snippet mark {
  background: rgba(255, 214, 10, 0.45);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.docs-empty {
  margin: 24px 0;
  color: var(--text-secondary);
}

.docs-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline-soft);
  font-size: 12px;
  color: var(--text-tertiary);
}

.docs-footer a {
  color: inherit;
  text-decoration: none;
}

.docs-footer a:hover {
  text-decoration: underline;
}

.docs-footer .sep {
  margin: 0 0.4em;
  opacity: 0.55;
}

.docs-footer .footer-whereami {
  margin-top: 6px;
}

/* ---------- Overlay nav (mobile) ---------- */

.docs-nav-backdrop {
  display: none;
}

@media (max-width: 1100px) {
  .docs-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .docs-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .docs-menu-btn {
    display: inline-flex;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .docs-topnav-inner {
    gap: 8px;
    padding: 0 10px;
  }

  .docs-brand-full {
    display: none;
  }

  .docs-brand-short {
    display: inline;
  }

  .docs-brand-name {
    font-size: 15px;
  }

  .docs-brand-sub {
    display: none;
  }

  .docs-search {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    margin: 0;
  }

  .docs-search input {
    height: 32px;
    font-size: 13px;
    padding-left: 30px;
  }

  .docs-account {
    gap: 6px;
  }

  .docs-account-name {
    display: none;
  }

  .docs-dev-toggle {
    font-size: 11px;
    padding: 6px 8px;
  }

  .docs-shell,
  .docs-shell.no-toc {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-nav {
    position: fixed;
    left: 0;
    top: var(--topnav-height);
    width: min(86vw, 300px);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.12);
    background: var(--bg);
  }

  body.nav-open .docs-nav {
    transform: translateX(0);
  }

  .docs-nav-backdrop {
    display: block;
    position: fixed;
    inset: var(--topnav-height) 0 0 0;
    background: rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 45;
  }

  body.nav-open .docs-nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .docs-main {
    padding: 20px 18px 64px;
  }

  .docs-hero-title {
    font-size: 32px;
  }
}

@media (max-width: 420px) {
  .docs-account-link {
    display: none;
  }

  .docs-topnav-inner {
    gap: 6px;
    padding: 0 8px;
  }
}

@media (prefers-color-scheme: light) {
  .hljs-theme-dark {
    display: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  .hljs-theme-light {
    display: none !important;
  }
}

/* ---------- Embed mini-window (developer portal iframe) ---------- */

body.docs-embed {
  --topnav-height: 44px;
  font-size: 15px;
}

body.docs-embed .docs-topnav-inner {
  padding: 0 12px;
  gap: 8px;
}

body.docs-embed .docs-brand-name {
  font-size: 13px;
}

body.docs-embed .docs-brand-sub {
  font-size: 11px;
}

body.docs-embed .docs-search {
  max-width: 140px;
}

body.docs-embed .docs-search input {
  font-size: 13px;
  height: 30px;
}

body.docs-embed .docs-dev-toggle {
  font-size: 11px;
  padding: 4px 8px;
}

body.docs-embed .docs-shell {
  --sidebar-width: 200px;
}

body.docs-embed .docs-main {
  padding: 16px 14px 40px;
}

body.docs-embed .docs-hero-title {
  font-size: 24px;
}

body.docs-embed .docs-home-grid {
  grid-template-columns: 1fr;
}

body.docs-embed .docs-toc {
  display: none !important;
}

@media (max-width: 734px) {
  body.docs-embed .docs-search {
    display: none;
  }
}
