/* ChaosNetBench — MkDocs Material custom theme */
/* Design tokens derived from the V2–V4 visual identity */

/* ─── Fonts: system stack, no external requests ─────────────────────────── */
:root {
  --md-text-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                  Roboto, "Helvetica Neue", Arial, sans-serif;
  --md-code-font: ui-monospace, "SFMono-Regular", "SF Mono", Menlo,
                  Consolas, "Liberation Mono", monospace;

  /* Brand palette */
  --cnb-bg:           #f7f6f3;
  --cnb-bg-alt:       #eeece8;
  --cnb-bg-card:      #ffffff;
  --cnb-navy:         #0d1b2a;
  --cnb-navy-muted:   #4a5568;
  --cnb-navy-light:   #4a5568;
  --cnb-blue:         #0a5fa3;
  --cnb-blue-hover:   #084a82;
  --cnb-blue-light:   #e6f0fb;
  --cnb-amber:        #b55d0a;
  --cnb-amber-light:  #fdf0e6;
  --cnb-border:       #dedad5;

  /* Override Material primary/accent */
  --md-primary-fg-color:         #0a5fa3;
  --md-primary-fg-color--light:  #e6f0fb;
  --md-primary-fg-color--dark:   #084a82;
  --md-primary-bg-color:         #ffffff;
  --md-accent-fg-color:          #0a5fa3;
  --md-default-bg-color:         #f7f6f3;
  --md-default-fg-color:         #0d1b2a;
  --md-default-fg-color--light:  #4a5568;
  --md-default-fg-color--lighter:#4a5568;
  --md-typeset-a-color:          #0a5fa3;
}

/* ─── Base page ──────────────────────────────────────────────────────────── */
.md-main,
body {
  background: var(--cnb-bg);
}

.md-content {
  background: var(--cnb-bg);
}

/* Wider content column on large screens */
.md-grid {
  max-width: 1140px;
}

/* ─── Navigation ─────────────────────────────────────────────────────────── */
.md-header {
  background: var(--cnb-bg);
  color: var(--cnb-navy);
  border-bottom: 1px solid var(--cnb-border);
  box-shadow: 0 1px 3px rgba(13,27,42,0.06);
}

.md-header__button,
.md-header__source .md-source {
  color: var(--cnb-navy);
}

/* The default Material book logo is not a ChaosNetBench identity asset. */
.md-header__button.md-logo,
.md-nav__title .md-logo {
  display: none !important;
}

.md-header__title,
.md-header__topic {
  color: var(--cnb-navy);
  font-weight: 700;
}

.md-tabs {
  background: var(--cnb-bg);
  border-bottom: 1px solid var(--cnb-border);
}

