/*
 * PwrAgent docs site — Tangerine Terminal theme.
 *
 * Tokens lifted from docs/UI-THEME.md and
 * apps/desktop/src/renderer/src/styles/app.css. Keep this stylesheet
 * thin — defer to those two files when extending. Visual rules per
 * docs/design/desktop-style-guide.md: dense, editorial, sparse
 * tangerine signal, no decorative gradients, no orange-dominant panels.
 */

:root {
  --bg-app: #000000;
  --bg-sidebar: #050505;
  --bg-panel: #0a0a0a;
  --bg-panel-elevated: #101010;
  --bg-panel-hover: #14110d;
  --bg-row-active: #120800;
  --bg-input: #080808;

  --border-subtle: rgba(247, 243, 235, 0.10);
  --border-strong: rgba(247, 243, 235, 0.20);

  --text-primary: #f7f3eb;
  --text-secondary: #b8b0a5;
  --text-muted: #8c857a;

  --accent: #ff8a1f;
  --accent-strong: #ffa33d;
  --accent-bright: #ffb35c;
  --accent-soft: rgba(255, 138, 31, 0.12);
  --accent-border: rgba(255, 138, 31, 0.42);
  --accent-shadow: rgba(255, 138, 31, 0.34);

  --status-ok: #5fa969;
  --status-warning: #d99a3d;
  --status-suspended: #6b6660;
  --status-error: #c45a3a;

  --font-sans: "Inter", "Geist", "IBM Plex Sans", "SF Pro Text", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", SFMono-Regular, "SF Mono", Consolas, monospace;

  --content-max: 70ch;
  --shell-max: 104ch;
}

@supports (font-variation-settings: normal) {
  :root {
    --font-sans: "InterVariable", "Inter", "Geist", "IBM Plex Sans", "SF Pro Text", system-ui, sans-serif;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-app);
}

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent);
  color: #000;
}

/* ----- Skip-to-content link -----
 * Visually hidden until a keyboard user tabs to it as the first
 * focusable element on the page, then appears as a prominent
 * button anchored to the top-left so the user can skip past the
 * top nav and land directly in the main content area. The <main>
 * is `tabindex="-1"` so the anchor jump actually moves focus
 * (browser default puts focus on the URL bar, not the target). */

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: #000;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border-radius: 6px;
  transform: translateY(-200%);
  transition: transform 120ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

/* Don't paint a focus ring around the <main> just because the
 * skip-link bumped focus there — the visible page content already
 * tells the user where they are. */
#main-content:focus {
  outline: none;
}

/* ----- Site header ----- */

.site-header {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(120%) blur(6px);
  -webkit-backdrop-filter: saturate(120%) blur(6px);
}

.site-header__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: none;
}

.site-brand__logo {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 7px;
}

.site-brand__mark {
  display: inline-block;
}

.site-brand__accent {
  color: var(--accent);
}

.site-brand__tagline {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding-left: 10px;
  border-left: 1px solid var(--border-subtle);
}

/* ----- Hero wordmark (index page) -----
 * Mirrors the chip on the macOS DMG install background — dark rounded
 * panel, big chunky wordmark, slim tagline under it. */

