/* Gruvbox-inspired theme matching vrognas.com */

:root {
  color-scheme: light;
  /* Light theme (default) */
  --bg: #ffffff;
  --bg-alt: #f1f1ec;
  --bg-card: #f2f2f2;
  --bg-hover: #e8e8e8;
  --fg: #242424;
  --fg-nav: #464646;
  --fg-nav-hover: #6e6353;
  --fg-dim: #555555;
  --fg-muted: #70675c;
  --accent: #427b58;
  --accent-hover: #79740e;
  --link: #427b58;
  --link-hover: #79740e;
  --border: #dddddd;
  --badge-technical: #3e6d71;
  --badge-job: #84671b;
  --badge-event: #84546d;
  --badge-news: #8d5934;
  --badge-technical-fg: #fff;
  --badge-job-fg: #fff;
  --badge-event-fg: #fff;
  --badge-news-fg: #fff;
  --badge-admin-fg: #fff;
  --fg-on-accent: #fff;
  --code-bg: #f7f7f7;
  --shadow: rgba(0, 0, 0, 0.08);
  --overlay: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #282828;
  --bg-alt: #1d2021;
  --bg-card: #3c3836;
  --bg-hover: #504945;
  --fg: #ebdbb2;
  --fg-nav: #ebdbb2;
  --fg-nav-hover: #bdae93;
  --fg-dim: #bdae93;
  --fg-muted: #b3a48d;
  --accent: #8cbd7a;
  --accent-hover: #b8bb26;
  --link: #8cbd7a;
  --link-hover: #b8bb26;
  --border: #504945;
  --badge-technical: #6e9a9d;
  --badge-job: #b89d57;
  --badge-event: #b88ca3;
  --badge-news: #c49472;
  --badge-technical-fg: #1d2021;
  --badge-job-fg: #1d2021;
  --badge-event-fg: #1d2021;
  --badge-news-fg: #1d2021;
  --badge-admin-fg: #1d2021;
  --fg-on-accent: #1d2021;
  --code-bg: #1d2021;
  --shadow: rgba(0, 0, 0, 0.3);
  --overlay: rgba(0, 0, 0, 0.5);
}

/* Visually hidden (screen reader only) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--fg-on-accent);
  border-radius: 0 0 4px 4px;
  font-weight: 600;
  z-index: 200;
}
.skip-link:focus {
  top: 0;
  color: var(--fg-on-accent);
  text-decoration: none;
}

/* Focus indicators */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: -1px;
  border-color: var(--accent);
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
}
h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.3rem; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--link-hover); text-decoration: underline; }

/* Layout */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

main {
  flex: 1;
  padding: 2rem 0;
}

/* Navigation */
.navbar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg-nav);
  white-space: nowrap;
}
.navbar-brand:hover { color: var(--fg-nav-hover); text-decoration: none; }

.navbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-links a {
  color: var(--fg-nav);
  font-size: 0.9rem;
  padding: 0.5rem 0.25rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}
.navbar-links a:hover { color: var(--fg-nav-hover); text-decoration: none; }

#theme-toggle,
#soft-wrap-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  min-height: 2.75rem;
  min-width: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#soft-wrap-toggle {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  min-width: 5.75rem;
}
#theme-toggle:hover,
#soft-wrap-toggle:hover { border-color: var(--accent); color: var(--accent); }
#soft-wrap-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--fg-on-accent);
}

/* Show sun in dark mode, moon in light mode */
#theme-toggle .icon-moon { display: none; }
[data-theme="light"] #theme-toggle .icon-sun { display: none; }
[data-theme="light"] #theme-toggle .icon-moon { display: inline; }

/* Footer */
.footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--fg-muted);
}
.footer a { color: var(--fg-dim); }

/* Cards & tables */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.stats-bar-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.stats-bar-item dd {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  order: -1;
}
.stats-bar-item dt {
  font-size: 0.85rem;
  color: var(--fg-dim);
}

/* Message table */
.msg-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  contain: layout style;
}
.msg-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--fg-dim);
  font-size: 0.85rem;
  font-weight: 600;
}
.msg-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: top;
}
.msg-table tr:hover { background: var(--bg-hover); }
.msg-table .row-active { background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--accent); }
.msg-table .date-col { white-space: nowrap; width: 120px; color: var(--fg-dim); }
.msg-table .author-col { width: 160px; }
.msg-table .cat-col { white-space: nowrap; width: 100px; text-align: center; }

