/* ============================================================
   MaterialsHub Documentation — design system
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* palette */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --ink: #15161a;
  --ink-soft: #3c3f46;
  --muted: #71757f;
  --faint: #9aa0aa;
  --border: #e8eaef;
  --border-strong: #d8dbe2;

  --brand: #8a2b5f;
  --brand-ink: #6f2350;
  --blue: #2b5fa8;
  --accent: #b4471f;
  --brand-grad: linear-gradient(120deg, #2b5fa8 0%, #8a2b5f 100%);
  --brand-tint: rgba(138, 43, 95, .08);
  --blue-tint: rgba(43, 95, 168, .08);

  --code-bg: #f3f4f7;

  --header-h: 60px;
  --sidebar-w: 280px;
  --toc-w: 232px;
  --radius: 14px;
  --radius-sm: 9px;

  --shadow-sm: 0 1px 2px rgba(20,22,30,.05);
  --shadow: 0 1px 3px rgba(20,22,30,.06), 0 10px 30px rgba(20,22,30,.06);
  --shadow-lg: 0 18px 50px rgba(20,22,30,.14);

  --maxw: 780px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--brand-tint); }

/* ----------------------------------------------------------------
   Top header
   ---------------------------------------------------------------- */
.docheader {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 22px;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.docheader .hbrand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.docheader .logo-img { height: 24px; width: auto; display: block; }
.docheader .hbrand .divider { width: 1px; height: 22px; background: var(--border-strong); }
.docheader .hbrand .t-sub { font-weight: 600; font-size: 13px; color: var(--muted); letter-spacing: -.01em; }
@media (max-width: 560px) { .docheader .hbrand .divider, .docheader .hbrand .t-sub { display: none; } }
.docheader .spacer { flex: 1; }
.docheader .hlink {
  text-decoration: none; color: var(--ink-soft); font-size: 13.5px; font-weight: 600;
  padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface);
  transition: border-color .15s, color .15s, transform .12s;
}
.docheader .hlink:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); text-decoration: none; }

.menu-btn {
  display: none; width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-size: 17px; line-height: 1;
}

/* ----------------------------------------------------------------
   Layout
   ---------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
  max-width: 1400px; margin: 0 auto;
}

/* Sidebar */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 22px 14px 48px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: #e2e4ea; border-radius: 9px; border: 2px solid var(--surface); }

.nav-group { margin-bottom: 18px; }
.nav-group h4 {
  margin: 6px 12px 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--faint);
}
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 0;
  color: var(--ink-soft); text-decoration: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  transition: background .14s, color .14s;
}
.nav a .ic { font-size: 15px; width: 18px; text-align: center; filter: grayscale(.15); }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active {
  background: var(--brand-tint); color: var(--brand-ink); font-weight: 600;
}
.nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}

/* nested sub-pages */
.subnav { margin: 1px 0 6px; padding-left: 16px; border-left: 1px solid var(--border); margin-left: 19px; }
.subnav a { padding: 6px 10px; font-size: 13px; font-weight: 500; color: var(--muted); }
.subnav a:hover { color: var(--ink); }
.subnav a.active { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.subnav a.active::before { left: -17px; top: 6px; bottom: 6px; }
.nav a.parent-active { color: var(--brand-ink); }
.subnav-deep { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.subnav-deep a { font-size: 12.5px; padding: 5px 10px; }

/* Content */
.content {
  min-width: 0;
  padding: 46px 56px 90px;
  margin: 0 auto;
  width: 100%;
  max-width: calc(var(--maxw) + 112px);
}

/* Right TOC */
.toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 46px 20px 48px 8px;
}
.toc h5 { margin: 0 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.toc a {
  display: block; padding: 4px 0 4px 12px; margin: 1px 0;
  border-left: 2px solid var(--border);
  color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.4;
  transition: color .14s, border-color .14s;
}
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--brand-ink); border-left-color: var(--brand); font-weight: 600; }
.toc:empty { display: none; }

/* ----------------------------------------------------------------
   Typography
   ---------------------------------------------------------------- */
