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

/* === CSS Custom Properties — Light theme (default) === */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #78716c;
  --text-subtle: #a8a29e;
  --border: #e7e5e4;
  --accent: #0369a1;
  --accent-light: #e0f2fe;
  --tag-bg: #f1f5f9;
  --tag-text: #475569;
  --code-bg: #f1f5f9;
  --code-text: #7c3aed;
  --table-header-bg: #f1f5f9;
  --table-hover: rgba(3, 105, 161, 0.04);
  --winner: #059669;
  --highlight: #d97706;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* === Dark theme === */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --border: #334155;
  --accent: #38bdf8;
  --accent-light: rgba(56, 189, 248, 0.1);
  --tag-bg: #1e293b;
  --tag-text: #94a3b8;
  --code-bg: #1e293b;
  --code-text: #a78bfa;
  --table-header-bg: #1e293b;
  --table-hover: rgba(56, 189, 248, 0.04);
  --winner: #34d399;
  --highlight: #fbbf24;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* === Base === */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

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

/* === Header === */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__logo { height: 17px; width: auto; flex-shrink: 0; }
.site-header__logo path { fill: var(--text-primary); }

.site-header__sep { color: var(--border); font-size: 14px; }

.site-header__title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.site-header__title:hover { text-decoration: none; }

.site-header__breadcrumb { color: var(--text-muted); font-size: 13px; }

.site-header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px;
  color: var(--text-muted);
  transition: color 0.2s;
}
.theme-toggle:hover { color: var(--text-primary); }

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 32px;
  display: flex;
  justify-content: center;
  margin-top: auto;
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.site-footer__logo { width: 90px; height: auto; opacity: 0.5; }
.site-footer__logo path { fill: var(--text-muted); }

.site-footer__text {
  font-size: 12px;
  color: var(--text-subtle);
  text-align: center;
}

.site-footer__text a {
  color: var(--text-muted);
  font-weight: 500;
}

/* === Index Page === */
.index-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
}

.index-page__title {
  font-size: 0.8rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 24px;
}

.index-cards {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
}

.report-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(3, 105, 161, 0.08);
  transform: translateY(-2px);
  text-decoration: none;
}

.report-card__body { flex: 1; }

.report-card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.report-card:hover .report-card__title { color: var(--accent); }

.report-card__desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
}

.report-card__meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-subtle);
}

.report-card__flags {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 16px;
  padding-top: 2px;
}

.report-card__flags a {
  font-size: 18px;
  text-decoration: none;
  opacity: 0.9;
  transition: opacity 0.15s;
}

.report-card__flags a:hover { opacity: 1; }

/* === Report Layout === */
.report-layout {
  display: flex;
  justify-content: center;
  padding: 28px 32px;
  flex: 1;
}

.report-layout__inner {
  display: flex;
  max-width: 920px;
  width: 100%;
}

/* Left: metadata sidebar */
.meta-sidebar {
  width: 150px;
  flex-shrink: 0;
  padding-right: 24px;
  border-right: 1px solid var(--border);
  font-size: 12px;
}

.meta-sidebar__group { margin-bottom: 16px; }

.meta-sidebar__label {
  color: var(--text-subtle);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.meta-sidebar__value { color: var(--text-primary); }

.meta-sidebar__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.meta-sidebar__tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
}

.meta-sidebar__langs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-sidebar__lang {
  font-size: 12px;
  text-decoration: none;
  color: var(--accent);
}

.meta-sidebar__lang:hover { text-decoration: underline; }

.meta-sidebar__lang--active {
  color: var(--text-primary);
  font-weight: 600;
}

/* Center: content */
.report-content {
  flex: 1;
  padding: 0 28px;
  min-width: 0;
  overflow-x: hidden;
}

.report-content h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.report-content__subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.report-content h2 {
  font-size: 1.3rem;
  color: var(--accent);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.report-content h3 {
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.report-content p { margin-bottom: 1rem; color: var(--text-secondary); }
.report-content strong { color: var(--text-primary); }

.report-content code {
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  color: var(--code-text);
}

.report-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: 'Fira Code', monospace;
}

.report-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.report-content .table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.report-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.report-content > table {
  /* Tables not in a wrapper: self-scroll */
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

.report-content th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  background: var(--table-header-bg);
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

.report-content td {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.report-content tr:hover td { background: var(--table-hover); }

.report-content ul, .report-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.report-content li { margin-bottom: 0.3rem; }

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

/* Report-specific classes (used in inline HTML) */
.winner { color: var(--winner); font-weight: 600; }
.highlight { color: var(--highlight); font-weight: 600; }

.audio-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.audio-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 220px;
  font-family: 'Fira Code', monospace;
}
audio { height: 32px; flex: 1; min-width: 200px; }
[data-theme="dark"] audio { filter: invert(1) hue-rotate(180deg) brightness(0.85); }

.audio-grid {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.audio-grid-title {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compare-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.compare-card {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.compare-card h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.polish-note {
  background: var(--accent-light);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
}

.polish-note strong { color: var(--accent); }

.polish-note em {
  color: var(--text-primary);
  font-style: normal;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
}

.folx-banner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.folx-banner__logo { height: 36px; width: auto; flex-shrink: 0; }
.folx-banner__logo path { fill: var(--text-primary); }

.folx-banner__text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.folx-banner__text strong { color: var(--text-primary); }

.para-sample { margin-bottom: 0.75rem; }
.para-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-style: italic;
}
.para-sample audio { width: 100%; }

/* Right: TOC sidebar */
.toc-sidebar {
  width: 150px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  position: sticky;
  top: 60px;
  align-self: flex-start;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.toc-sidebar__title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.toc-sidebar__item {
  display: block;
  padding: 3px 0 3px 8px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.toc-sidebar__item:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc-sidebar__item--active {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* === Mobile === */
@media (max-width: 768px) {
  .report-layout { padding: 16px; }
  .report-layout__inner { flex-direction: column; }

  .meta-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 16px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
  }

  .meta-sidebar__group { margin-bottom: 0; }

  .report-content { padding: 0; }

  .toc-sidebar {
    position: static;
    width: 100%;
    max-height: none;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--code-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
  }

  .compare-pair { grid-template-columns: 1fr; }

  .audio-row { flex-direction: column; align-items: flex-start; }
  .audio-label { min-width: auto; }
  audio { width: 100%; }

  .site-header__breadcrumb {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .report-card__flags { flex-direction: row; margin-left: 12px; }
}