/* Category badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-technical { background: var(--badge-technical); color: var(--badge-technical-fg); }
.badge-job { background: var(--badge-job); color: var(--badge-job-fg); }
.badge-event { background: var(--badge-event); color: var(--badge-event-fg); }
.badge-news { background: var(--badge-news); color: var(--badge-news-fg); }
.badge-admin { background: var(--fg-muted); color: var(--badge-admin-fg); }

/* Message page */
.msg-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.msg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--fg-dim);
  margin-top: 0.5rem;
}
.msg-meta a { color: var(--fg-dim); }

.msg-body {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}
[data-soft-wrap="on"] .msg-body {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.quoted-history {
  margin-top: 0.75rem;
}
.quoted-history summary {
  cursor: pointer;
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.quoted-history .msg-body {
  margin-top: 0.75rem;
}

.msg-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* Thread list on message page */
.thread-list {
  margin-top: 1.5rem;
}
.thread-list-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.thread-list h3 { margin-bottom: 0; }

.thread-message {
  margin-top: 1rem;
}
.thread-message h2 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}
.thread-message-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
}

/* Thread view */
.thread-reply .subject-col { padding-left: 2rem; }

/* Month grid */
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.month-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  min-height: 2.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.month-card:hover { background: var(--bg-hover); text-decoration: none; }
.month-card .count {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* Messages layout with filter sidebar */
.messages-layout {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1.5rem;
  align-items: start;
}
.filter-sidebar {
  position: sticky;
  top: 4rem;
}
.filter-group {
  margin-bottom: 1.25rem;
}
.filter-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}
.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.filter-options .sort-btn,
.filter-options .cat-toggle {
  justify-content: flex-start;
  min-height: 2.75rem;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  width: 100%;
}
.filter-options--year {
  max-height: 16rem;
  overflow-y: auto;
}
.messages-main {
  min-width: 0;
}

/* Sort controls (used outside sidebar) */
.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.sort-label {
  font-size: 0.85rem;
  color: var(--fg-muted);
}
.sort-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}
.sort-btn:hover { border-color: var(--accent); color: var(--accent); }
.sort-btn.active { background: var(--accent); color: var(--fg-on-accent); border-color: var(--accent); }

.cat-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  opacity: 0.4;
}
.cat-toggle.active { opacity: 1; color: var(--fg-on-accent); }
.cat-toggle[data-cat="technical"].active { background: var(--badge-technical); border-color: var(--badge-technical); color: var(--badge-technical-fg); }
.cat-toggle[data-cat="job"].active { background: var(--badge-job); border-color: var(--badge-job); color: var(--badge-job-fg); }
.cat-toggle[data-cat="event"].active { background: var(--badge-event); border-color: var(--badge-event); color: var(--badge-event-fg); }
.cat-toggle[data-cat="news"].active { background: var(--badge-news); border-color: var(--badge-news); color: var(--badge-news-fg); }
.cat-toggle[data-cat="admin"].active { background: var(--fg-muted); border-color: var(--fg-muted); color: var(--badge-admin-fg); }
.cat-toggle:hover { opacity: 0.8; }

/* Author search */
.author-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9rem;
}
.author-search::placeholder { color: var(--fg-muted); }

.author-count-display {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}

/* Author index */
.author-list {
  list-style: none;
}
.author-list li {
  padding: 0.4rem 0;
}
.author-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.author-info {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  flex-shrink: 1;
}
.author-info a {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.author-period {
  font-size: 0.75rem;
  color: var(--fg-muted);
  white-space: nowrap;
}
.author-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  width: 180px;
  position: relative;
}
.author-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
}
.author-bar {
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
}
.author-count {
  color: var(--fg-muted);
  font-size: 0.8rem;
  min-width: 2rem;
  text-align: right;
}

