/* ==========================================================================
   Oliyam — shared stylesheet for oliyam.com and docs.oliyam.com
   Dependency-free. No web fonts, no external requests.
   ========================================================================== */

:root {
  --teal-900: #0d3b40;
  --teal-700: #155e63;
  --teal-600: #1c757c;
  --teal-500: #246a73;
  --teal-100: #e4f1f1;
  --rust-700: #8f2f24;
  --rust-600: #b13b2e;
  --rust-100: #fdeceA;
  --amber-700: #8b6b2e;
  --amber-100: #fbf1dd;
  --green-700: #2f6b4f;
  --green-100: #e3f2e9;

  --bg: #fbfaf7;
  --bg-raised: #ffffff;
  --bg-sunken: #f2f0ea;
  --border: #e0ddd4;
  --border-strong: #c9c5b8;
  --text: #1f2426;
  --text-muted: #5f6870;
  --text-faint: #8a9199;
  --accent: var(--teal-700);
  --accent-hover: var(--teal-600);
  --link: var(--teal-700);

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 35, 0.06), 0 2px 8px rgba(20, 30, 35, 0.04);
  --shadow-md: 0 2px 6px rgba(20, 30, 35, 0.08), 0 12px 28px rgba(20, 30, 35, 0.07);

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

  --measure: 74ch;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --bg-raised: #1c2224;
    --bg-sunken: #101315;
    --border: #2c3438;
    --border-strong: #3d474c;
    --text: #e6e9ea;
    --text-muted: #9aa5ab;
    --text-faint: #6f7c83;
    --accent: #4fbdc4;
    --accent-hover: #6fd3d9;
    --link: #5cc8cf;
    --teal-100: #12312f;
    --rust-100: #331a16;
    --amber-100: #33280f;
    --green-100: #14301f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.45), 0 12px 28px rgba(0, 0, 0, 0.35);
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

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

a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

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

code, pre, kbd { font-family: var(--font-mono); }

code {
  font-size: 0.88em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.36em;
}

pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* ---------- Header ---------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand .mark { width: 26px; height: 26px; flex: none; }
.brand .sub {
  font-weight: 450;
  color: var(--text-muted);
  font-size: 13px;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--border-strong);
}

.site-nav { display: flex; gap: 20px; align-items: center; margin-left: auto; font-size: 14.5px; }
.site-nav a { color: var(--text-muted); text-decoration: none; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer;
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 860px; margin: 0 auto; padding: 0 24px; }

.docs-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 208px;
  gap: 40px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 28px 80px;
  align-items: start;
}

.sidebar, .toc {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  font-size: 14px;
}

.sidebar h3, .toc h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 18px 0 8px;
  font-weight: 650;
}
.sidebar ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.sidebar li, .toc li { margin: 1px 0; }
.sidebar a, .toc a {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
}
.sidebar a:hover, .toc a:hover { background: var(--bg-sunken); color: var(--text); }
.sidebar a[aria-current="page"] {
  background: var(--teal-100);
  color: var(--accent);
  font-weight: 600;
}
.toc a.lvl-3 { padding-left: 22px; font-size: 13px; }

.content { min-width: 0; max-width: var(--measure); }

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

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; font-weight: 660; }
h1 { font-size: 2.1rem; margin: 0 0 12px; }
h2 { font-size: 1.44rem; margin: 2.2em 0 0.6em; padding-top: 0.3em; }
h3 { font-size: 1.15rem; margin: 1.8em 0 0.5em; }
h4 { font-size: 1rem; margin: 1.5em 0 0.4em; }

h2 + h3 { margin-top: 1em; }

.anchor {
  margin-left: 8px;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
  transition: opacity 0.12s;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }

.lede { font-size: 1.12rem; color: var(--text-muted); line-height: 1.6; }

.page-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  color: var(--text-muted); font-size: 13.5px;
  margin: 14px 0 26px; padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

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

.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-sunken); font-weight: 620; white-space: nowrap; color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); }
td code { white-space: nowrap; }

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

.callout {
  margin: 18px 0;
  padding: 13px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--teal-100);
}
.callout p { margin: 0; }
.callout.critical { border-left-color: var(--rust-600); background: var(--rust-100); }
.callout.warn { border-left-color: var(--amber-700); background: var(--amber-100); }

blockquote {
  margin: 18px 0;
  padding: 2px 18px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }

/* ---------- Badges / pills -------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 620; letter-spacing: 0.01em;
  padding: 2.5px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ok    { background: var(--green-100); color: var(--green-700); border-color: color-mix(in srgb, var(--green-700) 25%, transparent); }
.badge.warn  { background: var(--amber-100); color: var(--amber-700); border-color: color-mix(in srgb, var(--amber-700) 25%, transparent); }
.badge.bad   { background: var(--rust-100);  color: var(--rust-700);  border-color: color-mix(in srgb, var(--rust-700) 25%, transparent); }
.badge.muted { background: var(--bg-sunken); color: var(--text-muted); border-color: var(--border); }
.badge.level { background: var(--teal-100); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

@media (prefers-color-scheme: dark) {
  .badge.ok { color: #7fd3a6; }
  .badge.warn { color: #e0b055; }
  .badge.bad { color: #ef9384; }
}

/* ---------- Cards / grids --------------------------------------------- */

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }

