/* SPDX-License-Identifier: Apache-2.0
 * Stag Programming Language Website — Minimalist Typographic Theme
 * Palette harmonized with logo/Stag.jpeg (#ffffff paper + #18181b obsidian charcoal + muted pine accent)
 */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-elevated: #ffffff;
  --bg-code: #f5f5f7;
  --bg-code-header: #ededf0;
  --ink: #18181b;
  --ink-secondary: #52525b;
  --ink-muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #2d5a4c;
  --accent-hover: #22463b;
  --accent-soft: #eef5f2;
  --btn-bg: #18181b;
  --btn-ink: #ffffff;
  --btn-hover: #2f2f35;
  --syn-kw: #1d4e42;
  --syn-ty: #3f4f73;
  --syn-str: #7c4d2b;
  --syn-num: #6b4682;
  --syn-cmt: #71717a;
  --syn-fn: #18181b;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-md: 0 4px 16px rgba(24, 24, 27, 0.06);
  --radius: 8px;
  --radius-sm: 5px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-scale: 1;
  --nav-h: 60px;
  --max-w: 1120px;
}

[data-theme="dark"] {
  --bg: #111114;
  --bg-subtle: #16161a;
  --bg-elevated: #19191e;
  --bg-code: #18181d;
  --bg-code-header: #202027;
  --ink: #f4f4f5;
  --ink-secondary: #a1a1aa;
  --ink-muted: #71717a;
  --border: #26262c;
  --border-strong: #34343c;
  --accent: #74b9a3;
  --accent-hover: #90ccb9;
  --accent-soft: rgba(116, 185, 163, 0.12);
  --btn-bg: #f4f4f5;
  --btn-ink: #111114;
  --btn-hover: #e4e4e7;
  --syn-kw: #74b9a3;
  --syn-ty: #93b4e0;
  --syn-str: #d6a97b;
  --syn-num: #c19ee0;
  --syn-cmt: #71717a;
  --syn-fn: #f4f4f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: calc(15.5px * var(--font-scale));
  line-height: 1.68;
}

/* Smooth theme transition applied briefly on user toggle */
html.theme-transitioning,
html.theme-transitioning body,
html.theme-transitioning .site-header,
html.theme-transitioning .install-card,
html.theme-transitioning .card,
html.theme-transitioning .code-block,
html.theme-transitioning .code-header,
html.theme-transitioning pre,
html.theme-transitioning code,
html.theme-transitioning .docs-sidebar,
html.theme-transitioning .site-footer,
html.theme-transitioning .diagram-box,
html.theme-transitioning .table-wrap,
html.theme-transitioning th,
html.theme-transitioning td,
html.theme-transitioning .callout,
html.theme-transitioning .btn,
html.theme-transitioning .icon-btn,
html.theme-transitioning .font-ctrl button,
html.theme-transitioning .cmd-box,
html.theme-transitioning .logo-mark {
  transition: background-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              color 0.24s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.26s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.26s ease,
              filter 0.28s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-transitioning,
  html.theme-transitioning * {
    transition: none !important;
  }
}

.controls-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.font-ctrl {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  overflow: hidden;
}

.font-ctrl button {
  appearance: none;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 550;
  height: 32px;
  padding: 0 8px;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.font-ctrl button:last-child { border-right: none; }
.font-ctrl button:hover {
  background: var(--bg-code);
  color: var(--ink);
}
.font-ctrl button.active-scale {
  color: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

img { max-width: 100%; display: block; }

.logo-mark {
  mix-blend-mode: multiply;
  transition: filter 0.15s ease;
}
[data-theme="dark"] .logo-mark {
  filter: invert(1) brightness(0.95);
  mix-blend-mode: lighten;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.version-pill {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}
.nav-links a {
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 500;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--ink);
  text-decoration: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

/* Container & Sections */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 64px 0;
  border-bottom: 1px solid var(--border);
}
.section:last-of-type { border-bottom: none; }

.section-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 8px;
}

h1, h2, h3, h4 {
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.25;
}
h1 { font-size: clamp(2rem, 3.6vw, 2.75rem); font-weight: 650; margin: 0 0 14px; }
h2 { font-size: 1.55rem; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 1.12rem; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 14px; color: var(--ink-secondary); }

/* Hero */
.hero {
  padding: 68px 0 56px;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 44px;
  align-items: center;
}

.hero-brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.hero-brand-row img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}
.hero-lead {
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-secondary);
  max-width: 58ch;
  margin-bottom: 24px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 550;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-ink);
}
.btn-primary:hover {
  background: var(--btn-hover);
  color: var(--btn-ink);
  text-decoration: none;
}
.btn-secondary {
  background: var(--bg-subtle);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-code);
  color: var(--ink);
  text-decoration: none;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

