/* NGCP documentation, styled as part of ngcpanel.com (the website repo: "NGCPanel Website").
   Light and dark follow the OS (prefers-color-scheme). Works under the site's CSP (default-src 'self'):
   no inline styles or scripts. No inner scroll areas: the page grows, code wraps, tables become cards
   on phones. Fonts load root-absolute from /fonts/ (served by the website); elsewhere the system
   font stack takes over. */

@layer reset, tokens, base, chrome, page;

/* == SHARED START (keep identical to the docs stylesheet; tools/check_shared_css.py) == */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol, pre { margin: 0; }
  img, svg, picture { display: block; max-width: 100%; }
  img { height: auto; }
  button, input { font: inherit; color: inherit; }
  [hidden]:not([hidden="until-found"]) { display: none !important; }
}

@layer tokens {
  @font-face {
    font-family: "Instrument Sans";
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    font-stretch: 75% 100%;
    src: url("/fonts/instrument-sans.woff2") format("woff2-variations"), url("/fonts/instrument-sans.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    src: url("/fonts/jetbrains-mono.woff2") format("woff2-variations"), url("/fonts/jetbrains-mono.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

  :root {
    color-scheme: light dark;
    --font-sans: "Instrument Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, Consolas, monospace;
    --radius-ctl: 6px;
    --radius-card: 12px;
    --measure: 68ch;
    --page: 1200px;
    --gutter: clamp(16px, 4vw, 40px);

    /* light: warm parchment (values from the panel's web/src/index.css) */
    --bg: oklch(96.5% 0.009 95);
    --surface: oklch(98.8% 0.005 95);
    --surface-2: oklch(93.5% 0.011 95);
    --surface-3: oklch(90% 0.013 95);
    --border: oklch(88% 0.012 95);
    --border-strong: oklch(60% 0.012 90);
    --fg: oklch(21.5% 0.008 85);
    --fg-muted: oklch(43% 0.012 85);
    --fg-subtle: oklch(50% 0.012 85);
    --accent: oklch(54% 0.197 331);
    --accent-hover: oklch(49% 0.19 331);
    --on-accent: oklch(98.8% 0.005 95);
    --accent-text: oklch(48% 0.18 331);
    --accent-soft: oklch(93% 0.04 331);
    --success-text: oklch(48% 0.12 145);
    --success-soft: oklch(94.5% 0.035 145);
    --danger-text: oklch(50% 0.17 30);
    --danger-soft: oklch(94% 0.03 30);
    --warning-text: oklch(50% 0.105 70);
    --warning-soft: oklch(95% 0.04 85);
    --code-bg: oklch(21.5% 0.008 85);
    --code-fg: oklch(95.5% 0.008 85);
    --code-muted: oklch(78% 0.012 80);
    --code-key: oklch(81% 0.13 331);
    --shadow-color: oklch(20% 0.01 75 / 0.14);
    --shot-shadow: 0 1px 2px var(--shadow-color), 0 18px 48px -12px oklch(20% 0.01 75 / 0.28);
  }

  @media (prefers-color-scheme: dark) {
    :root {
      /* dark: warm near-black, yellow-brown undertone */
      --bg: oklch(17% 0.008 75);
      --surface: oklch(20.5% 0.009 75);
      --surface-2: oklch(24.5% 0.01 75);
      --surface-3: oklch(29% 0.011 75);
      --border: oklch(32% 0.011 75);
      --border-strong: oklch(54% 0.012 78);
      --fg: oklch(95.5% 0.008 85);
      --fg-muted: oklch(80% 0.012 80);
      --fg-subtle: oklch(70% 0.013 78);
      --accent: oklch(73% 0.17 331);
      --accent-hover: oklch(78% 0.15 331);
      --on-accent: oklch(20% 0.04 331);
      --accent-text: oklch(81% 0.13 331);
      --accent-soft: oklch(30% 0.06 331);
      --success-text: oklch(79% 0.14 140);
      --success-soft: oklch(27% 0.04 140);
      --danger-text: oklch(76% 0.14 30);
      --danger-soft: oklch(28% 0.05 30);
      --warning-text: oklch(82% 0.13 78);
      --warning-soft: oklch(29% 0.045 78);
      --code-bg: oklch(13.5% 0.007 75);
      --code-fg: oklch(95.5% 0.008 85);
      --code-muted: oklch(74% 0.012 80);
      --code-key: oklch(81% 0.13 331);
      --shadow-color: oklch(5% 0.005 75 / 0.6);
      --shot-shadow: 0 0 0 1px oklch(32% 0.011 75), 0 24px 60px -16px oklch(5% 0.005 75 / 0.9);
    }
  }
}

@layer base {
  html { scroll-padding-top: 24px; }
  html, body { overflow-x: clip; }
  body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
  }
  a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; }
  a:hover { text-decoration-thickness: 2px; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
  ::selection { background: var(--accent-soft); color: var(--fg); }
  code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.9em; }
  :not(pre) > code {
    background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere;
  }
  strong { font-weight: 650; }
  .vh {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

/* ---------- CHROME: skip link, header, footer (shared with the docs) ---------- */
@layer chrome {
  .skip {
    position: absolute; left: 8px; top: -60px; z-index: 20;
    background: var(--surface); color: var(--fg); padding: 10px 14px;
    border: 2px solid var(--accent); border-radius: var(--radius-ctl);
  }
  .skip:focus { top: 8px; }

  .site-head { border-bottom: 1px solid var(--border); background: var(--bg); }
  .site-head-in {
    max-width: var(--page); margin: 0 auto; padding: 12px var(--gutter);
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  }
  .brand {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
    color: var(--fg); text-decoration: none;
  }
  .brand-mark { width: 30px; height: 30px; flex: none; }
  .brand-mark rect { fill: var(--fg); }
  .brand-mark path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  .brand-name { font-weight: 700; font-stretch: 85%; font-size: 21px; letter-spacing: 0.01em; line-height: 1; }
  .brand-tag { color: var(--fg-muted); font-size: 14px; line-height: 1.2; }
  .site-nav { margin-left: auto; }
  .site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
  .site-nav a {
    display: inline-flex; align-items: center; min-height: 40px; padding: 6px 12px;
    color: var(--fg-muted); text-decoration: none; font-weight: 550; border-radius: var(--radius-ctl);
  }
  .site-nav a:hover { color: var(--fg); background: var(--surface-2); }
  .site-nav a[aria-current] { color: var(--fg); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
  @media (max-width: 599px) {
    .brand-tag { display: none; }
    .site-nav { margin-left: 0; flex-basis: 100%; }
    .site-nav ul { margin-left: -8px; }
    .site-nav a { padding-inline: 8px; }
  }

  .site-foot { border-top: 1px solid var(--border); margin-top: 96px; color: var(--fg-muted); font-size: 15px; }
  .site-foot-in {
    max-width: var(--page); margin: 0 auto; padding: 32px var(--gutter) 40px;
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 40px;
  }
  .site-foot p { margin: 0; }
  .site-foot .maker { color: var(--fg); font-weight: 600; }
  .site-foot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
  .site-foot a { color: var(--fg-muted); display: inline-block; padding: 4px 0; }
  .site-foot a:hover { color: var(--fg); }
}

/* == SHARED END == */

/* ---------- DOCS ---------- */
@layer page {
  .site-foot { margin-top: 64px; }

  /* docs bar: section name + search */
  .docs-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
  .docs-bar-in {
    max-width: var(--page); margin: 0 auto; padding: 10px var(--gutter);
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  }
  .docs-home {
    font-weight: 650; font-stretch: 85%; font-size: 19px; color: var(--fg); text-decoration: none;
    display: inline-flex; align-items: center; min-height: 40px;
  }
  .docs-home:hover { color: var(--accent-text); }
  .search { position: relative; flex: 1 1 260px; max-width: 520px; margin-left: auto; }
  .search svg {
    position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
    fill: none; stroke: var(--fg-subtle); stroke-width: 1.8; stroke-linecap: round; pointer-events: none;
  }
  .search input {
    width: 100%; min-height: 44px; padding: 8px 40px 8px 40px; font-size: 16px;
    color: var(--fg); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-ctl);
  }
  .search input::placeholder { color: var(--fg-subtle); opacity: 1; }
  .search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .search kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted);
    border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 6px; line-height: 20px;
  }
  .search:focus-within kbd { display: none; }
  @media (max-width: 599px) { .search { margin-left: 0; flex-basis: 100%; } .search kbd { display: none; } }

  .results { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter) 14px; }
  .results p { margin: 4px 0 0; color: var(--fg-muted); }
  .results ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
  .results li a {
    display: block; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-ctl); text-decoration: none; color: var(--fg); font-weight: 600;
  }
  .results li a:hover, .results li a:focus-visible { border-color: var(--accent); }
  .results .r-sec { color: var(--fg-subtle); font-family: var(--font-mono); font-size: 12.5px; font-weight: 400; margin-right: 6px; }
  .results .r-snip { color: var(--fg-muted); font-size: 14px; font-weight: 400; display: block; margin-top: 2px; }
  .results mark { background: var(--accent-soft); color: var(--fg); font-weight: 650; border-radius: 2px; padding: 0 1px; }

  /* layout */
  .docs-wrap { max-width: var(--page); margin: 0 auto; padding: 20px var(--gutter) 0; display: grid; gap: 24px; }
  @media (min-width: 960px) {
    .docs-wrap { grid-template-columns: 240px minmax(0, 1fr); gap: 48px; padding-top: 36px; }
  }
  main { min-width: 0; }

  /* sidebar: never its own scroll box - it is as long as it needs to be */
  .side summary {
    cursor: pointer; font-weight: 600; min-height: 44px; padding: 10px 14px; display: flex; align-items: center;
    border: 1px solid var(--border-strong); border-radius: var(--radius-ctl); background: var(--surface);
  }
  .side summary::-webkit-details-marker { display: none; }
  .side summary::after {
    content: ""; margin-left: auto; width: 8px; height: 8px; flex: none;
    border-right: 2px solid var(--fg-muted); border-bottom: 2px solid var(--fg-muted); transform: translateY(-2px) rotate(45deg);
  }
  .side[open] summary::after { transform: translateY(2px) rotate(-135deg); }
  .side summary { list-style: none; }
  @media (min-width: 960px) { .side summary { display: none; } }
  .side nav { padding: 8px 0; }
  .side .sec {
    margin: 22px 0 6px; padding-left: 12px; font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-subtle);
  }
  .side .sec:first-child { margin-top: 4px; }
  .side ul { list-style: none; margin: 0; padding: 0; }
  .side li a {
    display: block; padding: 5px 12px; border-left: 2px solid var(--border); color: var(--fg-muted);
    text-decoration: none; font-size: 15px; line-height: 1.45;
  }
  .side li a:hover { color: var(--fg); border-left-color: var(--border-strong); }
  .side li a[aria-current="page"] { color: var(--fg); font-weight: 650; border-left-color: var(--accent); background: var(--surface); }

  /* article */
  article { max-width: 780px; }
  .wide article { max-width: 1000px; }
  .crumb { font-family: var(--font-mono); font-size: 13px; color: var(--accent-text); display: flex; align-items: center; gap: 10px; }
  .crumb::before { content: ""; width: 22px; height: 2px; background: var(--accent); flex: none; }
  article h1 {
    margin: 10px 0 24px; font-size: clamp(34px, 4.8vw, 52px); line-height: 1.04;
    font-stretch: 78%; font-weight: 650; letter-spacing: -0.015em; text-wrap: balance;
  }
  article h2 {
    margin: 48px 0 12px; padding-top: 20px; border-top: 1px solid var(--border);
    font-size: 28px; line-height: 1.15; font-stretch: 82%; font-weight: 650; letter-spacing: -0.01em;
  }
  article h3 { margin: 32px 0 8px; font-size: 20px; line-height: 1.3; font-weight: 650; }
  article h4 { margin: 24px 0 6px; font-size: 17px; font-weight: 650; }
  article h2, article h3, article h4, article .op { scroll-margin-top: 16px; }
  article p, article ul, article ol, article dl { margin: 0 0 16px; }
  article ul, article ol { padding-left: 24px; }
  article li { margin: 4px 0; }
  article li > ul, article li > ol { margin: 4px 0; }
  /* ~75 characters a line: Instrument Sans' wide '0' makes 1ch ~1.45 average characters */
  article > p, article > ul, article > ol, article > blockquote, article > dl { max-width: 52ch; }
  article li::marker { color: var(--fg-subtle); }
  article hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
  article img { border-radius: var(--radius-ctl); }
  article a { overflow-wrap: anywhere; }

  pre {
    position: relative; background: var(--code-bg); color: var(--code-fg); border: 1px solid var(--border);
    border-radius: var(--radius-card); padding: 16px 18px; margin: 0 0 18px;
    white-space: break-spaces; overflow-wrap: anywhere; line-height: 1.55; font-size: 13.5px;
  }
  pre code { background: none; padding: 0; font-size: 1em; color: inherit; }
  .copy {
    position: absolute; top: 8px; right: 8px; min-height: 32px; min-width: 56px; padding: 4px 10px;
    font-family: var(--font-sans); font-size: 13px; font-weight: 600;
    color: var(--code-fg); background: transparent; border: 1px solid var(--code-muted); border-radius: var(--radius-ctl); cursor: pointer;
  }
  .copy:hover { border-color: var(--code-fg); }
  pre:has(.copy) { padding-top: 46px; }

  table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 15px; }
  th, td { text-align: left; vertical-align: top; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); }
  th { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-subtle); font-weight: 500; border-bottom-color: var(--border-strong); }
  td code { font-size: 0.86em; }
  th[align="center"], td[align="center"] { text-align: center; }
  th[align="right"], td[align="right"] { text-align: right; }
  @media (max-width: 640px) {
    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    tr { border: 1px solid var(--border); border-radius: var(--radius-ctl); margin-bottom: 10px; padding: 6px 0; background: var(--surface); }
    td { border: 0; padding: 4px 14px; }
    th[align], td[align] { text-align: left; }
    td[data-label]::before {
      content: attr(data-label); display: block; font-family: var(--font-mono); font-size: 12px; color: var(--fg-subtle);
    }
  }

  blockquote {
    margin: 0 0 18px; padding: 14px 18px; background: var(--warning-soft);
    border-left: 3px solid var(--warning-text); border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0;
  }
  blockquote p:last-child { margin-bottom: 0; }

  .toc { margin: 0 0 32px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
  .toc p { margin: 0 0 6px; font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-subtle); }
  .toc ul { margin: 0; padding-left: 18px; columns: 2 220px; column-gap: 32px; }
  .toc li { break-inside: avoid; margin: 3px 0; }

  .pager { max-width: 780px; display: flex; justify-content: space-between; gap: 12px; margin: 56px 0 0; flex-wrap: wrap; }
  .pager a {
    flex: 1 1 240px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-card);
    text-decoration: none; background: var(--surface); color: var(--fg); font-weight: 650;
  }
  .pager a:hover { border-color: var(--accent); }
  .pager a span { display: block; font-family: var(--font-mono); font-size: 12.5px; font-weight: 400; color: var(--fg-subtle); }
  .pager .next { text-align: right; }

  /* API reference */
  .api-index { display: flex; flex-wrap: wrap; gap: 6px 8px; }
  .api-index a {
    display: inline-flex; align-items: center; min-height: 32px; padding: 2px 12px;
    border: 1px solid var(--border-strong); border-radius: 999px; text-decoration: none; color: var(--fg); font-size: 14px;
  }
  .api-index a:hover { border-color: var(--accent); }
  .op { margin: 0 0 28px; padding: 4px 0 10px; border-bottom: 1px solid var(--border); }
  .op h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
  .op .path { font-size: 15px; background: none; padding: 0; }
  .method {
    display: inline-block; min-width: 62px; text-align: center; padding: 2px 8px; border-radius: 4px;
    font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; border: 1px solid currentColor;
  }
  .m-get { color: var(--success-text); background: var(--success-soft); }
  .m-post { color: var(--accent-text); background: var(--accent-soft); }
  .m-put, .m-patch { color: var(--warning-text); background: var(--warning-soft); }
  .m-delete { color: var(--danger-text); background: var(--danger-soft); }
  .summary { font-weight: 600; }
  .label { margin: 12px 0 6px; font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-subtle); }
  .req { color: var(--danger-text); font-family: var(--font-mono); font-size: 12px; }
  .note { color: var(--fg-muted); font-style: italic; }
  .responses { padding-left: 20px; }
  .type { color: var(--fg-muted); }
  details > summary { cursor: pointer; }
  .op details > summary { min-height: 32px; display: inline-flex; align-items: center; color: var(--accent-text); font-weight: 600; }

  @media print {
    .site-head, .docs-bar, .side, .pager, .copy, .site-foot { display: none; }
    .docs-wrap { display: block; }
  }
}
