:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f3f8f9;
  --color-surface: #ffffff;
  --color-text: #12252a;
  --color-text-secondary: #46626a;
  --color-border: #d7e3e5;
  --color-primary: #0d5c63;
  --color-primary-dark: #0a4a52;
  --color-accent: #00b4d8;
  --color-accent-strong: #007690;
  --color-focus: #006e86;
  --color-empty-bg: #fff8ec;
  --color-empty-text: #7a5b17;
  --color-empty-border: #f0dfb0;
  --color-error-bg: #fdf0ee;
  --color-error-text: #9c2b1f;
  --color-error-border: #f3c9c2;
  --color-neutral-bg: #eef4f5;
  --shadow-sm: 0 1px 3px rgba(13, 92, 99, 0.12);
  --shadow-md: 0 6px 20px rgba(13, 92, 99, 0.14);
  --radius-md: 0.6rem;
  --radius-lg: 1rem;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #081a1f;
    --color-bg-alt: #0d252b;
    --color-surface: #102931;
    --color-text: #eaf3f4;
    --color-text-secondary: #a9c1c6;
    --color-border: #1e3a41;
    --color-primary: #1e8790;
    --color-primary-dark: #166b73;
    --color-accent: #2fd0ec;
    --color-accent-strong: #4fd9f0;
    --color-focus: #4fd9f0;
    --color-empty-bg: #2a2213;
    --color-empty-text: #f0cf7a;
    --color-empty-border: #4d3f1c;
    --color-error-bg: #2c1512;
    --color-error-text: #f5a89c;
    --color-error-border: #5c2a23;
    --color-neutral-bg: #12292f;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 2rem 1.25rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
}

main {
  max-width: 46rem;
  margin: 0 auto;
}

a {
  color: var(--color-accent-strong);
}

a:hover {
  color: var(--color-primary);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  color: var(--color-primary);
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2rem;
  color: var(--color-primary);
}

h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

p {
  margin: 0 0 1rem;
}

/* Hero / busca */

.hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.tagline {
  color: var(--color-text-secondary);
  font-size: 1.05rem;
  max-width: 34rem;
  margin: 0 auto 1.75rem;
}

.search-box {
  position: relative;
  max-width: 32rem;
  margin: 0 auto;
  text-align: left;
}

.search-box label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 1.1rem;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.75rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  min-height: 3.25rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

input[type="search"]:hover {
  border-color: var(--color-accent);
}

input[type="search"]:focus-visible {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  outline-offset: 3px;
}

/* Estados: hint, loading, empty, error */

#resultados {
  margin-top: 1.5rem;
}

.hint,
.loading,
.empty-state,
.error-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-neutral-bg);
  color: var(--color-text-secondary);
}

.hint::before,
.loading::before,
.empty-state::before,
.error-state p::before {
  content: "";
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.hint::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23000' stroke-width='2'/%3E%3Cline x1='12' y1='11' x2='12' y2='17' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='7.5' r='1.2' fill='%23000'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23000' stroke-width='2'/%3E%3Cline x1='12' y1='11' x2='12' y2='17' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='7.5' r='1.2' fill='%23000'/%3E%3C/svg%3E");
}

.loading {
  color: var(--color-accent-strong);
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-neutral-bg));
}

.loading::before {
  animation: spin 0.9s linear infinite;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23000' stroke-width='2' stroke-dasharray='38 18' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23000' stroke-width='2' stroke-dasharray='38 18' stroke-linecap='round'/%3E%3C/svg%3E");
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  color: var(--color-empty-text);
  background: var(--color-empty-bg);
  border-color: var(--color-empty-border);
}

.empty-state::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='7' width='17' height='13' rx='1.5' fill='none' stroke='%23000' stroke-width='2'/%3E%3Cpath d='M3.5 7l8.5 6 8.5-6' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='7' width='17' height='13' rx='1.5' fill='none' stroke='%23000' stroke-width='2'/%3E%3Cpath d='M3.5 7l8.5 6 8.5-6' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.error-state {
  flex-direction: column;
  align-items: flex-start;
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
}

.error-state p {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.85rem;
}

.error-state p::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3l10 18H2z' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3Cline x1='12' y1='10' x2='12' y2='15' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='18' r='1.1' fill='%23000'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3l10 18H2z' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3Cline x1='12' y1='10' x2='12' y2='15' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='18' r='1.1' fill='%23000'/%3E%3C/svg%3E");
}

/* Botões */

button,
.error-state button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary);
  border: none;
  padding: 0.65rem 1.4rem;
  min-height: 2.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.error-state button:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.error-state button:active {
  transform: translateY(0);
}

/* Lista de atletas */

.athlete-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.athlete-list-item {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  text-align: left;
  padding: 0.85rem 1.1rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.athlete-list-item::first-letter {
  display: inline-block;
  float: left;
  width: 2.25rem;
  height: 2.25rem;
  line-height: 2.25rem;
  margin: 0 0.75rem 0.25rem 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
}

.athlete-list-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.athlete-list-item:active {
  transform: translateY(0);
}

/* Resultados por ano */

.year-group {
  margin-top: 2rem;
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-top: 0.6rem;
}

table {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
  background: var(--color-surface);
}

th,
td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: var(--color-bg-alt);
}

tbody tr:hover {
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
}

/* Páginas legais */

.back-link {
  margin-bottom: 1.5rem;
}

.back-link a {
  display: inline-block;
  font-weight: 600;
  text-decoration: none;
}

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

/* Rodapé */

footer {
  max-width: 46rem;
  margin: 2.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-align: center;
}

footer a {
  text-decoration: underline;
}

/* Responsivo */

@media (max-width: 480px) {
  body {
    padding: 1.25rem 1rem;
  }

  h1 {
    font-size: 1.7rem;
  }

  .athlete-list-item {
    padding: 0.75rem 0.9rem;
  }
}
