/* WFB site palette — extracted from garmin.watchfacebuilder.com (CoreUI theme):
   body bg #181924, body text rgba(255,255,255,.87), brand orange #fb8c00,
   header bar #2a2b36, secondary text #a7a7a7. System font stack matches CoreUI. */

:root {
  --bg: #181924;
  --bg-elevated: #2a2b36;
  --bg-card: #20212d;
  --bg-code: rgba(255, 255, 255, 0.07);
  --text: rgba(255, 255, 255, 0.87);
  --text-strong: #ffffff;
  --text-muted: #a7a7a7;
  --accent: #fb8c00;
  --accent-hover: #c97000;
  --accent-soft: rgba(251, 140, 0, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-mono: SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 60px;
  --toc-w: 260px;
  --content-max: 880px;
  --shell-max: 1300px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover,
a:focus { color: var(--accent-hover); text-decoration: underline; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(6px);
  min-height: var(--header-h);
}

.site-header__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-strong);
  font-weight: 600;
  text-decoration: none;
}
.site-header__brand:hover { color: var(--text-strong); text-decoration: none; }

.site-header__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #1a1206;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.site-header__brand-text {
  font-size: 16px;
  letter-spacing: 0.2px;
}

.site-header__nav {
  display: flex;
  gap: 22px;
  margin-left: auto;
  flex-wrap: wrap;
}
.site-header__nav a {
  color: var(--text-muted);
  font-size: 14px;
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.site-header__nav a:hover,
.site-header__nav a:focus {
  color: var(--text-strong);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.site-header__menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
}
.site-header__menu-icon,
.site-header__menu-icon::before,
.site-header__menu-icon::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  margin: 4px auto;
  transition: transform 0.2s, opacity 0.2s;
}
.site-header__menu-icon { position: relative; }
[aria-expanded="true"] .site-header__menu-icon { background: transparent; }
[aria-expanded="true"] .site-header__menu-icon::before { transform: translateY(6px) rotate(45deg); }
[aria-expanded="true"] .site-header__menu-icon::after  { transform: translateY(-6px) rotate(-45deg); }

/* ── Two-column shell ─────────────────────────────────────────────────── */

.site-shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: var(--toc-w) 1fr;
  gap: 36px;
}

/* ── Sidebar Table of Contents ────────────────────────────────────────── */

.toc {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  padding: 28px 0;
  overflow: hidden;
}
.toc__inner {
  height: 100%;
  overflow-y: auto;
  padding-right: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.toc__inner::-webkit-scrollbar { width: 6px; }
.toc__inner::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
.toc__heading {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding-left: 12px;
}
.toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border);
}
.toc__list li { margin: 0; }
.toc__link {
  display: block;
  padding: 6px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.4;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc__link:hover {
  color: var(--text-strong);
  text-decoration: none;
  border-left-color: var(--border-strong);
}
.toc__link--active {
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.toc__link--h3 {
  padding-left: 28px;
  font-size: 12.5px;
  opacity: 0.85;
}

/* When JS has populated the sidebar, hide the in-page ToC duplicate */
.toc--ready ~ .site-main .page__inline-toc { display: none; }

/* ── Main + article ────────────────────────────────────────────────────── */

.site-main {
  max-width: var(--content-max);
  padding: 40px 0 72px;
  min-width: 0; /* allow grid item to shrink */
}

.page__title {
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 24px;
  color: var(--text-strong);
  font-weight: 700;
  letter-spacing: -0.2px;
}

article.page h2 {
  font-size: 24px;
  line-height: 1.3;
  margin: 48px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-strong);
  font-weight: 600;
  scroll-margin-top: 80px;
}

article.page h3 {
  font-size: 18px;
  line-height: 1.35;
  margin: 28px 0 10px;
  color: var(--text-strong);
  font-weight: 600;
  scroll-margin-top: 80px;
}

article.page h4 {
  font-size: 16px;
  margin: 22px 0 8px;
  color: var(--text-strong);
  font-weight: 600;
}

article.page p,
article.page ul,
article.page ol {
  margin: 0 0 16px;
}
article.page ul,
article.page ol { padding-left: 28px; }
article.page li { margin-bottom: 4px; }
article.page li > p { margin-bottom: 8px; }

article.page strong { color: var(--text-strong); font-weight: 600; }
article.page em { color: var(--text); }

article.page blockquote {
  margin: 0 0 20px;
  padding: 14px 18px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  color: var(--text);
}
article.page blockquote p:last-child { margin-bottom: 0; }
article.page blockquote a { color: var(--accent); }

article.page code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: #ffd9a3;
  word-break: break-word;
}
article.page pre {
  background: var(--bg-card);
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow-x: auto;
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.55;
}
article.page pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

article.page table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 15px;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
article.page thead th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-strong);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
}
article.page th,
article.page td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
article.page tbody tr:last-child td { border-bottom: none; }
article.page tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

article.page hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

article.page img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-top: 72px;
}
.site-footer__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 22px 28px;
  color: var(--text-muted);
  font-size: 14px;
}
.site-footer__inner a { color: var(--accent); }

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  :root { --toc-w: 220px; }
  .site-shell { gap: 28px; }
}

@media (max-width: 860px) {
  /* Stack: collapse TOC to a top drawer triggered by the header button */
  .site-shell {
    grid-template-columns: 1fr;
    padding: 0 18px;
  }
  .site-header__nav { display: none; }
  .site-header__menu-toggle { display: inline-block; margin-left: auto; }

  .toc {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    height: auto;
    max-height: calc(100vh - var(--header-h));
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 16px 18px;
    z-index: 20;
    transform: translateY(-110%);
    transition: transform 0.25s ease;
  }
  .toc[data-open="true"] { transform: translateY(0); }
  .toc__inner { padding-right: 0; }

  .site-main { padding: 24px 0 48px; }
  .page__title { font-size: 28px; }
  article.page h2 { font-size: 21px; margin-top: 40px; }
  article.page h3 { font-size: 17px; }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  .page__title { font-size: 24px; }
  article.page h2 { font-size: 19px; }
}

/* When the ToC has been populated by JS, hide the duplicate in-page ToC.
   The in-page ToC is wrapped in <nav class="page__inline-toc"> by toc.js. */
.page__inline-toc[hidden] { display: none !important; }
