/* ==========================================================================
   VARIABLES
   ========================================================================== */
:root {
  --bg:              #ffffff;
  --bg-subtle:       #f8fafc;
  --bg-section:      #f1f5f9;
  --border:          #e2e8f0;
  --border-strong:   #cbd5e1;
  --text:            #0f172a;
  --text-muted:      #64748b;
  --text-faint:      #94a3b8;
  --accent:          #2563eb;
  --accent-dim:      #1d4ed8;
  --accent-subtle:   #eff6ff;
  --accent-border:   #93c5fd;
  --accent-partial:  #94a3b8;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-size-base: 15px;
  --line-height: 1.65;
  --radius: 6px;
  --nav-height: 60px;
  --header-height: 64px; /* nav-height + 4px top border */
}

[data-theme="dark"] {
  --bg:              #09090b;
  --bg-subtle:       #18181b;
  --bg-section:      #27272a;
  --border:          #3f3f46;
  --border-strong:   #52525b;
  --text:            #fafafa;
  --text-muted:      #a1a1aa;
  --text-faint:      #71717a;
  --accent:          #60a5fa;
  --accent-dim:      #93c5fd;
  --accent-subtle:   rgba(96, 165, 250, 0.08);
  --accent-border:   rgba(96, 165, 250, 0.3);
  --accent-partial:  #71717a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:              #09090b;
    --bg-subtle:       #18181b;
    --bg-section:      #27272a;
    --border:          #3f3f46;
    --border-strong:   #52525b;
    --text:            #fafafa;
    --text-muted:      #a1a1aa;
    --text-faint:      #71717a;
    --accent:          #60a5fa;
    --accent-dim:      #93c5fd;
    --accent-subtle:   rgba(96, 165, 250, 0.08);
    --accent-border:   rgba(96, 165, 250, 0.3);
    --accent-partial:  #71717a;
  }
}

/* ==========================================================================
   RESET / BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

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

a:hover {
  color: var(--accent-dim);
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
main {
  flex: 1;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* ==========================================================================
   HEADER / NAV
   ========================================================================== */
.site-header {
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--border);
}

.site-header nav {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: var(--nav-height);
  gap: 1.5rem;
}

.nav-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-home {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.nav-home:hover .site-name { color: var(--accent); }
.nav-home:hover { text-decoration: none; }

.site-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.logo-dark {
  display: none;
}

[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark  { display: block; }
}

.site-name {
  font-weight: 700;
  font-size: 0.975rem;
  color: var(--text);
  letter-spacing: -0.015em;
  transition: color 0.15s;
  white-space: nowrap;
}

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

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-subtle);
  text-decoration: none;
}

.nav-link--active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.nav-link--active:hover {
  color: var(--accent-dim);
  background: var(--accent-subtle);
  text-decoration: none;
}

.header-controls {
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.github-link {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: color 0.15s;
}

.github-link:hover {
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.775rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.35rem 0.875rem;
  border-radius: 99px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg-subtle);
}

/* ==========================================================================
   READING PROGRESS
   ========================================================================== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: var(--accent-border);
  width: 0%;
  z-index: 200;
  transition: width 0.1s linear;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.ambient-bar,
.site-footer {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  text-align: center;
}

.ambient-label,
.site-footer-label {
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* ==========================================================================
   TOOLS INTRO
   ========================================================================== */
.tools-intro {
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.tools-intro__title {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.045em;
  line-height: 1.1;
  margin-bottom: 1.5rem;
}

.tools-intro__inner p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: 0.75rem;
  max-width: 68ch;
}

.tools-intro__inner p:last-child {
  margin-bottom: 0;
}

.tools-intro__actions {
  margin-top: 2rem;
}

.tools-intro__link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  padding: 0.55rem 1.125rem;
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}

.tools-intro__link:hover {
  color: var(--accent-dim);
  background: var(--accent-subtle);
  border-color: var(--accent);
  text-decoration: none;
}

/* ==========================================================================
   MATRIX TABLE
   ========================================================================== */
.tools-section {
  margin-bottom: 3.5rem;
}

.tools-heading {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.875rem;
}

.tools-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.matrix-legend {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.matrix-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tools-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.875rem;
}

/* Hugo table display reset */
.tools-table thead { display: table-header-group; }
.tools-table tbody { display: table-row-group; }
.tools-table tr    { display: table-row; }
.tools-table th,
.tools-table td    { display: table-cell; }
.tools-table       { overflow: visible !important; }
table, thead, tbody, tr, th, td { contain: initial; }

.tools-table th,
.tools-table td {
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  word-wrap: break-word;
}

.tools-table thead tr:last-child th {
  border-bottom: 2px solid var(--border-strong);
}

.tools-table tbody tr:last-child td {
  border-bottom: none;
}

.tools-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  font-size: 0.775rem;
}

.tools-table tr.tools-table-phases th {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  background: var(--bg-section);
  border-bottom: none;
  padding-top: 0.5rem;
  padding-bottom: 0.3rem;
}

.tools-table tbody tr:hover td {
  background: var(--bg-subtle);
}

.tools-table .phase-divider {
  border-left: 2px solid var(--border-strong);
}

.tool-matrix-row {
  cursor: pointer;
  transition: background 0.1s;
}

.tool-matrix-row:focus-visible td {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Capability indicators — matrix */
.tools-matrix-table tbody td {
  vertical-align: middle;
  text-align: center;
}

.tools-matrix-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text);
}