.content h1 {
  font-size: 34px; line-height: 1.15; letter-spacing: -.02em;
  margin: 0 0 10px; font-weight: 800;
}
.content h2 {
  font-size: 22px; letter-spacing: -.01em; margin: 48px 0 14px;
  font-weight: 700; padding-top: 6px; scroll-margin-top: calc(var(--header-h) + 16px);
}
.content h3 { font-size: 17px; margin: 30px 0 8px; font-weight: 700; letter-spacing: -.01em; }
.content p { margin: 13px 0; color: var(--ink-soft); }
.content ul, .content ol { margin: 13px 0; padding-left: 22px; color: var(--ink-soft); }
.content li { margin: 6px 0; }
.content li::marker { color: var(--faint); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.lead { font-size: 19px; line-height: 1.6; color: var(--muted); margin: 4px 0 18px; font-weight: 400; }

.breadcrumb { font-size: 12.5px; color: var(--faint); margin-bottom: 16px; font-weight: 500; }
.breadcrumb a { color: var(--faint); }
.breadcrumb a:hover { color: var(--muted); text-decoration: none; }

/* ----------------------------------------------------------------
   Hero (home)
   ---------------------------------------------------------------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 44px 40px;
  background: var(--brand-grad);
  color: #fff; margin: 4px 0 30px;
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(900px 300px at 90% -20%, rgba(255,255,255,.22), transparent 60%);
  pointer-events: none;
}
.hero h1 { color: #fff; font-size: 38px; margin: 0 0 10px; position: relative; }
.hero p { color: rgba(255,255,255,.92); font-size: 18px; margin: 0; max-width: 60ch; position: relative; }
.hero .cta { margin-top: 22px; display: flex; gap: 12px; flex-wrap: wrap; position: relative; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  text-decoration: none; transition: transform .12s, box-shadow .12s, background .15s;
}
.btn-primary { background: #fff; color: var(--brand-ink); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.18); text-decoration: none; }
.btn-ghost { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.26); text-decoration: none; }

/* ----------------------------------------------------------------
   Badges
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 600;
  padding: 3px 11px; border-radius: 999px; vertical-align: middle; line-height: 1.5;
}
.badge.route { background: var(--code-bg); color: var(--brand-ink); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-weight: 600; }
.badge.gated { background: #fbe9da; color: var(--accent); }
.badge.public { background: #e1f1e6; color: #2c7a3f; }
.badge.admin { background: #ebe6f7; color: #5a3da8; }
.routes { margin: 10px 0 6px; display: flex; flex-wrap: wrap; gap: 8px; }

/* ----------------------------------------------------------------
   Figures
   ---------------------------------------------------------------- */
figure { margin: 24px 0; }
figure img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); background: #fff;
}
figcaption { font-size: 12.5px; color: var(--faint); margin-top: 10px; text-align: center; }

/* ----------------------------------------------------------------
   Callouts
   ---------------------------------------------------------------- */
.callout {
  position: relative; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius);
  padding: 15px 18px 15px 46px; margin: 20px 0; box-shadow: var(--shadow-sm);
}
.callout::before {
  content: "💡"; position: absolute; left: 16px; top: 14px; font-size: 16px;
}
.callout.tip { background: #f1f9f3; border-color: #cfe9d6; }
.callout.tip::before { content: "✅"; }
.callout.warn { background: #fdf3ec; border-color: #f3d8c5; }
.callout.warn::before { content: "⚠️"; }
.callout p { margin: 6px 0; color: var(--ink-soft); }
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--ink); }

/* ----------------------------------------------------------------
   Card grid
   ---------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; margin: 24px 0; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.card .ico {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-size: 20px; background: var(--blue-tint); margin-bottom: 12px;
}
.card h3 { margin: 0 0 4px; font-size: 15.5px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--ink-soft); }
thead th { background: var(--surface-2); font-weight: 700; color: var(--ink); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 6px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88em; color: var(--brand-ink); }

/* Feature list */
.feat { list-style: none; padding: 0; margin: 16px 0; }
.feat li { position: relative; padding: 5px 0 5px 28px; margin: 0; color: var(--ink-soft); }
.feat li::before { content: "→"; position: absolute; left: 4px; top: 5px; color: var(--brand); font-weight: 700; }

/* ----------------------------------------------------------------
   Pager + footer
   ---------------------------------------------------------------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 44px; }
.pager a {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
  text-decoration: none; color: inherit; background: var(--surface); box-shadow: var(--shadow-sm);
  transition: border-color .14s, transform .12s;
}
.pager a:hover { border-color: var(--brand); transform: translateY(-1px); text-decoration: none; }
.pager .lbl { display: block; font-size: 12px; color: var(--faint); margin-bottom: 3px; }
.pager .ttl { font-weight: 700; color: var(--brand-ink); font-size: 15px; }
.pager .next { text-align: right; grid-column: 2; }
.pager a:only-child { grid-column: 2; }

.docfoot { margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12.5px; }

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 880px) {
  :root { --sidebar-w: 270px; }
  .layout { grid-template-columns: minmax(0,1fr); }
  .menu-btn { display: grid; place-items: center; }
  .sidebar {
    position: fixed; left: 0; top: var(--header-h); z-index: 90;
    width: var(--sidebar-w); transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 30px 22px 72px; }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 30px; }
  .scrim { display: none; position: fixed; inset: var(--header-h) 0 0; background: rgba(10,12,18,.4); z-index: 85; }
  .scrim.show { display: block; }
}
