/* ==========================================================================
   Vesuvius — Repo Overview documentation portal
   Single shared stylesheet. No external dependencies, no build step.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-inset: #eef1f4;
  --bg-sidebar: #f9fafb;
  --bg-code: #f6f8fa;

  --fg: #1f2328;
  --fg-muted: #59636e;
  --fg-subtle: #818b98;

  --border: #d1d9e0;
  --border-muted: #e4e8ed;

  --accent: #0969da;
  --accent-hover: #0550ae;
  --accent-subtle: #ddf4ff;
  --accent-border: #b6e3ff;

  --ok: #1a7f37;
  --ok-subtle: #dafbe1;
  --warn: #9a6700;
  --warn-subtle: #fff8c5;
  --danger: #cf222e;
  --danger-subtle: #ffebe9;
  --info: #0969da;
  --info-subtle: #ddf4ff;

  --radius: 8px;
  --radius-sm: 5px;
  --sidebar-width: 17rem;
  --content-width: 52rem;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
  --shadow: 0 3px 8px rgba(31, 35, 40, 0.09);

  --transition: 150ms ease;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1117;
  --bg-subtle: #151b23;
  --bg-inset: #1c2128;
  --bg-sidebar: #10151c;
  --bg-code: #161b22;

  --fg: #e6edf3;
  --fg-muted: #9198a1;
  --fg-subtle: #6e7681;

  --border: #30363d;
  --border-muted: #21262d;

  --accent: #4493f8;
  --accent-hover: #79b8ff;
  --accent-subtle: #121d2f;
  --accent-border: #1f3a5f;

  --ok: #3fb950;
  --ok-subtle: #12261e;
  --warn: #d29922;
  --warn-subtle: #272115;
  --danger: #f85149;
  --danger-subtle: #2d1618;
  --info: #4493f8;
  --info-subtle: #121d2f;

  --shadow-sm: 0 1px 2px rgba(1, 4, 9, 0.5);
  --shadow: 0 3px 10px rgba(1, 4, 9, 0.6);
}

/* --- Reset ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

/* --- Skip link ------------------------------------------------------------ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

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

.layout {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 2.5rem 4rem;
}

/* --- Sidebar brand + nav -------------------------------------------------- */

.brand {
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.brand__mark {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #8250df);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: -0.02em;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand__title {
  font-weight: 650;
  font-size: 0.95rem;
}

.brand__subtitle {
  font-size: 0.72rem;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.nav__group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nav__label {
  padding: 0 1.25rem;
  margin-bottom: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-subtle);
}

.nav__link {
  display: block;
  padding: 0.34rem 1.25rem 0.34rem 1.4rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition), background var(--transition);
}

.nav__link:hover {
  color: var(--fg);
  background: var(--bg-inset);
}

.nav__link.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-subtle);
  font-weight: 600;
}

.nav__link--sub {
  padding-left: 2.1rem;
  font-size: 0.83rem;
}

.sidebar__footer {
  margin-top: auto;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--fg-subtle);
}

/* --- Topbar (mobile) ------------------------------------------------------ */

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar__toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}

.topbar__title {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-toggle {
  margin-left: auto;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg-subtle);
}

/* --- Breadcrumb ----------------------------------------------------------- */

.breadcrumb {
  font-size: 0.8rem;
  color: var(--fg-subtle);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.breadcrumb__sep {
  color: var(--border);
}

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

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 650;
  scroll-margin-top: 1.5rem;
}

h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.4rem;
  margin: 2.75rem 0 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-muted);
}

h3 {
  font-size: 1.1rem;
  margin: 1.9rem 0 0.6rem;
}

h4 {
  font-size: 0.95rem;
  margin: 1.4rem 0 0.4rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

p {
  margin: 0 0 1rem;
}

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

a:hover {
  text-decoration: underline;
}

.page-lede {
  font-size: 1.075rem;
  color: var(--fg-muted);
  margin-bottom: 1.75rem;
  max-width: 44rem;
}

strong {
  font-weight: 650;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-muted);
  margin: 2.5rem 0;
}

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

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

li {
  margin-bottom: 0.35rem;
}

li > ul,
li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
}

/* Definition-style list used for "key: value" spec blocks */
.spec {
  margin: 0 0 1.25rem;
  display: grid;
  grid-template-columns: minmax(7rem, max-content) 1fr;
  gap: 0.35rem 1.25rem;
  font-size: 0.92rem;
}

.spec dt {
  color: var(--fg-muted);
  font-weight: 600;
}

.spec dd {
  margin: 0;
}

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

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

:not(pre) > code {
  background: var(--bg-code);
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  padding: 0.12em 0.36em;
  white-space: nowrap;
}

