/*
 * Fenwave documentation theme.
 *
 * Design tokens are ported from fenwave-landing (app/css/style.css) so the
 * docs and the marketing site read as one product: same brand blue, same dark
 * surfaces, same Inter/JetBrains pairing, same tight tracking.
 *
 * Written as plain CSS rather than Tailwind: Jekyll builds with Ruby only, and
 * adding a Node/PostCSS step to a docs build would double its toolchain for no
 * reader-visible gain.
 */

:root {
  --brand-50: #eff6ff;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  /* Surfaces — matched to the IDP login screen for visual continuity. */
  --ink: #0b1220;
  --bg-deep: #0f172a;
  --bg-mid: #1e293b;
  --bg-raised: #172033;

  --border: #1e293b;
  --border-soft: #16203300;

  --text: #e2e8f0;
  --text-bright: #f8fafc;
  /* 5.08:1 on --bg-deep. Tailwind's slate-500/600 fail AA here; do not use. */
  --muted: #7b8a9f;

  --font-sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w: 17rem;
  --toc-w: 15rem;
  --header-h: 4rem;
  --radius: 0.5rem;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  letter-spacing: -0.017em;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-400);
  text-decoration: none;
}
a:hover {
  color: var(--brand-300);
}

/* ── Header ─────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--ink) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand:hover {
  color: var(--text-bright);
}
/* Sized by height so the wordmark's 4.9:1 aspect ratio drives the width. */
.brand-logo {
  height: 1.35rem;
  width: auto;
  display: block;
}
.brand-sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.95rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}

.header-spacer {
  flex: 1;
}

/* ── Language switcher ──────────────────────────────────────────────── */

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-mid) 40%, transparent);
}
.lang-switch a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.lang-switch a:hover {
  color: var(--text-bright);
}
.lang-switch a[aria-current='true'] {
  background: var(--brand-600);
  color: #fff;
}

/* ── Search ─────────────────────────────────────────────────────────── */

.search {
  position: relative;
  width: min(22rem, 40vw);
}
.search input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-mid) 45%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}
.search input::placeholder {
  color: var(--muted);
}
.search input:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 25%, transparent);
}
.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  max-height: 24rem;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px -12px rgb(0 0 0 / 0.6);
  padding: 0.35rem;
}
.search-results:empty {
  display: none;
}
.search-results a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 0.375rem;
  color: var(--text);
}
.search-results a:hover,
.search-results a.is-active {
  background: color-mix(in srgb, var(--brand-600) 22%, transparent);
}
.search-results .r-title {
  font-weight: 500;
  font-size: 0.9rem;
}
.search-results .r-crumb {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}
.search-empty {
  padding: 0.75rem 0.6rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 2.5rem;
  max-width: 96rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: start;
}

.sidebar,
.toc {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1.75rem 0 3rem;
  scrollbar-width: thin;
}

.content {
  min-width: 0;
  padding: 2.25rem 0 5rem;
}

/* ── Sidebar nav ────────────────────────────────────────────────────── */

.nav-section {
  margin-bottom: 1.35rem;
}
.nav-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  padding-left: 0.65rem;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list .nav-list {
  margin-left: 0.65rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}
.nav-list a {
  display: block;
  padding: 0.3rem 0.65rem;
  border-radius: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}
.nav-list a:hover {
  color: var(--text-bright);
  background: color-mix(in srgb, var(--bg-mid) 55%, transparent);
}
.nav-list a[aria-current='page'] {
  color: var(--text-bright);
  background: color-mix(in srgb, var(--brand-600) 20%, transparent);
  box-shadow: inset 2px 0 0 var(--brand-500);
}

/* ── Table of contents ──────────────────────────────────────────────── */

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc li ul {
  padding-left: 0.75rem;
}
.toc a {
  display: block;
  padding: 0.22rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  border-left: 2px solid transparent;
  padding-left: 0.7rem;
  margin-left: -0.7rem;
}
.toc a:hover {
  color: var(--text);
}
.toc a.is-active {
  color: var(--brand-300);
  border-left-color: var(--brand-500);
}

/* ── Prose ──────────────────────────────────────────────────────────── */