.md-tabs__link {
  color: var(--cnb-navy-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.md-tabs__item--active .md-tabs__link,
.md-tabs__link:hover {
  color: var(--cnb-blue);
  opacity: 1;
}

.md-tabs__indicator {
  background: var(--cnb-blue);
}

/* ─── Headings ───────────────────────────────────────────────────────────── */
.md-typeset h1 {
  color: var(--cnb-navy);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.md-typeset h2 {
  color: var(--cnb-navy);
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--cnb-border);
  padding-bottom: 0.3em;
}

.md-typeset h3 {
  color: var(--cnb-navy);
  font-weight: 700;
}

/* ─── Links ──────────────────────────────────────────────────────────────── */
.md-typeset a {
  color: var(--cnb-blue);
  text-decoration-skip-ink: auto;
}

.md-typeset a:hover {
  color: var(--cnb-blue-hover);
}

/* ─── Code ───────────────────────────────────────────────────────────────── */
.md-typeset code {
  background: var(--cnb-blue-light);
  color: var(--cnb-blue);
  border-radius: 4px;
  padding: 0.15em 0.35em;
  font-size: 0.82em;
}

.md-typeset pre > code {
  background: transparent;
  color: #d4e0ee;
  padding: 0;
  font-size: inherit;
}

.highlight pre,
.md-typeset .highlight {
  background: var(--cnb-navy) !important;
  border-radius: 6px;
}

/* ─── Search ─────────────────────────────────────────────────────────────── */
.md-search__form,
.md-search__input {
  background: var(--cnb-bg-alt);
  color: var(--cnb-navy);
}

.md-search__input::placeholder {
  color: var(--cnb-navy-muted);
  opacity: 1;
}

.md-search__icon,
.md-search__input ~ .md-search__icon {
  color: var(--cnb-navy-muted);
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.md-footer {
  background: var(--cnb-navy);
  color: #a8b8cc;
}

.md-footer-meta {
  background: #081116;
}

/* ─── ━━━ HOMEPAGE CUSTOM LAYOUT ━━━ ────────────────────────────────────── */

/* Force vertical stacking; Material's typeset context must not flow sections as columns */
.md-typeset .cnb-home {
  display: block;
  width: 100%;
}

.md-typeset .cnb-home > section {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  float: none;
  clear: both;
}

.md-typeset .cnb-home > hr {
  display: block;
  clear: both;
  width: 100%;
}

/* Hide default MkDocs h1 on the homepage so we control the hero fully */
.cnb-home .md-content__inner > h1:first-child {
  display: none;
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.cnb-hero {
  padding: 44px 0 40px;
  text-align: left;
}

.cnb-hero__eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cnb-blue);
  margin-bottom: 20px;
}

.cnb-hero__title {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 800;
  color: var(--cnb-navy);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
}

.cnb-hero__tagline {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--cnb-navy-muted);
  max-width: 720px;
  margin: 0 0 14px;
  line-height: 1.45;
  font-weight: 650;
}

.cnb-hero__desc {
  font-size: 0.95rem;
  color: var(--cnb-navy-light);
  max-width: 720px;
  margin: 0 0 26px;
  line-height: 1.65;
}

.cnb-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 20px;
}

.cnb-hero__paper-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.83rem;
  color: var(--cnb-navy-muted);
  text-decoration: none;
}

.cnb-hero__paper-link:hover {
  color: var(--cnb-blue);
  text-decoration: underline;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.cnb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none !important;
  border-radius: 6px;
  border: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.cnb-btn-primary {
  background: var(--cnb-blue);
  color: #fff !important;
  border-color: var(--cnb-blue);
}

.cnb-btn-primary:hover {
  background: var(--cnb-blue-hover);
  border-color: var(--cnb-blue-hover);
}

.cnb-btn-outline {
  background: transparent;
  color: var(--cnb-navy) !important;
  border-color: var(--cnb-border);
}

.cnb-btn-outline:hover {
  border-color: var(--cnb-blue);
  color: var(--cnb-blue) !important;
  background: var(--cnb-blue-light);
}

/* ─── Section scaffold ───────────────────────────────────────────────────── */
.cnb-section {
  padding: 52px 0;
}

.cnb-section--alt {
  background: var(--cnb-bg-alt);
  padding: 52px 0;
  /* negative-margin bleed removed: unreliable inside Material's flex context */
}

.cnb-section__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cnb-blue);
  margin-bottom: 10px;
}

.cnb-section__title {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 700;
  color: var(--cnb-navy);
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 0 0 16px;
}

.cnb-section__lead {
  font-size: 1.02rem;
  color: var(--cnb-navy-muted);
  max-width: 680px;
  line-height: 1.7;
  margin: 0 0 32px;
}

/* ─── Figure presentation ────────────────────────────────────────────────── */
.cnb-figure {
  margin: 40px 0;
  text-align: center;
}

.cnb-figure img,
.cnb-figure svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--cnb-border);
  box-shadow: 0 2px 8px rgba(13,27,42,0.07);
}

.cnb-figure figcaption {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--cnb-navy-muted);
  font-style: italic;
  line-height: 1.5;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.cnb-cards {
  display: grid;
  gap: 18px;
}

.cnb-cards--3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.cnb-cards--5 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.cnb-cards--5 > .cnb-card {
  grid-column: span 2;
}

.cnb-cards--5 > .cnb-card:nth-child(4) {
  grid-column: 2 / span 2;
}

.cnb-cards--2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.cnb-card {
  background: var(--cnb-bg-card);
  border: 1px solid var(--cnb-border);
  border-radius: 10px;
  padding: 26px 22px;
  box-shadow: 0 1px 3px rgba(13,27,42,0.05);
}

