/* =========================================================================
   quell-docs.css
   Local layout engine for the Quell documentation sub-site.

   Load order (see _quarto.yml):
     1. quell-base.css   — ghost tokens, reset, baseline, forms
     2. quell-core.css   — unlayered override surface (Surface A/B/C)
     3. quell-light.css  — structural token set (--spacing-*, --color-*, etc.)
     4. quell-docs.css   — this file, unlayered, wins over all three

   This sheet intentionally declares no @layer of its own. As an unlayered
   sheet loaded last, every rule here already outranks the layered portions
   of quell-base.css and sits alongside quell-core.css's Surface C
   components — matching the project's "no specificity wars" contract.

   Token strategy: quell-core.css and quell-light.css share a token
   vocabulary (--spacing-*, --color-*, --radius-* / --border-radius-*,
   --shadow-*, --size-content-*). This sheet consumes those shared names
   rather than inventing a parallel scale, so a downstream theme swap only
   requires re-declaring tokens, never rule rewrites here.
   ========================================================================= */

:root {
  /* Local layout tokens — namespaced so they never collide with the
     upstream token vocabulary, but still resolve through it. */
  --ods-docs-topnav-height: 3.75rem;
  --ods-docs-sidebar-width: 16rem;
  --ods-docs-body-max-width: var(--size-content-lg, 60rem);
  --ods-docs-gutter: var(--spacing-lg, 1.265rem);
}

/* -------------------------------------------------------------------------
   Layout shell
   ------------------------------------------------------------------------- */

.ods-docs-layout {
  display: grid;
  grid-template-columns: var(--ods-docs-sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--ods-docs-topnav-height) minmax(0, 1fr);
  grid-template-areas:
    "topnav topnav"
    "sidebar body";
  min-block-size: 100dvb;
  background: var(--color-bg-light), var(--color-surface-subtle);

}

/* -------------------------------------------------------------------------
   Top navigation utility
   ------------------------------------------------------------------------- */

.ods-docs-topnav {
  grid-area: topnav;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding-inline: var(--ods-docs-gutter);
  background: var(--color-primary);
  border-block-end: var(--border-width-sm, 0.0625rem) solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-index-sticky, 100);
}

.ods-docs-topnav__brand {
  font-family: var(--font-fam-secondary, var(--font-family-heading));
  font-weight: var(--font-weight-bold, 600);
  color: var(--color-matte-white);
  text-decoration: none;
}

.ods-docs-topnav__links {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

.ods-docs-topnav__links a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm, 0.875rem);
}

.ods-docs-topnav__links a:hover,
.ods-docs-topnav__links a[aria-current="page"] {
  color: var(--color-accent);
}

/* Mobile sidebar toggle — pairs with quell-light.js disclosure module
   (data-q-toggle / data-q-active / aria-expanded). No visual state is
   ever set inline by the script; only these attributes are read. */
.ods-docs-topnav__toggle {
  display: none;
  appearance: none;
  border: var(--border-width-sm, 0.0625rem) solid var(--color-border);
  border-radius: var(--radius-md, var(--border-radius-md));
  background: var(--color-surface);
  color: var(--color-text-primary);
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
}

/* -------------------------------------------------------------------------
   Sidebar column — fixed width on desktop, off-canvas on mobile
   ------------------------------------------------------------------------- */

.ods-docs-sidebar {
  grid-area: sidebar;
  border-inline-end: var(--border-width-sm, 0.0625rem) solid var(--color-border);
  background: var(--color-lighter-grey);
  overflow-y: auto;
  min-inline-size: 0;
  padding: var(--ods-docs-gutter) var(--spacing-md);
}

.ods-docs-sidebar nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxs, var(--spacing-xs));
}

.ods-docs-sidebar nav a {
  display: block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm, var(--border-radius-sm));
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm, 0.875rem);
}

.ods-docs-sidebar nav a:hover {
  background: var(--color-accent-subtle);
  color: var(--color-text-primary);
  /* added font-weight text to light */
  font-weight: 800;
}

.ods-docs-sidebar nav a[data-q-current="true"],
.ods-docs-sidebar nav a[aria-current] {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: var(--font-weight-medium, 500);
}

.ods-docs-sidebar__heading {
  font-size: var(--font-size-sm, 0.85rem);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide, 0.05em);
  color: var(text-muted-grey);
  margin-block: var(--spacing-md) var(--spacing-xs);
}

/* -------------------------------------------------------------------------
   Flexible documentation body
   ------------------------------------------------------------------------- */

.ods-docs-body {
  grid-area: body;
  min-inline-size: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.ods-docs-content {
  max-inline-size: var(--ods-docs-body-max-width);
  margin-inline: auto;
  padding: var(--spacing-xxl, var(--spacing-xl)) var(--ods-docs-gutter);
  min-inline-size: 0;
}

.ods-docs-content > * + * {
  margin-block-start: var(--spacing-md);
}

.ods-docs-content h1,
.ods-docs-content h2,
.ods-docs-content h3 {
  max-inline-size: 100%;
}

/* -------------------------------------------------------------------------
   Resilient code block handling
   Nested technical content (long CLI output, unbroken tokens, wide tables)
   must scroll internally rather than clip or blow out the grid track.
   ------------------------------------------------------------------------- */

.ods-docs-content pre {
  font-family: "JetBrains Mono";
  color: var(--color-text-inverse);
  max-inline-size: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  box-sizing: border-box;
}

.ods-docs-content pre code {
  display: inline-block;
  min-inline-size: 100%;
  white-space: inherit;
}

.ods-docs-content code:not(pre code) {
  overflow-wrap: anywhere;
}

.ods-docs-content table {
  display: block;
  max-inline-size: 100%;
  overflow-x: auto;
}

/* -------------------------------------------------------------------------
   Breakpoint: collapse to single column below 768px
   ------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
  .ods-docs-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topnav"
      "body";
  }

  .ods-docs-topnav__toggle {
    display: inline-flex;
    align-items: center;
  }

  .ods-docs-topnav__links {
    display: none;
  }

  .ods-docs-sidebar {
    position: fixed;
    inset-block: var(--ods-docs-topnav-height) 0;
    inset-inline-start: 0;
    inline-size: min(80vw, var(--ods-docs-sidebar-width));
    transform: translateX(-100%);
    transition: transform var(--transition-speed-normal, var(--duration-base)) var(--transition-ease, var(--ease-default));
    z-index: var(--z-index-overlay, 1000);
    box-shadow: var(--shadow-lg);
  }

  /* Driven by quell-light.js: data-q-active is added/removed on the
     toggle target, never a style attribute. */
  .ods-docs-sidebar[data-q-active] {
    transform: translateX(0);
  }
}
