/* ============================================================
   Somabay Endurance Festival 2026 — Start Lists · Styles
   ============================================================

   ============================================================ */

:root {
  /* ── Colour palette (white theme) ──────────────────── */
  --bg:            #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f4f5f7;
  --border:        #e2e5ea;
  --border-focus:  #1a1a2e;
  --text-primary:  #1a1a2e;
  --text-secondary:#4a5568;
  --text-muted:    #9aa5b4;
  --accent:        #1a1a2e;
  --gold:          #9a6f00;
  --male:          #1a5fb4;
  --female:        #c01c28;
  --mixed:         #c05800;
  --radius:        12px;
  --radius-sm:     8px;
  --transition:    0.2s ease;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow:        0 4px 20px rgba(0,0,0,0.07);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Utility ────────────────────────────────────────── */
/* .hidden is the initial CSS-only hide; JS overrides via element.style.display */
.hidden { display: none; }
.logo-missing { display: none; }
/* Hide the logos container when both logos fail to load */
.hero-logos:has(.logo-company.logo-missing):has(.logo-event.logo-missing) { display: none; }

/* ── HERO ──────────────────────────────────────────── */
.hero {
  position: relative;
  height: 550px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background-image: url("assets/header-bg/background.jpeg");
  background-size: cover;
  background-position: center;
  background-color: #1a1a2e; /* fallback when no image */
}

/* dark gradient overlay so white text is always readable */
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.52) 0%,
    rgba(0, 0, 0, 0.65) 100%
  );
  z-index: 0;
}

/* thin accent line at the bottom of the hero */
.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  padding: 24px 24px 24px;
  padding-top: 48px; /* shifts content slightly downward */
  width: 100%;
  margin: 0 auto;
}

/* ── Logos ─────────────────────────────────────────── */
.hero-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-bottom: 28px;
  animation: fadeUp 0.5s ease both;
}

.logo {
  height: 56px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  opacity: 0.92;
  transition: opacity var(--transition);
}

.logo:hover { opacity: 1; }

/* ── Hero text ─────────────────────────────────────── */
.hero h1 {
  font-size: clamp(1.2rem, 3.2vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  white-space: nowrap;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  margin-bottom: 14px;
  animation: fadeUp 0.5s 0.08s ease both;
}

.hero-subtitle {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.75);
  animation: fadeUp 0.5s 0.16s ease both;
}

.hero-updated {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.55);
  animation: fadeUp 0.5s 0.22s ease both;
}

/* ── META BAR (between hero and filter panel) ───────── */

.meta-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 14px;
  margin-left: 0;
}

.meta-updated {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.03em;
}

/* ── LAYOUT ─────────────────────────────────────────── */
main { padding: 32px 0 64px; }

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── FILTER PANEL ───────────────────────────────────── */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.5s 0.08s ease both;
}

/* Search field */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field svg {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: 12px 42px 12px 44px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-field input::placeholder { color: var(--text-muted); }

.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,26,46,0.08);
}