.tools-matrix-table td .capability,
.matrix-legend .capability {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.tools-matrix-table td .capability::before,
.matrix-legend .capability::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tools-matrix-table td .capability.full::before,
.matrix-legend .capability.full::before {
  background: var(--accent);
}

.tools-matrix-table td .capability.partial::before,
.matrix-legend .capability.partial::before {
  background: linear-gradient(to right, var(--accent-partial) 50%, transparent 50%);
  border: 1.5px solid var(--accent-partial);
  box-sizing: border-box;
}

/* ==========================================================================
   TOOL DETAIL CARDS
   ========================================================================== */
.tools-detail-section {
  margin-top: 0.5rem;
}

.tools-detail-grid {
  display: flex;
  flex-direction: column;
}

.tool-detail-card {
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

.tool-detail-card:last-child {
  border-bottom: 1px solid var(--border);
}

.tool-detail-card:target {
  background: var(--accent-subtle);
}

.tool-detail-body {
  padding: 2.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-detail-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.tool-detail-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}

.tool-detail-description {
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 78ch;
}

.tool-detail-description p { margin-bottom: 0.5rem; }
.tool-detail-description p:last-child { margin-bottom: 0; }

.tool-detail-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2.5rem;
  padding: 1.125rem 1.375rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tool-detail-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tool-detail-info-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}

.tool-detail-info-link {
  font-size: 0.875rem;
  color: var(--accent);
  word-break: break-all;
}

.tool-detail-info-link:hover {
  color: var(--accent-dim);
  text-decoration: underline;
}

.tool-detail-info-value {
  font-size: 0.875rem;
  color: var(--text);
}

.tool-detail-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.tool-detail-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tool-detail-table-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}

.tool-goals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tool-goals-table thead th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 0.75rem;
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.tool-goals-table tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  width: 45%;
  vertical-align: top;
}

.tool-goals-table tbody td {
  padding: 0.45rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.825rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

.tool-goals-table tbody tr:last-child th,
.tool-goals-table tbody tr:last-child td {
  border-bottom: none;
}

/* Detail card: pill-style capability labels */
.tool-detail-tables .capability {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  letter-spacing: 0.04em;
  border-radius: 99px;
  text-transform: uppercase;
}

.tool-detail-tables .capability.full {
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
}

.tool-detail-tables .capability.partial {
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.capability-description {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

/* ==========================================================================
   READING PROGRESS BAR
   ========================================================================== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: #ffffff;
  transform: scaleX(0);
  transform-origin: left;
  z-index: 1000;
  transition: transform 0.1s linear;
}

/* ==========================================================================
   BACK TO TOP
   ========================================================================== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.15s, box-shadow 0.15s;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   CONTENT PAGES (single / article)
   ========================================================================== */
.article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.75rem;
  margin-bottom: 2.5rem;
}

.article-meta {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 0.6rem;
}

.article-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.2;
  color: var(--text);
}

.article-body {
  max-width: 72ch;
  font-size: 0.95rem;
  line-height: 1.8;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.article-body h1 { font-size: 1.5rem; }
.article-body h2 { font-size: 1.25rem; }
.article-body h3 { font-size: 1.05rem; }
.article-body h4 { font-size: 0.95rem; }

.article-body p { margin-bottom: 1rem; color: var(--text); }
.article-body p:last-child { margin-bottom: 0; }

.article-body ul,
.article-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.article-body li { margin-bottom: 0.25rem; }

.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--text);
}

.article-body pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.article-body table th,
.article-body table td {
  text-align: left;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border);
}

.article-body table th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.article-body table tbody tr:last-child td {
  border-bottom: none;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding-top: 1.5rem;
  font-size: 0.875rem;
}

.article-nav a {
  color: var(--text-muted);
}

.article-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

/* ==========================================================================
   POST LIST
   ========================================================================== */
.post-item {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
}

.post-item:last-child {
  border-bottom: 1px solid var(--border);
}

.post-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.post-title a {
  color: var(--text);
  text-decoration: none;
}

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

.post-date {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
}

.post-excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.6rem 0;
  line-height: 1.65;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.post-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

.continue-reading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.continue-reading:hover {
  color: var(--accent-dim);
}

/* ==========================================================================
   ERROR PAGES (404)
   ========================================================================== */
.error-page {
  padding: 7rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--border-strong);
  line-height: 1;
  letter-spacing: -0.06em;
}

.error-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.error-message {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  max-width: 48ch;
}

.error-home-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  padding: 0.55rem 1.125rem;
  border-radius: var(--radius);
  transition: border-color 0.15s, color 0.15s;
  text-decoration: none;
  margin-top: 0.5rem;
  width: fit-content;
}

.error-home-link:hover {
  color: var(--accent-dim);
  border-color: var(--accent);
  text-decoration: none;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  .tool-detail-tables {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1.5rem 1.25rem;
  }

  .tools-intro {
    padding: 2.5rem 0 2rem;
  }

  .tools-intro__title {
    font-size: 1.9rem;
    letter-spacing: -0.035em;
  }

  .tools-table th,
  .tools-table td {
    font-size: 0.8rem;
    padding: 0.45rem 0.6rem;
  }

  .back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
  }

  .article-title {
    font-size: 1.5rem;
  }

  .article-body {
    font-size: 0.9rem;
  }
}

@media (max-width: 560px) {
  .site-header nav {
    padding: 0 1.25rem;
    gap: 0.75rem;
  }

  .site-name {
    font-size: 0.9rem;
  }

  .nav-links {
    display: none;
  }

  .tools-intro__title {
    font-size: 1.55rem;
    letter-spacing: -0.025em;
  }
}
