/* Aligned with Whisper Shortcut web app design tokens */

:root {
  /* Whisper Shortcut palette */
  --bg: #0f0f0f;
  --fg: #fafafa;
  --muted: #a1a1a1;
  --accent: #3b82f6;
  --card: #1a1a1a;
  --border: #2a2a2a;
  /* Spacing (8px base) */
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  /* Typography */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  /* Aliases for existing selectors */
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  line-height: var(--leading-normal);
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header */
header {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-8);
  text-align: center;
}

header h1 {
  font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl));
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.02em;
  color: var(--fg);
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-base);
  max-width: 36em;
  margin-left: auto;
  margin-right: auto;
  line-height: var(--leading-relaxed);
}

header p + p {
  margin-top: var(--space-3);
}

/* Inline links in header intro: accent, underline on hover */
header p a {
  color: var(--accent);
  text-decoration: none;
}

header p a:hover {
  text-decoration: underline;
}

/* Standalone header link (if any): same as inline */
header a {
  display: inline;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  font-weight: inherit;
  font-size: inherit;
}

header a:hover {
  background: none;
  border: none;
}

/* Main */
main {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-12);
}

main > h2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  margin: 0 0 var(--space-4);
  color: var(--fg);
  letter-spacing: -0.01em;
}

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: var(--space-3);
}

.table-wrap::-webkit-scrollbar {
  height: 6px;
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--card);
  border-radius: 3px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 3px;
  opacity: 0.5;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead {
  background: var(--card);
}

th {
  text-align: left;
  padding: var(--space-4) var(--space-5);
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

th:first-child {
  border-radius: var(--radius) 0 0 0;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition), background var(--transition);
}

th.sortable:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.03);
}

th:nth-child(3),
th:nth-child(4) {
  white-space: normal;
  line-height: 1.35;
  min-width: 5rem;
}

th .sort-icon {
  margin-left: 0.35rem;
  opacity: 0.5;
  font-size: 0.7em;
}

th.sort-asc .sort-icon::after {
  content: " ↑";
  opacity: 1;
  color: var(--accent);
}

th.sort-desc .sort-icon::after {
  content: " ↓";
  opacity: 1;
  color: var(--accent);
}

td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:last-child td:first-child {
  border-radius: 0 0 0 var(--radius);
}

tbody tr:last-child td:last-child {
  border-radius: 0 0 var(--radius) 0;
}

td:first-child {
  font-weight: var(--font-semibold);
  color: var(--fg);
}

td:nth-child(2) {
  color: var(--muted);
  font-size: 0.85rem;
}

td:nth-child(3) {
  font-variant-numeric: tabular-nums;
  font-weight: var(--font-medium);
}

td:nth-child(5) {
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  font-weight: var(--font-medium);
}

td:last-child {
  color: var(--muted);
  font-size: var(--text-sm);
  max-width: 280px;
}

.legend-footnote {
  margin-top: var(--space-3);
  padding: 0;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--muted);
}

.legend-footnote strong {
  color: var(--muted);
  font-weight: var(--font-semibold);
}

.legend-footnote a {
  color: var(--accent);
  text-decoration: none;
}

.legend-footnote a:hover {
  text-decoration: underline;
}

/* Footer */
.page-footer {
  margin-top: var(--space-10);
  font-size: var(--text-sm);
  color: var(--muted);
}

.page-footer .legend {
  padding: var(--space-5) var(--space-6);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  line-height: var(--leading-relaxed);
}

.page-footer .legend strong {
  color: var(--fg);
}

.page-footer .sources,
.page-footer .license {
  margin-bottom: var(--space-5);
  padding: var(--space-5) var(--space-6);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.page-footer .sources ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem var(--space-3);
  margin: var(--space-3) 0 0;
  padding-left: 0;
  list-style: none;
}

.page-footer .sources li {
  margin-bottom: 0;
  line-height: var(--leading-normal);
}

.page-footer .sources li:not(:last-child)::after {
  content: ' · ';
  margin-left: var(--space-3);
  color: var(--muted);
}

.page-footer h2 {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  margin: 0 0 var(--space-3);
  color: var(--fg);
  letter-spacing: -0.01em;
}

.page-footer ul {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-6);
}

.page-footer li {
  margin-bottom: 0.35rem;
  line-height: var(--leading-normal);
}

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

.page-footer .sources a {
  word-break: break-all;
}

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

.page-footer-legal {
  margin: var(--space-6) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
}

.page-footer-legal .page-footer-sep,
.page-footer-legal .page-footer-made-in {
  color: var(--muted);
}

.page-footer-legal a {
  color: var(--muted);
  text-decoration: none;
}

.page-footer-legal a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.page-footer-other-projects {
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-6);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.page-footer-other-projects h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--fg);
  letter-spacing: -0.01em;
}

.other-projects-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.other-project-card {
  display: flex;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  min-width: 0;
}

.other-project-icon-link {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition);
}

.other-project-icon-link:hover {
  opacity: 0.9;
}

.other-project-icon {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
}

.other-project-icon-placeholder {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
}

.other-project-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

.other-project-text strong {
  font-size: var(--text-sm);
  color: var(--fg);
}

.other-project-text > span:not(.other-project-links) {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.4;
}

.other-project-links {
  font-size: var(--text-xs);
}

.other-project-links a {
  color: var(--accent);
}

@media (max-width: 640px) {
  header {
    padding: var(--space-8) var(--space-4) var(--space-6);
  }

  main {
    padding: 0 var(--space-4) var(--space-8);
  }

  th,
  td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-xs);
  }

  td:last-child {
    max-width: 180px;
  }

  .other-project-card {
    flex-wrap: wrap;
  }
}
