/* Copyright (c) 2025 Jurjen Stellingwerff                        */
/* SPDX-License-Identifier: LGPL-3.0-or-later                     */
/* Shared stylesheet for all Loft documentation pages.             */
/* Hand-edited; copied into out_dir by documentation.rs.            */

:root {
  --bg: #fff;
  --text: #1a1a2e;
  --code-bg: #f8f9fa;
  --border: #e5e7eb;
  --accent: #2563eb;
  --nav-bg: #f3f4f6;
  --kw: #d1242f;
  --ty: #8250df;
  --st: #0a3069;
  --cm: #6a737d;
  --nm: #0550ae;
  --bi: #953800;
  --en: #1a7f37;
  --dim: #6b7280;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 32px;
}

nav {
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 32px;
  font-size: 0.9em;
}
.nav-links { line-height: 2.2; }
nav a { color: var(--accent); text-decoration: none; margin: 0 3px; }
nav a:hover { text-decoration: underline; }
.cur { font-weight: 700; color: var(--text); margin: 0 3px; }
.nav-sep { color: var(--dim); font-weight: 600; font-size: 0.85em; margin: 0 4px; }

/* ── Search ─────────────────────────────────────────────────────────────── */

.search-wrap { position: relative; display: inline-block; margin-top: 6px; }
#search {
  width: 220px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.88em;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
#search:focus { outline: 2px solid var(--accent); border-color: transparent; }
.search-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 260px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 100;
  overflow: hidden;
}
.search-results a {
  display: flex;
  justify-content: space-between;
  padding: 7px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9em;
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--nav-bg); }
.search-kind {
  font-size: 0.78em;
  color: var(--dim);
  align-self: center;
}