.card {
  display: flex; flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
a.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: inherit;
}
.card .card-code {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--accent); letter-spacing: 0.02em;
}
.card h3 { margin: 5px 0 7px; font-size: 1.02rem; line-height: 1.35; }
.card p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.card .card-foot {
  margin-top: auto; padding-top: 13px;
  display: flex; gap: 7px; flex-wrap: wrap; align-items: center;
}

/* ---------- Board renders --------------------------------------------- */

/* Card thumbnail. The renders have transparent backgrounds, so they sit on a
   neutral tint that works in both themes rather than a baked-in white box. */
.card-media {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  margin: -18px -20px 14px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(160deg,
      color-mix(in srgb, var(--teal-100) 60%, var(--bg-sunken)),
      var(--bg-sunken));
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
  transition: transform 0.22s ease;
}
a.card:hover .card-media img { transform: scale(1.035); }

.card-media.empty {
  font-size: 12.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

/* Home-page strip: one representative board per line. */
.hero-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 8px 0 12px;
}
.hero-shot {
  display: block;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg,
      color-mix(in srgb, var(--teal-100) 60%, var(--bg-sunken)),
      var(--bg-sunken));
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.hero-shot:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  box-shadow: var(--shadow-md);
}
.hero-shot img { display: block; width: 100%; height: auto; }
.hero-shot span {
  position: absolute; left: 12px; bottom: 10px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--bg-raised) 85%, transparent);
  padding: 2px 8px; border-radius: 999px;
  backdrop-filter: blur(4px);
}

/* Full-width shot at the top of a board page. */
.board-shot {
  margin: 8px 0 24px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg,
      color-mix(in srgb, var(--teal-100) 55%, var(--bg-sunken)),
      var(--bg-sunken));
}
.board-shot img { display: block; width: 100%; height: auto; }
.board-shot figcaption {
  margin-top: 6px;
  padding: 0 4px 2px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Hero ------------------------------------------------------ */

.hero { padding: 76px 0 56px; }
.hero h1 {
  font-size: clamp(2.2rem, 5.2vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  max-width: 18ch;
}
.hero .lede { font-size: clamp(1.05rem, 2.2vw, 1.25rem); max-width: 62ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 9px;
  font-weight: 580; font-size: 15px; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.14s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; transform: translateY(-1px); }
.btn.ghost { border-color: var(--border-strong); color: var(--text); background: var(--bg-raised); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

@media (prefers-color-scheme: dark) {
  .btn.primary { color: #06211f; }
  .btn.primary:hover { color: #06211f; }
}

/* ---------- Stats ----------------------------------------------------- */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; margin: 34px 0;
}
.stat { background: var(--bg-raised); padding: 20px 18px; }
.stat .num {
  font-size: 1.9rem; font-weight: 660; letter-spacing: -0.02em;
  line-height: 1.1; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat .label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Search / filter ------------------------------------------- */

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 20px; align-items: center; }

input[type="search"], input[type="text"] {
  flex: 1 1 240px; min-width: 0;
  padding: 9px 13px;
  font: inherit; font-size: 14.5px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
}
input[type="search"]:focus, input[type="text"]:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.chip {
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-raised); color: var(--text-muted);
  font-size: 13.5px; font-weight: 520; cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { color: #06211f; } }

.empty-state { padding: 40px 0; text-align: center; color: var(--text-muted); }

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

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 80px;
  padding: 40px 0 56px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg-sunken);
}
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 28px; }
.site-footer h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 5px 0; }
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.footer-note { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-faint); }

/* ---------- Prev/next ------------------------------------------------- */

.pager { display: flex; gap: 14px; margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--border); }
.pager a {
  flex: 1; padding: 13px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit; background: var(--bg-raised);
}
.pager a:hover { border-color: var(--accent); }
.pager .dir { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.pager .ttl { color: var(--accent); font-weight: 560; font-size: 14.5px; }
.pager .next { text-align: right; }

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

@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: 244px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); padding: 22px 20px 64px; gap: 0; }
  .sidebar {
    position: static; max-height: none; overflow: visible;
    margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
  }
  .sidebar[hidden] { display: none; }
  .nav-toggle { display: inline-block; }
  .site-nav { display: none; }
  .site-nav.open {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--bg-raised); border-bottom: 1px solid var(--border);
    padding: 14px 24px; box-shadow: var(--shadow-md);
  }
  .hero { padding: 48px 0 36px; }
  .brand .sub { display: none; }
}

/* ---------- Print (handbook edition) ---------------------------------- */

@media print {
  :root { --bg: #fff; --bg-raised: #fff; --bg-sunken: #f6f6f4; --text: #000; --border: #ccc; }
  .site-header, .site-footer, .sidebar, .toc, .pager, .filter-bar, .anchor, .nav-toggle { display: none !important; }
  .docs-layout { display: block; padding: 0; }
  .content { max-width: none; }
  body { font-size: 10.5pt; }
  h1, h2, h3 { break-after: avoid; }
  table, pre, figure, .callout { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8.5pt; color: #555; word-break: break-all; }
  .board-page { break-before: page; }
}