.cnb-card__icon {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: var(--cnb-blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--cnb-blue);
  font-family: var(--md-code-font);
  margin-bottom: 14px;
}

.cnb-card__icon--amber {
  background: var(--cnb-amber-light);
  color: var(--cnb-amber);
}

.cnb-card__title {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--cnb-navy);
  margin: 0 0 8px;
  line-height: 1.3;
}

.cnb-card__body {
  font-size: 0.85rem;
  color: var(--cnb-navy-muted);
  line-height: 1.6;
  margin: 0;
}

/* ─── Research preview blocks ────────────────────────────────────────────── */
.cnb-research-preview {
  background: var(--cnb-bg-card);
  border: 1px solid var(--cnb-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(13,27,42,0.06);
}

.cnb-research-preview__fig {
  padding: 24px 24px 0;
}

.cnb-research-preview__fig img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--cnb-border);
}

.cnb-research-preview__body {
  padding: 22px 24px 24px;
}

.cnb-research-preview__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cnb-amber);
  margin-bottom: 8px;
  display: block;
}

.cnb-research-preview__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cnb-navy);
  margin: 0 0 10px;
  line-height: 1.3;
}

.cnb-research-preview__desc {
  font-size: 0.85rem;
  color: var(--cnb-navy-muted);
  line-height: 1.6;
  margin: 0 0 16px;
}

/* ─── Research questions ─────────────────────────────────────────────────── */
.cnb-questions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 32px 0;
}

.cnb-question {
  border-left: 3px solid var(--cnb-blue);
  padding: 12px 0 12px 20px;
}

.cnb-question p {
  margin: 0;
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--cnb-navy);
  line-height: 1.4;
}

/* ─── Start routes ───────────────────────────────────────────────────────── */
.cnb-start-routes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 32px 0;
}

.cnb-start-route {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--cnb-bg-card);
  border: 1px solid var(--cnb-border);
  border-radius: 10px;
  padding: 24px 20px;
  text-decoration: none !important;
  color: var(--cnb-navy) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cnb-start-route:hover {
  border-color: var(--cnb-blue);
  box-shadow: 0 3px 10px rgba(10,95,163,0.12);
}

.cnb-start-route__type {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cnb-navy-light);
}

.cnb-start-route__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cnb-navy);
  line-height: 1.3;
}

