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

:root {
  --color-bg: #f6f9f8;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #4a5568;
  --color-primary: #0f766e;
  --color-primary-dark: #0d5f59;
  --color-primary-light: #ccfbf1;
  --color-accent: #d94f3d;
  --color-border: #d5ddd9;
  --color-focus: #2563eb;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
  --container-max: 68rem;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Skip link === */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 1000;
  padding: 0.75rem 1.25rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* === Focus styles === */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

a:focus:not(:focus-visible) {
  outline: none;
}

/* === Screen reader only === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Container === */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* === Header === */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1.15rem;
}

.logo-icon {
  font-size: 1.4rem;
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.nav-list a {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  text-decoration: none;
  color: var(--color-text-muted);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-list a:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.nav-list a[aria-current="page"] {
  background: var(--color-primary);
  color: #fff;
}

/* === Hero === */
.hero {
  padding: 3.5rem 0 3rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, #115e59 100%);
  color: #fff;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.hero-lead {
  font-size: 1.15rem;
  line-height: 1.6;
  opacity: 0.92;
  max-width: 38rem;
  margin-bottom: 1.75rem;
}

.hero-lead strong {
  color: #99f6e4;
  font-weight: 700;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  cursor: pointer;
  border: 2px solid transparent;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #fff;
  color: var(--color-primary-dark);
}

.btn-primary:hover {
  background: #f0fdfa;
}

.btn-secondary {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-secondary:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* === Stats === */
.stats-section {
  padding: 2.5rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-number {
  display: block;
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* === Sections === */
.levels-section,
.recent-section {
  padding: 2.5rem 0;
}

.levels-section h2,
.recent-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
}

.section-more {
  margin-top: 1.25rem;
}

.section-more a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

.section-more a:hover {
  text-decoration: underline;
}

/* === Level cards === */
.level-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.level-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  min-width: 10rem;
}

.level-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow);
}

.level-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.level-count {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* === Country chips === */
.country-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 2rem;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.country-chip:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.country-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 700;
}

/* === Page container === */
.page-container {
  padding-top: 2.5rem;
  padding-bottom: 3rem;
}

.page-lead {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  margin-bottom: 1.75rem;
  max-width: 40rem;
}

/* === Search === */
.search-controls {
  margin-bottom: 1.75rem;
}

.search-input {
  width: 100%;
  max-width: 28rem;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  min-height: 1.4em;
}

/* === Fund grid === */
.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1rem;
}

.fund-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
}

.fund-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--color-primary);
}

.fund-card[hidden] {
  display: none;
}

.fund-card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.25rem;
}

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

.fund-card-title a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.fund-card-short {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.fund-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  font-size: 0.9rem;
}

.fund-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.meta-label {
  display: none;
}

.fund-card-code {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  letter-spacing: 0.01em;
}

/* === Badge === */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-level {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* === No results === */
.no-results {
  padding: 2rem;
  text-align: center;
  font-size: 1.05rem;
  color: var(--color-text-muted);
}

/* === Country grid === */
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem;
}

.country-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.15rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.country-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.country-card-count {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* === Breadcrumb === */
.breadcrumb {
  margin-bottom: 1.5rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-left: 0.35rem;
  color: var(--color-border);
}

.breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb [aria-current] {
  color: var(--color-text);
  font-weight: 600;
}

/* === Fund detail === */
.fund-header {
  margin-bottom: 2rem;
}

.fund-header h1 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.fund-short-name {
  margin-top: 0.25rem;
  font-size: 1.1rem;
  color: var(--color-primary);
  font-weight: 600;
}

.fund-other-name {
  margin-top: 0.25rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.fund-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 48rem) {
  .fund-detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.detail-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.detail-section h2 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
}

.detail-list dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.detail-list dd {
  font-size: 0.95rem;
  word-break: break-word;
}

.detail-list code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--color-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
}

.detail-list a {
  color: var(--color-primary);
  text-decoration: none;
}

.detail-list a:hover {
  text-decoration: underline;
}

/* === Link list === */
.link-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.link-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.link-list a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

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

.link-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.no-links {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* === Notes section === */
.notes-section {
  margin-top: 1rem;
}

/* === Fund nav === */
.fund-nav {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.fund-nav a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.fund-nav a:hover {
  text-decoration: underline;
}

/* === Taxonomy list === */
.taxonomy-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.5rem;
}

.taxonomy-list li a {
  display: block;
  padding: 0.7rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  transition: border-color 0.15s;
}

.taxonomy-list li a:hover {
  border-color: var(--color-primary);
}

.taxonomy-count {
  color: var(--color-text-muted);
  font-weight: 400;
}

/* === Footer === */
.site-footer {
  margin-top: 3rem;
  padding: 1.75rem 0;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}

.site-footer p {
  margin-bottom: 0.25rem;
}

.site-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

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

/* === Responsive === */
@media (max-width: 40rem) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-list {
    gap: 0.1rem;
  }

  .hero {
    padding: 2.5rem 0 2rem;
  }

  .fund-grid {
    grid-template-columns: 1fr;
  }

  .country-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .detail-list dt {
    margin-top: 0.35rem;
  }
}

/* === Print === */
@media print {
  .skip-link,
  .search-controls,
  .hero-actions,
  nav[aria-label="Main navigation"] {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .fund-card,
  .detail-section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
