/* Mostly Losses - single-page topic blog for RH-AI project notes.
   Consumed by index.html; left sidebar nav + center content pane, no build step. */

:root {
  color-scheme: light dark;
  --bg: #f8f6f2;
  --surface: #fffef9;
  --text: #1a1814;
  --muted: #5c574f;
  --border: #ddd8ce;
  --accent: #8b3a3a;
  --accent-soft: #f3e8e8;
  --code-bg: #f0ece4;
  --link: #6b2f2f;
  --max-width: 42rem;
  --sidebar-width: 15rem;
  --layout-max: 68rem;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", Georgia, serif;
  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1a1917;
    --text: #ece8e0;
    --muted: #a39e94;
    --border: #2e2b27;
    --accent: #d48484;
    --accent-soft: #2a1f1f;
    --code-bg: #242220;
    --link: #e8a0a0;
  }
}

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  overflow: visible;
}

.noscript-fallback {
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.noscript-fallback h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.noscript-fallback ul {
  margin: 0.5rem 0 1rem;
  padding-left: 1.25rem;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header-inner,
.page-main,
.site-footer-inner {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.site-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-tagline {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
}

.page-main {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 1.25rem;
}

.topic-nav {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.topic-nav-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.topic-nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.topic-nav-list a {
  display: block;
  padding: 0.45rem 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.35;
  text-decoration: none;
  color: var(--text);
  border-radius: 5px;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.topic-nav-list a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.topic-nav-list a.is-active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.content-area {
  min-width: 0;
}

.topic-article {
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topic-title {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.25;
}

.topic-deck {
  margin: 0.75rem 0 0;
  font-size: 1.05rem;
  color: var(--muted);
  font-style: italic;
}

.topic-published {
  display: block;
  margin-top: 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-card {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.post-card:first-child {
  padding-top: 0;
}

.post-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.25;
}

.post-card h2 a {
  color: inherit;
  text-decoration: none;
}

.post-card h2 a:hover {
  color: var(--accent);
}

.post-meta {
  margin: 0 0 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.post-summary {
  margin: 0;
  color: var(--muted);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.post-tags li {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.article-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.2;
  font-weight: 600;
}

.article-deck {
  margin: 0.75rem 0 0;
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.prose {
  max-width: var(--max-width);
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-sans);
  line-height: 1.3;
  margin: 2rem 0 0.75rem;
}

.prose h2 {
  font-size: 1.35rem;
}

.prose h3 {
  font-size: 1.15rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre {
  margin: 0 0 1.1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.35rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose blockquote {
  margin-left: 0;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.prose img,
.prose figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.prose figure {
  margin: 1.5rem 0;
}

.prose figcaption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose .mermaid {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  text-align: center;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose table {
  width: 100%;
  margin: 1.25rem 0 1.5rem;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.45;
}

.prose th,
.prose td {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--code-bg);
  font-weight: 600;
}

.prose td code {
  font-size: 0.82em;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.site-footer-inner {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--muted);
}

.status-message {
  font-family: var(--font-sans);
  color: var(--muted);
  font-style: italic;
}

.status-message.error {
  color: var(--accent);
  font-style: normal;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .sidebar {
    position: static;
  }

  .topic-nav-list {
    gap: 0;
  }

  .topic-article {
    padding: 1.25rem;
  }
}