h1 {
  font-size: 1.75em;
  margin: 0 0 24px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
h2 { font-size: 1.1em; font-weight: 700; margin: 2em 0 0.4em; }

p { margin: 0.4em 0 1em; color: #374151; }

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 18px;
  font-size: 0.875em;
  line-height: 1.55;
}

code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Syntax highlight classes */
.cm { color: var(--cm); font-style: italic; }
.kw { color: var(--kw); font-weight: 600; }
.ty { color: var(--ty); }
.st, .ch { color: var(--st); }
.nm { color: var(--nm); }
.bi { color: var(--bi); }
.en { color: var(--en); }
.fn-call { color: #005cc5; }

/* stdlib links inside code blocks: inherit span colour, subtle underline */
pre a { color: inherit; text-decoration: underline dotted; }
pre a:hover { text-decoration: underline; }

/* ── Index page ─────────────────────────────────────────────────────────── */

header {
  text-align: center;
  padding: 48px 0 32px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 32px;
}
header h1 { font-size: 3em; margin: 0 0 8px; letter-spacing: -1px; }
.tagline { font-size: 1.4em; color: var(--text); margin: 0; font-weight: 500; }
.subtagline { font-size: 1em; color: var(--dim); margin: 6px 0 0; }
.version { font-size: 0.85em; color: var(--dim); margin: 4px 0 0; opacity: 0.7; }

.index-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.index-hero { text-align: center; max-width: 720px; }
.index-search { width: 100%; max-width: 400px; }
.index-search #search { width: 100%; font-size: 1em; padding: 8px 14px; }

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.hero-btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95em;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.hero-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 3px 10px rgba(37, 99, 235, .12);
}
.hero-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.hero-btn-primary:hover { box-shadow: 0 3px 14px rgba(37, 99, 235, .35); }

/* ── Showcase: visual "what can you build" tiles on the landing page ─── */

.showcase {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin: 0 0 40px;
}
.showcase-side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
}
.showcase-tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  text-decoration: none;
  color: inherit;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.showcase-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(37, 99, 235, .16);
}
.showcase-tile img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center top;
  background: #0b0b1e;
}
.showcase-caption {
  padding: 18px 20px;
}
.showcase-caption h2 {
  margin: 6px 0 6px;
  font-size: 1.4em;
  color: var(--text);
}
.showcase-caption h3 {
  margin: 6px 0 6px;
  font-size: 1.1em;
  color: var(--text);
}
.showcase-caption p {
  margin: 0;
  color: #4b5563;
  font-size: 0.95em;
  line-height: 1.55;
}
.showcase-tag {
  display: inline-block;
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  padding: 3px 10px;
  border-radius: 999px;
}
.showcase-sub {
  display: flex;
  align-items: center;
}
.showcase-sub .showcase-caption { padding: 18px 20px; }
@media (max-width: 760px) {
  .showcase { grid-template-columns: 1fr; }
  .showcase-side { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
}
@media (max-width: 520px) {
  .showcase-side { grid-template-columns: 1fr; grid-template-rows: auto auto; }
}

.intro { margin-bottom: 40px; }
.intro ul { padding-left: 1.4em; }
.intro li { margin: 6px 0; color: #374151; }

.topics-heading {
  font-size: 1.3em;
  margin: 0 0 16px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.card {
  display: block;
  padding: 16px 18px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.card h2 { font-size: 1em; margin: 0 0 6px; color: var(--accent); }
.card p { font-size: .85em; margin: 0; color: #4b5563; line-height: 1.5; }

/* ── vs-Rust comparison page ────────────────────────────────────────────── */

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0.6em 0 0.8em;
}

pre.rust-pre   { background: #fff8f0; border-color: #fcd9ad; }
pre.python-pre { background: #f0f7ff; border-color: #b6d0f5; }

.lang-label {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.loft-label   { color: #2563eb; }
.rust-label   { color: #b45309; }
.python-label { color: #1a5fa8; }

.verdict {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0.4em 0 1em;
}

.up, .down {
  margin: 0;
  padding: 0.5em 0.75em;
  border-radius: 5px;
  font-size: 0.92em;
  line-height: 1.5;
}
.up   { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.down { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }
.up   strong, .down strong {
  display: block;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2em;
}

/* vs-rust section headers */
section-header, h2.diff {
  padding: 0.3em 0.7em;
  background: var(--nav-bg);
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
}

/* ── Article section headings (topic pages) ─────────────────────────────── */

article h2 {
  font-size: 1.25em;
  margin-top: 2.8em;
  margin-bottom: 0.4em;
  padding: 0.3em 0.7em;
  border-left: 4px solid var(--accent);
  background: var(--code-bg);
  border-radius: 0 4px 4px 0;
}

article h3 {
  font-size: 1.05em;
  margin-top: 2em;
  margin-bottom: 0.3em;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25em;
}

/* ── Featured card (vs Rust on index) ───────────────────────────────────── */

.card-featured {
  border-color: var(--accent);
  background: linear-gradient(135deg, #eff6ff 0%, var(--code-bg) 100%);
}
.card-featured:hover { box-shadow: 0 4px 12px rgba(37,99,235,.2); }
.card-featured h2 { color: var(--accent); }

/* ── Roadmap badges ─────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: .72em;
  font-weight: 600;
  vertical-align: middle;
  letter-spacing: .02em;
}
.badge.planned {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ── Print / single-page reference ─────────────────────────────────────── */

.print-page { max-width: 1100px; }

.print-header {
  text-align: center;
  padding: 3em 0 2em;
  border-bottom: 3px solid var(--accent);
  margin-bottom: 3em;
}
.print-header h1 { font-size: 2.5em; margin: 0 0 0.3em; }

.print-toc {
  column-count: 2;
  column-gap: 2.5em;
  margin: 2em 0 3em;
  padding: 1.5em 2em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  break-inside: avoid;
}
.print-toc h2 { column-span: all; margin: 0 0 1em; font-size: 1.1em; }
.print-toc ul { margin: 0; padding-left: 1.2em; list-style: none; }
.print-toc li { margin: 0.3em 0; font-size: 0.9em; }
.print-toc a { color: var(--accent); text-decoration: none; }
.print-toc a:hover { text-decoration: underline; }
.toc-indent { padding-left: 1.5em; }
.toc-section { font-weight: 700; margin-top: 0.8em; }
.toc-desc { color: var(--dim); font-size: 0.85em; }
.toc-note { color: var(--dim); font-size: 0.8em; font-style: italic; }

.print-section {
  margin-top: 4em;
  padding-top: 2em;
  border-top: 3px solid var(--border);
}
.print-section > h1 {
  font-size: 2em;
  margin: 0 0 1em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}
.print-section article h2 { margin-top: 2em; }

/* ── Performance / benchmark page ───────────────────────────────────────── */

.bench-table { width: 100%; border-collapse: collapse; font-size: 0.88em; margin: 1em 0 1.5em; }
.bench-table th { background: var(--nav-bg); border: 1px solid var(--border); padding: 6px 10px; text-align: left; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; }
.bench-table td { border: 1px solid var(--border); padding: 5px 10px; vertical-align: middle; }
.bench-table tr:nth-child(even) td { background: var(--code-bg); }
.bench-table td.bench-name { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.85em; color: var(--dim); }
.bench-table td.ms { text-align: right; white-space: nowrap; }
.bench-bar-wrap { display: flex; align-items: center; gap: 6px; min-width: 120px; }
.bench-bar { height: 12px; border-radius: 3px; min-width: 2px; }
.bench-bar.python  { background: #3b82f6; }
.bench-bar.interp  { background: #8b5cf6; }
.bench-bar.native  { background: #10b981; }
.bench-bar.wasm    { background: #f59e0b; }
.bench-bar.rust    { background: #ef4444; }
.bench-ms   { font-size: 0.82em; color: var(--dim); white-space: nowrap; }
.bench-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0.5em 0 1.5em; font-size: 0.85em; }
.bench-legend-item { display: flex; align-items: center; gap: 5px; }
.bench-legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.bench-note { font-size: 0.85em; color: var(--dim); font-style: italic; margin: -0.5em 0 1em; }
.bottleneck { background: var(--code-bg); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 0 6px 6px 0; padding: 0.7em 1em; margin: 0.5em 0 1.2em; font-size: 0.92em; }
.bottleneck strong { display: block; font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.3em; }

/* ── Print media ─────────────────────────────────────────────────────────── */

@media print {
  nav, .search-wrap { display: none !important; }

  body {
    max-width: 100%;
    padding: 0.5cm 1cm;
    font-size: 10pt;
    line-height: 1.5;
  }

  pre {
    page-break-inside: avoid;
    break-inside: avoid;
    font-size: 0.82em;
  }

  h1, h2, h3 {
    page-break-after: avoid;
    break-after: avoid;
  }

  .print-page { max-width: 100%; }
  .print-toc { page-break-after: always; break-after: page; column-count: 2; }
  .print-section { page-break-before: always; break-before: page; }

  /* Show URLs for external links only */
  a[href^="http"]:after {
    content: " <" attr(href) ">";
    font-size: 0.7em;
    color: #666;
  }
  /* Don't show URLs for internal anchors or nav links */
  a[href^="#"]:after, a[href$=".html"]:after { content: ""; }
}
