/**
 * Slop Dashboard - Monospace Web Style
 * Inspired by https://github.com/owickstrom/the-monospace-web
 * Pure ASCII charts, no external dependencies
 */

@font-face {
  font-family: "Berkeley Mono";
  src: url("fonts/BerkeleyMonoVariable.otf") format("opentype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-family: "Berkeley Mono", monospace;
  --line-height: 1.25rem;
  --border-thickness: 1px;
  --text-color: #c9d1d9;
  --text-color-alt: #8b949e;
  --background-color: #0d1117;
  --background-color-alt: #161b22;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-yellow: #d29922;
  --accent-blue: #58a6ff;
  --accent-purple: #a371f7;

  font-family: var(--font-family);
  font-size: 14px;
  font-variant-numeric: tabular-nums lining-nums;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Lobotomized owl - but not inside grids/flex */
* + * {
  margin-top: var(--line-height);
}

/* Reset margins inside grid/flex containers */
.issue-row > *, .commit-row > *, .activity-item > *,
.summary > *, .filters > *, .modal-header > *,
.activity-section > *, .activity-panel > *,
.heatmap-row > *, .file-heatmap > * {
  margin-top: 0;
}

html {
  background: var(--background-color);
  color: var(--text-color);
}

body {
  max-width: 100ch;
  margin: 0 auto;
  padding: var(--line-height) 2ch;
  line-height: var(--line-height);
}

/* Header */
header {
  border-bottom: var(--border-thickness) solid var(--text-color-alt);
  padding-bottom: var(--line-height);
  margin-bottom: var(--line-height);
}

h1 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1ch;
  margin: 0;
}

h1::before {
  content: "# ";
  color: var(--text-color-alt);
}

.updated {
  color: var(--text-color-alt);
  font-size: 0.85rem;
  margin: 0;
  display: block;
}

.essay-link {
  font-size: 0.85rem;
  margin: var(--line-height) 0 0;
  text-align: center;
  color: var(--text-color-alt);
}

.essay-link a {
  color: var(--accent-blue);
  text-decoration: none;
}

.essay-link a:hover {
  text-decoration: underline;
}

/* Section headers */
h2 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  margin: calc(var(--line-height) * 1.5) 0 var(--line-height);
}

h2::before {
  content: "## ";
  color: var(--text-color-alt);
}

/* Summary - inline stats */
.summary {
  display: flex;
  gap: 3ch;
  flex-wrap: wrap;
  padding: var(--line-height) 0;
  border-top: var(--border-thickness) solid var(--text-color-alt);
  border-bottom: var(--border-thickness) solid var(--text-color-alt);
  margin: 0;
}

.stat {
  margin: 0;
}

.stat-value {
  font-weight: 700;
  color: var(--accent-blue);
}

.stat-label {
  color: var(--text-color-alt);
}

/* Priority colors in summary */
.priority-breakdown .p0 { color: var(--accent-red); }
.priority-breakdown .p1 { color: var(--accent-yellow); }
.priority-breakdown .p2 { color: var(--text-color); }
.priority-breakdown .p3 { color: var(--text-color-alt); }

/* ASCII Charts */
.ascii-chart {
  font-family: var(--font-family);
  font-size: 0.85rem;
  line-height: 1.2;
  overflow-x: auto;
  margin: 0;
  color: var(--accent-blue);
}

/* Word Cloud */
.word-cloud {
  line-height: 1.8;
  padding: 1ch;
  border: var(--border-thickness) solid var(--text-color-alt);
}

.cloud-word {
  display: inline-block;
  margin: 0 0.5ch;
  color: var(--accent-blue);
  cursor: default;
  transition: color 0.15s;
}

.cloud-word:hover {
  color: var(--accent-green);
}

/* Filter buttons */
.filters {
  display: flex;
  gap: 1ch;
  margin: var(--line-height) 0;
}