.clear-search {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.clear-search:hover { color: var(--text-primary); background: rgba(0,0,0,0.06); }
.clear-search.visible { display: flex; }

/* Selects row */
.filter-selects {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-selects select {
  flex: 1;
  min-width: 148px;
  padding: 10px 34px 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231a1a2e' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--transition);
}

.filter-selects select:focus { border-color: var(--accent); }

/* Active/selected filter — light highlight so user can see a filter is applied */
.filter-selects select.is-active {
  border-color: var(--accent);
  background-color: rgba(26, 26, 46, 0.06);
  box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.10);
  font-weight: 600;
}

.filter-selects select option { background: #ffffff; color: var(--text-primary); }

/* Disabled/greyed-out filter */
.filter-selects select:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background-color: var(--surface-2);
}

/* Reset / black button */
.btn-reset {
  padding: 10px 22px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.btn-reset:hover {
  background: #2d2d4a;
  border-color: #2d2d4a;
  transform: translateY(-1px);
}

/* ── RESULTS BAR ────────────────────────────────────── */
.results-bar {
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0 4px;
}

/* ── TABLE WRAPPER ──────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.5s 0.34s ease both;
}

/* ── STATE CONTAINER ────────────────────────────────── */
.state-container {
  padding: 80px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-wrap,
.empty-wrap,
.error-wrap,
.choose-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(26,26,46,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.state-container p {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
}

.state-container span {
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 360px;
  line-height: 1.6;
}

.state-icon { font-size: 2.6rem; line-height: 1; margin-bottom: 2px; }

/* ── TABLE ──────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }

thead {
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 13px 16px;
  text-align: left;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  animation: rowIn 0.28s ease both;
  animation-delay: calc(var(--row-index, 0) * 14ms);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

td {
  padding: 13px 16px;
  font-size: 0.9rem;
  color: var(--text-primary);
  vertical-align: middle;
}

/* BIB badge */
.bib-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 4px 10px;
  background: rgba(154,111,0,0.08);
  border: 1px solid rgba(154,111,0,0.22);
  border-radius: 6px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}

/* Gender badge */
.gender-badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: capitalize;
}

.gender-male   { background: rgba(26,95,180,0.08);  color: var(--male);   border: 1px solid rgba(26,95,180,0.2);   }
.gender-female { background: rgba(192,28,40,0.08);  color: var(--female); border: 1px solid rgba(192,28,40,0.2); }
.gender-mixed  { background: rgba(192,88,0,0.08);   color: var(--mixed);  border: 1px solid rgba(192,88,0,0.2);  }

/* Race cell */
.race-cell {
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
}

/* Athlete name — bold */
.name-cell {
  font-weight: 700;
}

/* Nationality cell — flag image only, no text */
.nat-cell {
  padding: 8px 16px;
}

.flag-img {
  display: block;
  width: 28px;
  height: 18px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Clickable rows */
tbody tr.clickable-row { cursor: pointer; }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 720px;
  /* 16:9 aspect ratio */
  aspect-ratio: 16 / 9;
  overflow: auto;
  padding: 36px 40px 32px;
  box-sizing: border-box;
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

.modal-close {
  position: absolute;
  top: 16px; right: 20px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* Modal header row: flag + name + bib */
.modal-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
}
.modal-flag-wrap .flag-img {
  height: 56px;
  width: auto;
  border-radius: 4px;
  object-fit: contain;
}
.modal-name {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

/* BIB row in modal: "BIB" label + badge */
.modal-bib {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-bib-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Chips row */
.modal-chips {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
/* Details list — single column, stacked */
.modal-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-detail-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.modal-detail-value {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── PAGINATION ─────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px 0 4px;
  animation: fadeUp 0.3s ease both;
}

#pageInfo {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 110px;
  text-align: center;
}

.page-btn {
  padding: 8px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.page-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── FOOTER ─────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 26px 24px;
  text-align: center;
  background: var(--surface-2);
}

footer p {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── ANIMATIONS ─────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ── RESPONSIVE ─────────────────────────────────────── */

/* ---- desktop only: reduced hero height ---- */
@media (min-width: 901px) {
  .hero { height: 400px; }
}

/* ---- tablet ---- */
@media (max-width: 900px) {
  .hero { height: 260px; }
  .hero-content { padding-top: 36px; }
  .hero-logos { gap: 28px; margin-bottom: 20px; }
  .logo { max-height: 52px; max-width: 130px; }
  main { padding: 28px 0 48px; }
}

/* ---- large phone ---- */
@media (max-width: 700px) {
  .hero { height: 190px; }
  .hero-content { padding: 28px 16px 16px; padding-top: 32px; }
  .hero-logos { gap: 20px; margin-bottom: 14px; }
  .logo { max-height: 44px; max-width: 100px; }
  .hero h1 { white-space: normal; font-size: clamp(1rem, 5vw, 1.6rem); margin-bottom: 8px; }
  .hero-subtitle { font-size: 0.72rem; letter-spacing: 0.1em; }

  main { padding: 20px 0 40px; }
  .container { padding: 0 12px; }

  /* Filters: stack vertically, full-width */
  .filter-panel { padding: 12px; gap: 10px; }
  .filter-selects {
    flex-direction: column;
    gap: 8px;
  }
  .filter-selects select,
  .btn-reset {
    width: 100%;
    min-width: unset;
    padding: 12px 36px 12px 13px;
    font-size: 1rem; /* larger tap target */
  }
  .search-field input { font-size: 1rem; padding: 13px 42px 13px 44px; }

  /* Table: compact cells */
  th { padding: 10px 10px; font-size: 0.6rem; }
  td { padding: 10px 10px; font-size: 0.82rem; }
  .bib-badge { min-width: 36px; padding: 3px 7px; font-size: 0.76rem; }

  /* Pagination */
  .page-btn { padding: 10px 16px; font-size: 0.9rem; }
  #pageInfo { font-size: 0.78rem; }
}

/* ---- small phone ---- */
@media (max-width: 480px) {
  .hero { height: 170px; }
  .hero-content { padding-top: 24px; }
  .hero-logos { gap: 14px; }
  .logo { max-height: 44px; max-width: 90px; }
  .hero h1 { font-size: clamp(0.9rem, 4.5vw, 1.3rem); }

  th { padding: 8px 8px; }
  td { padding: 9px 8px; font-size: 0.8rem; }
  .name-cell { font-weight: 700; }
}

/* ---- modal on phones ---- */
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-box {
    aspect-ratio: unset;
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 32px;
    overflow-y: auto;
  }
  .modal-name { font-size: 1.4rem; }
  .modal-close { top: 12px; right: 14px; font-size: 1.8rem; min-width: 44px; min-height: 44px; }
}