/* Home search */
.home-search {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  position: sticky;
  top: 3.75rem;
  z-index: 99;
  background: var(--bg);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.home-search-input {
  flex: 1;
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.95rem;
}
.home-search-input::placeholder { color: var(--fg-muted); }
.filter-select {
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
}
.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.msg-hidden { display: none; }

/* Category filter classes (toggled on .msg-table) */
.msg-table.filtering tr.msg-hidden { display: revert; }
.msg-table.hide-technical tr[data-cat="technical"] { display: none; }
.msg-table.hide-event tr[data-cat="event"] { display: none; }
.msg-table.hide-job tr[data-cat="job"] { display: none; }
.msg-table.hide-news tr[data-cat="news"] { display: none; }
.msg-table.hide-admin tr[data-cat="admin"] { display: none; }

/* Breadcrumbs */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.breadcrumb li { display: inline; }
.breadcrumb a { color: var(--fg-dim); }
.breadcrumb .sep { margin: 0 0.4rem; }

/* Page description (subtitle below h1) */
.page-desc {
  color: var(--fg-dim);
  margin-bottom: 1rem;
}

/* Search result cards (JS-generated) */
.search-result {
  padding: 0.75rem 1rem;
}
.search-result-title {
  margin-bottom: 0.25rem;
}
.search-result-title a {
  font-weight: 600;
}
.search-result-title .badge {
  margin-left: 0.5rem;
}
.search-result-meta {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-bottom: 0.3rem;
}
.search-result-snippet {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* Search status */
.search-status {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* Load more */
.load-more-wrap {
  text-align: center;
  margin-top: 1rem;
}
.load-more-btn { padding: 0.5rem 2rem; }
.browse-hint { display: none; margin-top: 0.75rem; }

/* Content list (about page etc.) */
.content-list {
  margin: 0.5rem 0 0 1.5rem;
}

/* Card utilities */
.card-note { margin-top: 0.5rem; }
.card-footnote { margin-top: 0.5rem; font-size: 0.85rem; color: var(--fg-muted); }
.card-chart { padding: 1rem; --chart-height: 180; overflow: hidden; }
.card-chart svg { display: block; }

/* Thread page */
.thread-participants { color: var(--fg-muted); font-size: 0.8rem; }
.count-col { text-align: right; }
.thread-current { background: var(--bg-hover); }

/* Home search results */
.search-results-wrap { display: none; margin-top: 0.5rem; margin-bottom: 0.75rem; }
.search-results-wrap.active { display: block; }

/* Keyboard shortcut help overlay */
.kbd-help {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
}
.kbd-help.visible { display: flex; }
.kbd-help-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  max-width: 360px;
  width: 90%;
}
.kbd-help-inner h3 { margin-bottom: 1rem; }
.kbd-help-inner table { width: 100%; }
.kbd-help-inner td {
  padding: 0.3rem 0;
  font-size: 0.9rem;
  color: var(--fg-dim);
}
.kbd-help-inner td:first-child {
  width: 100px;
  white-space: nowrap;
}
kbd {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
}

/* Toast notification */
.kbd-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--fg-dim);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  pointer-events: none;
}
.kbd-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
  .messages-layout {
    grid-template-columns: 1fr;
  }
  .filter-sidebar {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
  }
  .filter-group { margin-bottom: 0; }
  .filter-options {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .filter-options .sort-btn,
  .filter-options .cat-toggle {
    width: auto;
  }
  .filter-options--year { max-height: none; overflow: visible; }
  .msg-table .author-col { width: 120px; }
  .author-bar-wrap { width: 120px; }
  .stats-bar { gap: 0.25rem 1.25rem; }
}

@media (max-width: 640px) {
  .navbar .container { flex-wrap: wrap; }
  .navbar-left { gap: 0.75rem; }
  .navbar-links { gap: 0.5rem; }
  .msg-table .author-col { display: none; }
  .msg-table .cat-col { width: auto; }
  .author-bar-wrap { width: 100px; }
  .author-list { columns: 1; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .stats-bar { flex-direction: column; gap: 0.25rem; }
  .card-chart { --chart-height: 120; }
  .author-bar-wrap { width: 80px; }

  /* Card layout for message tables */
  .msg-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .msg-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
  }
  .msg-table td {
    border: none;
    padding: 0;
  }
  .msg-table .subject-col {
    flex-basis: 100%;
    order: -1;
    margin-bottom: 0.25rem;
  }
  .msg-table .date-col {
    width: auto;
    font-size: 0.8rem;
  }
  .msg-table .author-col {
    display: block;
    width: auto;
    font-size: 0.8rem;
    color: var(--fg-dim);
  }
  .msg-table .cat-col {
    display: block;
    width: auto;
    text-align: left;
  }
  .thread-reply .subject-col { padding-left: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