.wordmark-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 8px 0 40px;
  padding: 36px 32px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.wordmark-hero__mark {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.wordmark-hero__accent {
  color: var(--accent);
}

.wordmark-hero__tagline {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .wordmark-hero {
    padding: 28px 20px;
  }
  .wordmark-hero__mark {
    font-size: 42px;
  }
}

/* ----- Screenshot hero (index page) -----
 * Real product screenshot as the landing-page opener. Sits flush at
 * the full content width with a thin frame matching the rest of the
 * image styling, plus a small caption beneath. */

.screenshot-hero {
  margin: 8px 0 40px;
  padding: 0;
}

.screenshot-hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.screenshot-hero figcaption {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ----- In-page screenshot figure -----
 * Used by `_includes/figure.html` for every body-level screenshot.
 * Caption sits inside the bordered frame as a strip beneath the
 * image — the image + caption read as one figure object so a
 * reader can decode the screenshot without scrolling back to the
 * surrounding prose. */

.screenshot {
  margin: 1.6em 0 2em;
  padding: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.screenshot img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 0;
}

.screenshot figcaption {
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.screenshot figcaption strong {
  color: var(--text-primary);
  font-weight: 600;
}

.screenshot figcaption code {
  font-size: 0.92em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 13.5px;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.005em;
  transition: color 120ms ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--accent);
  outline: none;
}

.site-nav__group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.site-nav__head {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.site-nav__top {
  display: inline-flex;
  align-items: center;
  padding: 6px 0;
}

/* Cosmetic caret on hover-capable pointers. Touch + mobile
   replace this with an explicit .site-nav__toggle button. */
@media (hover: hover) and (pointer: fine) {
  .site-nav__top::after {
    content: "▾";
    margin-left: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    transform: translateY(-1px);
    transition: color 120ms ease;
  }

  .site-nav__top--sub::after {
    content: "▸";
  }

  .site-nav__group:hover .site-nav__top::after,
  .site-nav__group:focus-within .site-nav__top::after,
  .site-nav__group--sub:hover .site-nav__top--sub::after,
  .site-nav__group--sub:focus-within .site-nav__top--sub::after {
    color: var(--accent);
  }
}

/* Explicit tap-target shown only when CSS can't rely on hover.
   Hidden by default on hover-capable desktop pointers. */
.site-nav__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 8px 10px;
  margin: -8px 0 -8px 2px;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
}

.site-nav__toggle::before {
  content: "▾";
  font-size: 11px;
  display: inline-block;
  transition: transform 160ms ease;
}

.site-nav__toggle--sub::before {
  content: "▸";
}

.site-nav__toggle[aria-expanded="true"]::before {
  transform: rotate(180deg);
}

.site-nav__toggle--sub[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.site-nav__toggle:hover,
.site-nav__toggle:focus-visible {
  color: var(--accent);
  background: var(--bg-panel-hover);
  outline: none;
}

.site-nav__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: -14px;
  min-width: 240px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  z-index: 20;
}

/* Hover/focus reveal — only when the pointer can hover. */
@media (hover: hover) and (pointer: fine) {
  .site-nav__group:hover > .site-nav__dropdown,
  .site-nav__group:focus-within > .site-nav__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

.site-nav__dropdown li {
  margin: 0;
}

.site-nav__dropdown a {
  display: block;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.site-nav__dropdown a:hover,
.site-nav__dropdown a:focus-visible {
  background: var(--bg-panel-hover);
  color: var(--accent);
}

/* Nested Providers submenu — sits inside .site-nav__dropdown as a <li>. */
.site-nav__group--sub {
  position: relative;
}

.site-nav__head--sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.site-nav__head--sub .site-nav__top {
  flex: 1;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.site-nav__head--sub .site-nav__top:hover,
.site-nav__head--sub .site-nav__top:focus-visible {
  background: var(--bg-panel-hover);
  color: var(--accent);
}

.site-nav__subdropdown {
  position: absolute;
  top: -7px;
  left: 100%;
  min-width: 200px;
  margin: 0 0 0 4px;
  padding: 6px 0;
  list-style: none;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  z-index: 21;
}

@media (hover: hover) and (pointer: fine) {
  .site-nav__group--sub:hover > .site-nav__subdropdown,
  .site-nav__group--sub:focus-within > .site-nav__subdropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
  }
}

.site-nav__subdropdown li {
  margin: 0;
}

.site-nav__subdropdown a {
  display: block;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.site-nav__subdropdown a:hover,
.site-nav__subdropdown a:focus-visible {
  background: var(--bg-panel-hover);
  color: var(--accent);
}

/* Touch pointers (iPad, phones large enough to fall outside the
   <=720px mobile media query): hide hover-cosmetic carets, show
   the real toggle buttons, drive visibility from aria-expanded. */
@media (hover: none), (pointer: coarse) {
  .site-nav__top::after { content: none; }
  .site-nav__toggle { display: inline-flex; }

  .site-nav__dropdown,
  .site-nav__subdropdown {
    opacity: 0;
    visibility: hidden;
  }

  .site-nav__group:has(> .site-nav__head > .site-nav__toggle[aria-expanded="true"]) > .site-nav__dropdown,
  .site-nav__group--sub:has(> .site-nav__head > .site-nav__toggle[aria-expanded="true"]) > .site-nav__subdropdown {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}

.site-nav__github {
  color: var(--text-muted) !important;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0;
}

.site-nav__github:hover {
  color: var(--accent-strong) !important;
}

/* ----- Main + page ----- */

.site-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 56px 24px 96px;
  /* Clip text-selection paint to this column so multi-block
   * selections don't bleed orange edge-to-edge across the empty
   * rails on either side. */
  contain: paint;
}

.page > *:first-child {
  margin-top: 0;
}

.page > *:last-child {
  margin-bottom: 0;
}

/* ----- Typography ----- */

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 2em 0 0.6em;
}

/* Sticky-header offset for anchor-jumps. The header is
   position: sticky on desktop (~50px tall + border), so anchor
   targets need a top margin or they land underneath the header.
   Mobile drops sticky (`.site-header { position: static }` in the
   mobile media query below), so this only fires on desktop. */
@media (min-width: 721px) {
  .page :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: 72px;
  }
}

h1 {
  font-size: 30px;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 0.4em;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 20px;
  margin-top: 2.4em;
  padding-top: 1.4em;
  border-top: 1px solid var(--border-subtle);
}

.page > h1 + p,
.page > h1 + blockquote {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.55;
  margin-top: 0;
}

h3 {
  font-size: 16px;
  margin-top: 1.8em;
  color: var(--text-primary);
}

h4 {
  font-size: 12.5px;
  margin-top: 1.5em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

p {
  margin: 0 0 1em;
}

p:last-child {
  margin-bottom: 0;
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

em {
  color: var(--text-secondary);
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 2.4em 0;
}

a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: rgba(255, 138, 31, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  text-decoration-color: var(--accent);
  outline: none;
}

/* ----- Lists ----- */

ul, ol {
  padding-left: 1.4em;
  margin: 0 0 1.1em;
}

li {
  margin: 0.25em 0;
}

li > p {
  margin: 0.4em 0;
}

li::marker {
  color: var(--text-muted);
}

/* ----- Code ----- */

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-panel);
  color: var(--accent-bright);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

/* Keyboard key glyphs (<kbd>↑</kbd>, <kbd>Cmd+Z</kbd>). Slightly
 * heavier border and softer background than <code> so a key reads
 * as a key, not as code. Inherits text-primary so contrast against
 * the page background stays at ≈19:1. */
kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-panel-elevated);
  padding: 0.1em 0.45em;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 var(--border-strong);
  line-height: 1.2;
  white-space: nowrap;
}

pre {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 1.3em 0;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.highlight {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  margin: 1.3em 0;
  overflow: hidden;
}

.highlight pre {
  background: transparent;
  border: 0;
  border-radius: 0;
  margin: 0;
}

/* ----- Tables ----- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 14px;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.55em 0.8em;
  border-bottom: 1px solid var(--border-subtle);
}

thead th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-panel);
}

tbody tr:hover {
  background: var(--bg-panel-elevated);
}

td code {
  font-size: 0.9em;
  background: var(--bg-app);
}

/* ----- Blockquote ----- */

blockquote {
  margin: 1.4em 0;
  padding: 0.5em 1em;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 0.96em;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote strong {
  color: var(--text-primary);
}

/* ----- Images ----- */

img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

/* ----- Footer ----- */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 28px 24px;
  margin-top: 64px;
  background: var(--bg-sidebar);
}

.site-footer__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

.site-footer__brand {
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-footer__accent {
  color: var(--accent);
}

.site-footer__meta a {
  color: var(--text-muted);
}

.site-footer__meta a:hover {
  color: var(--accent);
}

/* ----- Responsive ----- */

@media (max-width: 720px) {
  /* Header scrolls away normally on mobile — sticky + always-expanded
     dropdowns covered most of the viewport. */
  .site-header {
    position: static;
    padding: 10px 18px;
  }

  .site-header__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .site-brand {
    align-self: flex-start;
  }

  /* Stack groups + GitHub link as full-width rows so nothing wraps
     into someone else's whitespace. */
  .site-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    font-size: 14px;
  }

  .site-nav__group {
    display: block;
  }

  .site-nav__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .site-nav__top {
    flex: 1;
    padding: 10px 0;
  }

  .site-nav__top::after { content: none; }

  /* Mobile toggle reads as an obvious tap target — outlined chevron
     pill in the accent color rather than a dim text character. */
  .site-nav__toggle {
    display: inline-flex;
    min-width: 44px;
    height: 32px;
    padding: 0 12px;
    margin: 0;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: 6px;
  }

  .site-nav__toggle::before {
    font-size: 16px;
    line-height: 1;
    font-weight: 700;
  }

  .site-nav__toggle:hover,
  .site-nav__toggle:focus-visible,
  .site-nav__toggle[aria-expanded="true"] {
    color: var(--accent-strong);
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .site-nav__dropdown,
  .site-nav__subdropdown {
    position: static;
    min-width: 0;
    margin: 0 0 6px 12px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    height: 0;
    overflow: hidden;
    transform: none;
  }

  .site-nav__group:has(> .site-nav__head > .site-nav__toggle[aria-expanded="true"]) > .site-nav__dropdown,
  .site-nav__group--sub:has(> .site-nav__head > .site-nav__toggle[aria-expanded="true"]) > .site-nav__subdropdown {
    opacity: 1;
    visibility: visible;
    height: auto;
  }

  .site-nav__dropdown a,
  .site-nav__subdropdown a {
    padding: 8px 0;
    font-size: 13.5px;
    white-space: normal;
  }

  .site-nav__dropdown a:hover,
  .site-nav__subdropdown a:hover,
  .site-nav__dropdown a:focus-visible,
  .site-nav__subdropdown a:focus-visible {
    background: transparent;
  }

  .site-nav__head--sub .site-nav__top {
    padding: 8px 0;
    font-size: 13.5px;
  }

  .site-nav__github {
    padding: 10px 0;
  }

  .site-main {
    padding: 24px 18px 60px;
  }

  /* Wide tables (4-col Settings references on provider pages, etc.)
     get their own horizontal scroll so they don't push body width. */
  .page table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