.cnb-start-route__desc {
  font-size: 0.82rem;
  color: var(--cnb-navy-muted);
  line-height: 1.5;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media screen and (max-width: 76.1875em) {
  .cnb-section--alt {
    padding: 44px 0;
  }
}

@media screen and (max-width: 600px) {
  .cnb-hero {
    padding: 36px 0 32px;
  }

  .cnb-hero__actions {
    flex-direction: column;
    align-items: center;
  }

  .cnb-btn {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  .cnb-section {
    padding: 36px 0;
  }

  .md-tabs {
    display: none;
  }

  .cnb-cards,
  .cnb-questions,
  .cnb-start-routes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ─── Focus states ───────────────────────────────────────────────────────── */
.cnb-btn:focus-visible,
.cnb-start-route:focus-visible {
  outline: 2px solid var(--cnb-blue);
  outline-offset: 3px;
}

/* ─── Accessibility: reduce motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cnb-btn,
  .cnb-start-route {
    transition: none;
  }
}

/* ─── Long-term project layout refinements ─────────────────────────────── */

/* Keep project identity persistent; top-level tabs already show location. */
.md-header__topic[data-md-component="header-topic"],
.md-header__source {
  display: none;
}

.md-header__topic:first-child {
  opacity: 1 !important;
  transform: none !important;
}

.md-content,
.md-content__inner,
.md-typeset {
  min-width: 0;
}

.md-typeset .arithmatex {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.cnb-hero__facts {
  margin: 18px 0 0;
  color: var(--cnb-navy-muted);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.cnb-figure a {
  display: block;
  border-radius: 8px;
}

.cnb-figure a:focus-visible,
.cnb-research-preview__fig a:focus-visible,
.cnb-text-link:focus-visible {
  outline: 2px solid var(--cnb-blue);
  outline-offset: 3px;
}

.cnb-route-link {
  margin: 28px 0 0;
  text-align: center;
  font-weight: 650;
}

.cnb-text-link {
  display: inline-block;
  color: var(--cnb-blue);
  font-size: 0.84rem;
  font-weight: 650;
  text-decoration: none;
}

.cnb-text-link:hover {
  color: var(--cnb-blue-hover);
  text-decoration: underline;
}

.cnb-research-grid {
  align-items: stretch;
}

.cnb-research-preview {
  display: flex;
  flex-direction: column;
}

.cnb-research-preview__body {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.cnb-research-preview__desc {
  flex: 1;
}

.cnb-figure--wide,
.cnb-figure--research {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
}

@media screen and (max-width: 900px) {
  .cnb-cards--5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cnb-cards--5 > .cnb-card,
  .cnb-cards--5 > .cnb-card:nth-child(4) {
    grid-column: auto;
  }
}

@media screen and (max-width: 600px) {
  .cnb-cards--5 {
    grid-template-columns: minmax(0, 1fr);
  }

  .cnb-hero__facts {
    max-width: 290px;
  }

  .cnb-figure {
    margin: 28px 0;
  }
}

/* ─── Final hierarchy and density pass ──────────────────────────────────── */

.cnb-home .cnb-figure {
  margin: 28px 0 24px;
}

.cnb-research-stack {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.cnb-research-preview--featured .cnb-research-preview__fig {
  padding: 22px 22px 0;
}

.cnb-research-preview--featured .cnb-research-preview__title {
  font-size: 1.18rem;
}

.cnb-research-preview--featured .cnb-research-preview__body {
  padding: 20px 22px 22px;
}

.cnb-research-preview--secondary {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
}

.cnb-research-preview--secondary .cnb-research-preview__fig {
  align-self: center;
  padding: 20px;
}

.cnb-research-preview--secondary .cnb-research-preview__body {
  padding: 24px;
}

.cnb-publication-meta {
  margin: -0.25rem 0 1.2rem;
  color: var(--cnb-navy-light);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.md-typeset pre,
.md-typeset .highlight {
  max-width: 100%;
  overflow-x: auto;
}

.md-copyright__highlight {
  line-height: 1.6;
}

.md-footer-meta a {
  color: #d4e0ee;
}

.md-footer-meta a:hover {
  color: #ffffff;
}

@media screen and (max-width: 760px) {
  .cnb-research-preview--secondary {
    display: flex;
    flex-direction: column;
  }

  .cnb-research-preview--featured .cnb-research-preview__fig,
  .cnb-research-preview--secondary .cnb-research-preview__fig {
    padding: 18px 18px 0;
  }

  .cnb-research-preview--featured .cnb-research-preview__body,
  .cnb-research-preview--secondary .cnb-research-preview__body {
    padding: 20px;
  }
}

/* ─── Pre-deployment two-column hero ────────────────────────────────────── */

.cnb-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(250px, 0.95fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
}

.cnb-hero__main {
  min-width: 0;
}

.cnb-hero__panel {
  background: var(--cnb-blue-light);
  border: 1px solid #c9dcec;
  border-radius: 10px;
  padding: 26px 24px;
  color: var(--cnb-navy);
}

.md-typeset .cnb-hero__panel h2 {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  color: var(--cnb-navy);
  font-size: 0.95rem;
  letter-spacing: 0;
}

.cnb-hero__panel ul {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cnb-hero__panel li {
  margin: 0;
  padding: 2px 0 2px 13px;
  border-left: 2px solid var(--cnb-blue);
  color: var(--cnb-navy-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

@media screen and (max-width: 820px) {
  .cnb-hero__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .cnb-hero__panel {
    width: 100%;
    box-sizing: border-box;
  }
}

@media screen and (max-width: 600px) {
  .cnb-hero__actions {
    align-items: flex-start;
  }

  .cnb-hero__facts {
    max-width: 100%;
  }

  .cnb-hero__panel {
    padding: 22px 20px;
  }
}
