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

/* ── Design tokens ── */
:root {
  --bg:            #0e0e0f;
  --surface:       #161618;
  --surface-hover: #1e1e21;
  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(255,255,255,0.18);
  --text:          #f0ede8;
  --muted:         #7a7a82;
  --accent:        #c8f060;
  --font-serif:    'Instrument Serif', Georgia, serif;
  --font-mono:     'DM Mono', 'Courier New', monospace;
}

/* ── Base ── */
html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Skip link (a11y) ── */
.skip-link {
  position: absolute;
  top: -999px;
  left: 1rem;
  background: var(--accent);
  color: #000;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ── Header ── */
header {
  padding: 4rem 2rem 2rem;
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--accent);
}

h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 480px;
}

/* ── Divider ── */
.divider {
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
  padding: 0 2rem;
}
.divider hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0 2.5rem;
}

/* ── Main content wrapper ── */
.grid-wrap {
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
  padding: 0 2rem;
  flex: 1;
}

/* ── Status badge (shared) ── */
.badge {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  border-radius: 3px;
  padding: 2px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-live     { background: rgba(200,240,96,0.12); color: #c8f060; }
.badge-wip      { background: rgba(255,180,50,0.12);  color: #f4a820; }
.badge-archived { background: rgba(255,255,255,0.06); color: var(--muted); }

/* ── Tags (shared) ── */
.tag {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--muted);
}

/* ── Table ── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.project-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

/* Minimum widths — let columns grow naturally beyond these */
.col-name    { min-width: 160px; }
.col-desc    { min-width: 180px; width: 99%; } /* width:99% lets desc absorb spare space */
.col-tags    { min-width: 100px; white-space: nowrap; }
.col-status  { min-width: 80px;  white-space: nowrap; }
.col-updated { min-width: 110px; white-space: nowrap; }
.col-actions { min-width: 130px; white-space: nowrap; }

/* ── Header row ── */
.project-table thead tr {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.project-table th {
  padding: 0;
  text-align: left;
  font-weight: 400;
}

.project-table th.col-desc,
.project-table th.col-tags,
.project-table th.col-actions {
  padding: 0 1rem;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  height: 40px;
  vertical-align: middle;
}

/* ── Sort buttons (Name, Status, Updated headers) ── */
.sort-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  height: 40px;
  padding: 0 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.12s;
  text-align: left;
  white-space: nowrap;
}
.sort-btn:hover { color: var(--text); }
.sort-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.sort-btn.active { color: var(--accent); }

.sort-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0.3;
  transition: opacity 0.12s;
}
.sort-btn:hover .sort-icon,
.sort-btn.active .sort-icon { opacity: 1; }

/* Chevron up */
.sort-icon::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 4px solid currentColor;
}
/* Chevron down */
.sort-icon::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid currentColor;
}

/* asc: dim the down chevron */
.sort-btn[data-dir="asc"]  .sort-icon::after  { opacity: 0.2; }
/* desc: dim the up chevron */
.sort-btn[data-dir="desc"] .sort-icon::before { opacity: 0.2; }

/* ── Body rows ── */
.project-table tbody tr {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.12s, box-shadow 0.12s;
  position: relative;
}
.project-table tbody tr:last-child { border-bottom: none; }
.project-table tbody tr:hover { background: var(--surface-hover); }
.project-table tbody tr:hover td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}
.project-table tbody tr[hidden] { display: none; }

.project-table td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  font-size: 12px;
  color: var(--text);
}

/* ── Name cell ── */
.td-name-link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-decoration: none;
  color: inherit;
}
.td-name-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.td-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.td-name-link:hover .td-name { color: var(--accent); }
.td-path {
  font-size: 10px;
  color: var(--accent);
  opacity: 0.6;
}

/* ── Desc cell ── */
.td-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Tags cell ── */
.td-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Status cell ── */
.col-status { text-align: center; }
.project-table td.col-status { text-align: center; }

/* ── Actions cell ── */
.td-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.td-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  white-space: nowrap;
}
.td-action:hover {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255,255,255,0.04);
}
.td-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.td-action svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── State rows ── */
.state-msg {
  text-align: center;
  padding: 3rem 2rem;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem 4rem;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.empty-illustration {
  width: 160px;
  height: auto;
  margin-bottom: 1.25rem;
  color: var(--text);
}
.empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.empty-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.empty-hint code {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* ── Updated cell ── */
.td-updated {
  font-size: 11px;
  color: var(--muted);
  cursor: default;
}
.td-updated[title] {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

/* ── Responsive: collapse desc, tags, updated on narrow screens ── */
@media (max-width: 600px) {
  .col-desc, .col-tags, .col-updated,
  .project-table td:nth-child(2),
  .project-table td:nth-child(3),
  .project-table td:nth-child(5) { display: none; }
}

/* ── Footer ── */
footer {
  max-width: 1020px;
  margin: 3rem auto 2rem;
  width: 100%;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  gap: 1rem;
  flex-wrap: wrap;
}
footer a {
  color: var(--muted);
  text-decoration: none;
}
footer a:hover { color: var(--text); }

footer code {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* ── Responsive ── */
@media (max-width: 540px) {
  header, .divider, .grid-wrap, footer { padding-left: 1.25rem; padding-right: 1.25rem; }
  header { padding-top: 2.5rem; }
}

/* ── Controls (search + tag filters) ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 14px;
  height: 14px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 9px 36px 9px 36px;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--border-hover); }
/* Hide browser-native clear button */
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--muted);
  transition: color 0.12s, background 0.12s;
}
.search-clear:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.search-clear svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Tag filter chips ── */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-filter {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 9px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  user-select: none;
}
.tag-filter:hover {
  color: var(--text);
  border-color: var(--border-hover);
}
.tag-filter.active {
  background: rgba(200,240,96,0.1);
  border-color: rgba(200,240,96,0.35);
  color: var(--accent);
}
.tag-filter:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── No-results message ── */
.no-results {
  padding: 2.5rem 0 1rem;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}
.no-results span { font-style: normal; color: var(--text); }

/* ── Count bar ── */
.count-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  min-height: 1.5rem;
}

#count-text {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.count-reset {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.count-reset:hover {
  color: var(--text);
  border-color: var(--border-hover);
}
.count-reset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