.filter-btn {
  background: transparent;
  border: var(--border-thickness) solid var(--text-color-alt);
  color: var(--text-color);
  padding: 0 1ch;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-btn:hover {
  border-color: var(--text-color);
}

.filter-btn.active {
  background: var(--text-color);
  color: var(--background-color);
}

/* Issue/commit rows */
.issue-row {
  display: grid;
  grid-template-columns: 7ch 11ch 1fr 7ch 3ch;
  gap: 1ch;
  padding: 0;
  border-bottom: var(--border-thickness) solid var(--background-color-alt);
  line-height: calc(var(--line-height) * 1.4);
  font-size: 0.85rem;
  margin: 0;
  align-items: baseline;
}

.commit-row {
  display: grid;
  grid-template-columns: 8ch 1fr 12ch 10ch;
  gap: 1ch;
  padding: 0;
  border-bottom: var(--border-thickness) solid var(--background-color-alt);
  line-height: calc(var(--line-height) * 1.4);
  font-size: 0.85rem;
  margin: 0;
  align-items: baseline;
}

.issue-row:hover, .commit-row:hover {
  background: var(--background-color-alt);
}

.status {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
}

.status.open { color: var(--accent-green); }
.status.closed { color: var(--text-color-alt); }

.issue-id, .commit-sha {
  color: var(--accent-blue);
}

.issue-title, .commit-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority {
  text-align: right;
  font-weight: 600;
}

.priority.p0 { color: var(--accent-red); }
.priority.p1 { color: var(--accent-yellow); }
.priority.p2 { color: var(--text-color); }
.priority.p3 { color: var(--text-color-alt); }

.commit-stats {
  text-align: right;
}

.additions { color: var(--accent-green); }
.deletions { color: var(--accent-red); }

.commit-date {
  color: var(--text-color-alt);
  text-align: right;
}

.bot-marker {
  color: var(--accent-purple);
  font-weight: 600;
}

/* Scrollable containers */
.scroll-container {
  max-height: calc(var(--line-height) * 18);
  overflow-y: auto;
  border: var(--border-thickness) solid var(--text-color-alt);
  padding: 0 1ch;
}

.scroll-container > * {
  margin-top: 0;
}

/* Footer */
footer {
  border-top: var(--border-thickness) solid var(--text-color-alt);
  padding-top: var(--line-height);
  margin-top: calc(var(--line-height) * 2);
  color: var(--text-color-alt);
  font-size: 0.85rem;
}

footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Activity Section - On Deck / Just Completed */
.activity-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3ch;
  margin: var(--line-height) 0;
}

.activity-panel {
  border: var(--border-thickness) solid var(--text-color-alt);
  padding: 1ch;
}

.activity-panel h2 {
  margin: 0 0 var(--line-height);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.activity-panel h2::before {
  content: "▶ ";
  color: var(--accent-green);
}

.activity-panel:last-child h2::before {
  content: "✓ ";
}

.activity-item {
  display: grid;
  grid-template-columns: 3ch 11ch 1fr 7ch;
  gap: 1ch;
  font-size: 0.85rem;
  line-height: calc(var(--line-height) * 1.3);
  cursor: pointer;
  margin: 0;
  align-items: baseline;
}

.activity-item:hover {
  background: var(--background-color-alt);
}

.activity-priority {
  font-weight: 700;
}

.activity-id {
  color: var(--accent-blue);
}

.activity-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-time {
  color: var(--text-color-alt);
  text-align: right;
  font-size: 0.75rem;
}

.activity-item.completed .activity-priority {
  color: var(--accent-green);
}

.activity-empty {
  color: var(--text-color-alt);
  font-style: italic;
  margin: 0;
}

.activity-item.completed .activity-title {
  color: var(--text-color-alt);
}

/* Clickable rows */
.clickable {
  cursor: pointer;
}

.issue-time {
  color: var(--text-color-alt);
  font-size: 0.75rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--background-color);
  border: var(--border-thickness) solid var(--text-color-alt);
  max-width: 80ch;
  width: 90%;
  max-height: 80vh;
  overflow: auto;
  padding: calc(var(--line-height) * 1.5);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 2ch;
  border-bottom: var(--border-thickness) solid var(--text-color-alt);
  padding-bottom: var(--line-height);
  margin: 0;
}