/* Install Card */
.install-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.install-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--ink);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.cmd-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-family: var(--font-mono);
  font-size: 12.8px;
  color: var(--ink);
  overflow-x: auto;
}
.cmd-box code {
  white-space: nowrap;
  background: none;
  padding: 0;
  border: none;
}

.copy-btn {
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--ink-secondary);
  border-radius: 4px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--ink); }

.install-note {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 12px 0 0;
}

.win-download-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.win-download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
}

/* Feature Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: calc(15.5px * var(--font-scale)); margin-bottom: 8px; }
.card p { font-size: calc(14px * var(--font-scale)); margin: 0; color: var(--ink-secondary); }

.ext-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
}
.ext-banner img {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
}
@media (max-width: 640px) {
  .ext-banner { grid-template-columns: 1fr; }
}

/* Code Showcase */
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 22px;
  margin-top: 20px;
}

/* Code blocks */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink);
}

pre {
  margin: 0 0 18px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  position: relative;
}
pre code {
  display: block;
  padding: 15px 18px;
  border: none;
  background: none;
  font-size: calc(13.2px * var(--font-scale));
  line-height: 1.58;
  white-space: pre;
}

.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--bg-code);
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--bg-code-header);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}
.code-block pre {
  margin: 0;
  border: none;
  border-radius: 0;
}

/* Syntax classes */
.tok-kw { color: var(--syn-kw); font-weight: 550; }
.tok-ty { color: var(--syn-ty); }
.tok-str { color: var(--syn-str); }
.tok-num { color: var(--syn-num); }
.tok-cmt { color: var(--syn-cmt); font-style: italic; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(14px * var(--font-scale));
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
}
td { color: var(--ink-secondary); }

/* Pipeline SVG container */
.diagram-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin-top: 20px;
}

/* Docs Layout */
.docs-shell {
  max-width: 1340px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: calc(100vh - var(--nav-h));
}

.docs-sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 20px 16px 40px;
  background: var(--bg-subtle);
}

.sidebar-search {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  margin-bottom: 14px;
}
.sidebar-search:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-color: var(--accent);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-list li { margin: 2px 0; }
.toc-list a {
  display: block;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 13.3px;
  color: var(--ink-secondary);
  line-height: 1.38;
}
.toc-list a:hover {
  background: var(--bg-code);
  color: var(--ink);
  text-decoration: none;
}
.toc-list a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}
.toc-h2 > a { font-weight: 550; color: var(--ink); margin-top: 6px; }
.toc-h3 > a { padding-left: 18px; font-size: 12.7px; }

.docs-main {
  padding: 36px 48px 80px;
  max-width: 920px;
  min-width: 0;
}

.docs-main h1 { font-size: 2rem; margin-bottom: 10px; }
.docs-main h2 {
  font-size: 1.42rem;
  margin: 44px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.docs-main h3 { font-size: 1.12rem; margin: 28px 0 10px; }
.docs-main h4 { font-size: 1rem; margin: 20px 0 8px; }
.docs-main ul, .docs-main ol {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--ink-secondary);
}
.docs-main li { margin: 5px 0; }
.docs-main blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.docs-main blockquote p:last-child { margin-bottom: 0; }
.docs-main hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 18px 0;
  font-size: 14px;
}
.callout strong { color: var(--ink); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  background: var(--bg-subtle);
  font-size: 13.5px;
  color: var(--ink-muted);
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: var(--ink-secondary); }

/* Mobile */
.mobile-toc-btn {
  display: none;
  margin-bottom: 16px;
}

@media (max-width: 960px) {
  .hero-grid, .split-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docs-shell { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: fixed;
    left: 0;
    top: var(--nav-h);
    width: 290px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow-md);
  }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-main { padding: 26px 20px 64px; }
  .mobile-toc-btn { display: inline-flex; }
}

@media (max-width: 640px) {
  .cards-grid { grid-template-columns: 1fr; }
  .nav-links { gap: 12px; }
  .nav-links .hide-sm { display: none; }
}