.prose {
  max-width: 46rem;
}
.prose h1 {
  font-size: 2.25rem;
  line-height: 1.277;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  background: linear-gradient(
    to right,
    rgb(226 232 240 / 0.65),
    rgb(226 232 240),
    rgb(226 232 240 / 0.65)
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prose h2 {
  font-size: 1.5rem;
  line-height: 1.415;
  letter-spacing: -0.017em;
  color: var(--text-bright);
  margin: 2.75rem 0 0.85rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.prose h3 {
  font-size: 1.15rem;
  color: var(--text-bright);
  margin: 2rem 0 0.6rem;
}
.prose h4 {
  font-size: 1rem;
  color: var(--text-bright);
  margin: 1.5rem 0 0.5rem;
}
.prose p,
.prose li {
  color: var(--text);
}
.prose ul,
.prose ol {
  padding-left: 1.25rem;
}
.prose li {
  margin: 0.3rem 0;
}
.prose strong {
  color: var(--text-bright);
  font-weight: 600;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}
/* Pages often end a section with `---` right before the next `##`, which would
   draw two rules a few pixels apart. The heading keeps its own. */
.prose hr + h2 {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.prose img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  border-radius: 0.3rem;
  background: color-mix(in srgb, var(--bg-mid) 70%, transparent);
  color: var(--brand-200);
}
.prose pre {
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}
.prose pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

/* Tables scroll inside their own container so the page never scrolls
   sideways — the permission and troubleshooting tables are wide. */
.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}
.prose th,
.prose td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.prose th {
  background: color-mix(in srgb, var(--bg-mid) 55%, transparent);
  color: var(--text-bright);
  font-weight: 600;
  white-space: nowrap;
}
.prose tbody tr:last-child td {
  border-bottom: none;
}

/* ── Admonitions (MkDocs `!!! note` converted at build time) ─────────── */

.admonition {
  margin: 1.35rem 0;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-500);
  background: color-mix(in srgb, var(--bg-mid) 40%, transparent);
}
.admonition > :first-child {
  margin-top: 0;
}
.admonition > :last-child {
  margin-bottom: 0;
}
.admonition-title {
  font-weight: 600;
  color: var(--text-bright);
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}
.admonition.warning {
  border-left-color: #f59e0b;
}
.admonition.danger {
  border-left-color: #ef4444;
}
.admonition.tip {
  border-left-color: #10b981;
}

/* ── Page footer nav ────────────────────────────────────────────────── */

.page-nav {
  display: flex;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-mid) 30%, transparent);
  color: var(--text);
}
.page-nav a:hover {
  border-color: var(--brand-600);
}
.page-nav .dir {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.page-nav .next {
  text-align: right;
}

/* ── Home hero ──────────────────────────────────────────────────────── */

.hero {
  position: relative;
  padding: 5rem 1.5rem 3.5rem;
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.hero::before {
  content: '';
  position: absolute;
  inset: -40% 0 auto 50%;
  translate: -50% 0;
  width: 55rem;
  height: 40rem;
  background: radial-gradient(
    closest-side,
    color-mix(in srgb, var(--brand-600) 28%, transparent),
    transparent
  );
  pointer-events: none;
}
.hero > * {
  position: relative;
}
.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 500;
  background: linear-gradient(to right, var(--brand-500), var(--brand-200));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.85rem;
}
.hero h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--text-bright);
}
.hero p {
  max-width: 42rem;
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: 1.05rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(
    to right,
    rgb(255 255 255 / 0.85),
    #fff,
    rgb(255 255 255 / 0.85)
  );
  color: #0f172a;
}
.btn-secondary {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-mid) 35%, transparent);
  color: var(--text);
}
.btn-secondary:hover {
  color: var(--text-bright);
  border-color: var(--brand-600);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  max-width: 72rem;
  margin: 3rem auto 0;
  padding: 0 1.5rem;
}
.card {
  display: block;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-mid) 30%, transparent);
  color: var(--text);
  transition: border-color 0.15s ease;
}
.card:hover {
  border-color: var(--brand-600);
  color: var(--text);
}
.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--text-bright);
}
.card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Footer ─────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */

.nav-toggle {
  display: none;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .nav-toggle {
    display: block;
  }
  .search {
    width: 100%;
  }
  .brand-sub {
    display: none;
  }
  .sidebar {
    display: none;
    position: fixed;
    inset: var(--header-h) 0 0;
    z-index: 30;
    max-height: none;
    background: var(--bg-deep);
    padding: 1.25rem 1.5rem 3rem;
    border-right: none;
  }
  .sidebar.is-open {
    display: block;
  }
}