pre {
  position: relative;
  margin: 0 0 1.25rem;
  padding: 0.95rem 1.1rem;
  background: var(--bg-code);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-family: var(--font-sans);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
}

pre:hover .copy-btn,
.copy-btn:focus {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--fg);
}

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

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  background: var(--bg-subtle);
  font-weight: 650;
  white-space: nowrap;
}

th,
td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-muted);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

td code {
  white-space: nowrap;
}

/* --- Callouts ------------------------------------------------------------- */

.note {
  display: block;
  margin: 0 0 1.5rem;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--info);
  background: var(--info-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
}

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

.note__title {
  display: block;
  font-weight: 650;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
  color: var(--info);
}

.note--warn {
  border-left-color: var(--warn);
  background: var(--warn-subtle);
}

.note--warn .note__title {
  color: var(--warn);
}

.note--ok {
  border-left-color: var(--ok);
  background: var(--ok-subtle);
}

.note--ok .note__title {
  color: var(--ok);
}

/* --- Cards (section landing pages + home) --------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition),
    transform var(--transition);
}

.card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}

.card__title {
  font-weight: 650;
  color: var(--accent);
  font-size: 0.95rem;
}

.card__desc {
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

.card__meta {
  font-size: 0.72rem;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

/* --- Stat strip ----------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}

.stat {
  padding: 0.85rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}

.stat__value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat__label {
  display: block;
  font-size: 0.74rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.15rem;
}

/* --- Figures / diagrams --------------------------------------------------- */

figure {
  margin: 0 0 1.75rem;
}

figure svg,
figure img {
  display: block;
  width: 100%;
  height: auto;
}

.diagram {
  padding: 1.1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  overflow-x: auto;
}

.figure--diagram .diagram {
  padding: 0;
}

.diagram__frame {
  display: block;
  width: 100%;
  height: var(--diagram-height, 34rem);
  border: 0;
  background: transparent;
}

.diagram--pending {
  border-style: dashed;
  color: var(--fg-muted);
  font-size: 0.88rem;
}

.diagram--pending p {
  margin: 0;
}

.diagram--pending p + p {
  margin-top: 0.4rem;
}

.diagram--pending strong {
  color: var(--fg);
}

.diagram svg {
  min-width: 34rem;
}

figcaption {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 100%;
  color: var(--fg-muted);
}

figcaption strong {
  color: var(--fg);
}

/* --- Photographic figures ------------------------------------------------- */

.figure--media img {
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-sm);
}

.figure--hero {
  margin-bottom: 2rem;
}

.figure--hero img {
  border: 0;
  border-radius: var(--radius);
  box-shadow: none;
}

/* --- In-page table of contents -------------------------------------------- */

.toc {
  margin: 0 0 2rem;
  padding: 0.9rem 1.1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.toc__title {
  font-weight: 650;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  margin-bottom: 0.4rem;
}

.toc ol {
  margin: 0;
  padding-left: 1.2rem;
  columns: 2;
  column-gap: 1.5rem;
}

.toc li {
  margin-bottom: 0.2rem;
  break-inside: avoid;
}

@media (max-width: 46rem) {
  .toc ol {
    columns: 1;
  }
}

/* --- Pager ---------------------------------------------------------------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-muted);
  font-size: 0.875rem;
}

.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 48%;
  text-decoration: none;
}

.pager__dir {
  font-size: 0.7rem;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pager__title {
  font-weight: 600;
}

.pager__next {
  margin-left: auto;
  text-align: right;
}

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

.footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 2.5rem 3rem;
  border-top: 1px solid var(--border-muted);
  font-size: 0.8rem;
  color: var(--fg-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  justify-content: space-between;
}

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

@media (max-width: 64rem) {
  .content {
    padding: 1.75rem 1.5rem 3.5rem;
  }

  .footer {
    padding: 1.5rem 1.5rem 3rem;
  }
}

@media (max-width: 52rem) {
  .topbar {
    display: flex;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow);
    padding-top: 1rem;
  }

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

  body.nav-open {
    overflow: hidden;
  }

  .sidebar__scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(1, 4, 9, 0.45);
  }

  body.nav-open .sidebar__scrim {
    display: block;
  }

  .brand {
    display: none;
  }

  .content {
    padding: 1.5rem 1.15rem 3rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .footer {
    padding: 1.25rem 1.15rem 2.5rem;
  }
}

/* --- Print ---------------------------------------------------------------- */

@media print {
  .sidebar,
  .topbar,
  .pager,
  .copy-btn,
  .sidebar__scrim {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .content,
  .footer {
    max-width: none;
    padding: 0;
  }

  body {
    font-size: 11pt;
  }

  pre {
    white-space: pre-wrap;
    word-break: break-word;
  }

  a {
    color: inherit;
  }
}