.modal-id {
  font-weight: 700;
  color: var(--accent-blue);
}

.modal-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0 1ch;
  border: var(--border-thickness) solid currentColor;
}

.modal-status.open {
  color: var(--accent-green);
}

.modal-status.closed {
  color: var(--text-color-alt);
}

.modal-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--accent-red);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin: var(--line-height) 0;
}

.modal-meta {
  font-size: 0.85rem;
  color: var(--text-color-alt);
  margin: var(--line-height) 0;
}

.modal-meta .priority {
  font-weight: 700;
}

.modal-type {
  color: var(--accent-purple);
  text-transform: uppercase;
  font-size: 0.75rem;
}

.label {
  background: var(--background-color-alt);
  padding: 0 1ch;
  font-size: 0.75rem;
  border: var(--border-thickness) solid var(--text-color-alt);
}

.modal-body {
  margin: var(--line-height) 0;
}

.modal-desc {
  font-family: var(--font-family);
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  color: var(--text-color);
  background: var(--background-color-alt);
  padding: 1ch;
  margin: 0;
  max-height: 30vh;
  overflow-y: auto;
}

.modal-footer {
  border-top: var(--border-thickness) solid var(--text-color-alt);
  padding-top: var(--line-height);
  margin-top: var(--line-height);
}

.modal-footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

.modal-footer a:hover {
  text-decoration: underline;
}

/* File Heatmap */
.file-heatmap {
  font-family: var(--font-family);
  font-size: 0.85rem;
  border: var(--border-thickness) solid var(--text-color-alt);
  padding: 0 1ch;
  max-height: calc(var(--line-height) * 20);
  overflow-y: auto;
}

.heatmap-row {
  display: grid;
  grid-template-columns: 13ch 4ch 1fr;
  gap: 1ch;
  line-height: calc(var(--line-height) * 1.3);
  margin: 0;
}

.heatmap-row.clickable {
  cursor: pointer;
}

.heatmap-row.clickable:hover {
  background: var(--background-color-alt);
}

.heatmap-bar {
  color: var(--accent-blue);
}

.heatmap-count {
  color: var(--text-color-alt);
  text-align: right;
}

.heatmap-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* File Modal */
.file-modal {
  max-width: 90ch;
}

.file-modal-stats {
  display: flex;
  gap: 3ch;
  padding: var(--line-height) 0;
  border-bottom: var(--border-thickness) solid var(--text-color-alt);
  margin: 0;
}

.file-stat {
  margin: 0;
}

.file-modal-chart {
  margin: var(--line-height) 0;
}

.file-modal-history {
  max-height: 30vh;
  overflow-y: auto;
  border: var(--border-thickness) solid var(--text-color-alt);
  padding: 0 1ch;
  margin: var(--line-height) 0;
}

.file-commit-row {
  display: grid;
  grid-template-columns: 8ch 1fr 10ch 10ch;
  gap: 1ch;
  line-height: calc(var(--line-height) * 1.3);
  font-size: 0.85rem;
  margin: 0;
  border-bottom: var(--border-thickness) solid var(--background-color-alt);
}

.file-commit-row:last-child {
  border-bottom: none;
}

.file-modal-stats > *, .file-commit-row > * {
  margin-top: 0;
}

/* Error state */
.error {
  color: var(--accent-red);
  padding: calc(var(--line-height) * 2);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 1ch;
  height: 1ch;
}

::-webkit-scrollbar-track {
  background: var(--background-color-alt);
}

::-webkit-scrollbar-thumb {
  background: var(--text-color-alt);
}
