/* results_core.css — base, header, filters, chips, event card */

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

:root {
  --orange:        #E8631A;
  --orange-dim:    rgba(232,99,26,0.12);
  --orange-border: rgba(232,99,26,0.30);
  --white:         #FFFFFF;
  --off-white:     #F7F5F2;
  --surface2:      #F4F2EF;
  --border:        #E8E4DF;
  --text:          #1A1410;
  --text-mid:      #5C5248;
  --text-soft:     #9B9088;
  --green:         #2A9D5C;
  --green-dim:     rgba(42,157,92,0.12);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --radius:        12px;
  --radius-sm:     8px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; height: 100%; }
body {
  font-family: 'Barlow', sans-serif;
  background: var(--off-white);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sticky-stack {
  background: var(--white);
  box-shadow: 0 1px 0 var(--border);
}

/* ── Stage selector ── */
.stage-selector-wrap {
  padding: 6px 14px 0px;
  display: none; /* shown only in multi-stage mode */
}
.stage-selector {
  display: flex; gap: 5px; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 6px;
}
.stage-selector::-webkit-scrollbar { display: none; }
.stage-selector::before,
.stage-selector::after { content: ''; flex: 1 1 0; min-width: 0; }
.stage-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center;
  height: 28px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px; font-weight: 700;
  padding: 0 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all .15s;
  white-space: nowrap;
}
.stage-pill:active { opacity: .75; }
.stage-pill.active {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
}
.stage-pill.overall {
  border-color: var(--orange-border);
  color: var(--orange);
}
.stage-pill.overall.active {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
}
.stage-pill.live-stage::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: #2A9D5C;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

/* Stage with no results yet — dimmed */
.stage-pill.pill-empty {
  opacity: 0.45;
  font-style: italic;
}
.stage-pill.pill-empty.live-stage {
  opacity: 1; /* live is always visible even without results yet */
}
.stage-pill.pill-empty.active {
  opacity: 1; /* selected pill always full opacity */
}

/* Stage completed (final) — checkmark indicator */
.stage-pill.final-stage:not(.no-results)::before {
  content: '✓';
  font-style: normal;
  font-size: 10px;
  margin-right: 4px;
  opacity: 0.7;
  vertical-align: middle;
}

/* Empty stage placeholder */
.empty-stage-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 52px 24px;
  margin: 24px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-mid);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}
.empty-stage-msg svg { flex-shrink: 0; opacity: 0.65; width: 32px; height: 32px; }
.empty-stage-msg span { max-width: 300px; line-height: 1.5; }

/* Provisional banner shown when live stage has partial overall */
.partial-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  color: #F0B429;
  background: rgba(240,180,41,0.08);
  border-bottom: 1px solid rgba(240,180,41,0.2);
  padding: 6px 12px;
  letter-spacing: 0.02em;
}
.partial-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #F0B429;
  flex-shrink: 0;
  animation: pulse-dot 1.8s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.3} }

/* "Still in Stage N" separator + pending competitor rows */
.pending-divider {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-soft);
  padding: 8px 12px 4px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}
.pending-row {
  opacity: 0.5;
}

/* Constrain all header content to 680px centered */
.sticky-inner {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.results-list-btn {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: .03em;
  color: var(--text-mid); text-decoration: none;
  padding: 4px 9px; border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  transition: border-color .15s, color .15s;
}
.results-list-btn:hover { color: var(--orange); border-color: var(--orange-border); }

.header-logo {
  display: flex; align-items: center; text-decoration: none;
}
.header-logo-img {
  height: 36px; width: auto;
}

.event-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--green-dim);
  border: 1px solid rgba(42,157,92,0.3);
  border-radius: 20px; padding: 5px 10px;
  font-size: 12px; font-weight: 600; color: var(--green); white-space: nowrap;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: pulse 1.8s ease-in-out infinite; flex-shrink: 0;
}
@keyframes pulse {
  0%,100%{opacity:1;transform:scale(1)}50%{opacity:.5;transform:scale(.85)}
}

/* Search */
.search-wrap {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
/* On wider screens, the border spans full width but content is constrained — fine as-is */
.search-box { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-soft); pointer-events: none;
}
.search-input {
  width: 100%; height: 38px;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 0 36px 0 38px;
  font-family: 'Barlow', sans-serif; font-size: 15px; color: var(--text);
  outline: none; transition: border-color .2s, background .2s;
  -webkit-appearance: none;
}
.search-input::placeholder { color: var(--text-soft); }
.search-input:focus { border-color: var(--orange); background: var(--white); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--text-soft); border: none; border-radius: 50%;
  width: 20px; height: 20px; color: white; font-size: 11px;
  cursor: pointer; display: none; align-items: center; justify-content: center;
}
.search-clear.visible { display: flex; }

/* Club filter button in header */
.club-filter-btn {
  display: flex; align-items: center; gap: 5px;
  border: 1.5px solid var(--border); border-radius: 20px;
  padding: 5px 12px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-mid); background: var(--white);
  cursor: pointer; transition: all .18s; white-space: nowrap;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  -webkit-tap-highlight-color: transparent;
}
.club-filter-btn.active { background: var(--orange); border-color: var(--orange); color: white; }
.club-filter-btn svg { flex-shrink: 0; }

/* Club modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--white); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 680px;
  padding: 0 0 calc(16px + env(safe-area-inset-bottom));
  transform: translateY(40px);
  transition: transform .25s cubic-bezier(.34,1.1,.64,1);
  max-height: 75dvh; display: flex; flex-direction: column;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 12px auto 0;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px; font-weight: 800; letter-spacing: 0.03em;
}
.modal-close {
  background: var(--surface2); border: none; border-radius: 50%;
  width: 28px; height: 28px; font-size: 13px; color: var(--text-mid);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-search {
  margin: 10px 16px;
  height: 36px; width: calc(100% - 32px);
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 0 16px;
  font-family: 'Barlow', sans-serif; font-size: 14px; color: var(--text);
  outline: none; transition: border-color .2s;
}
.modal-search:focus { border-color: var(--orange); }
.modal-list {
  overflow-y: auto; padding: 6px 10px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.modal-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 10px; border-radius: 8px;
  cursor: pointer; transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.modal-item:hover { background: var(--surface2); }
.modal-item.active { background: var(--orange-dim); }
.modal-item-name {
  font-size: 15px; font-weight: 500; color: var(--text);
}
.modal-item.active .modal-item-name { color: var(--orange); font-weight: 600; }
.modal-item-count {
  font-size: 12px; color: var(--text-soft);
  background: var(--surface2); border-radius: 10px;
  padding: 2px 8px;
}
.modal-item.active .modal-item-count { background: var(--orange-dim); color: var(--orange); }
.modal-clear {
  margin: 8px 16px 0;
  width: calc(100% - 32px); height: 44px;
  background: none; border: 1.5px solid var(--border);
  border-radius: 8px; font-family: 'Barlow', sans-serif;
  font-size: 13px; font-weight: 600; color: var(--text-mid);
  cursor: pointer; transition: all .18s;
}
.modal-clear:hover { border-color: var(--orange); color: var(--orange); }

/* Club highlight mode */
.competitor-row.club-highlight-match { background: rgba(232,99,26,0.13); border-left: 3px solid var(--orange); }
.col-club-sub.highlight { color: var(--orange); font-weight: 600; }

/* Modal toggle */
.modal-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
  border-bottom: 1px solid var(--border);
}
.modal-toggle-label {
  font-size: 13px; color: var(--text-mid); font-weight: 500;
}
.toggle-switch {
  position: relative; width: 38px; height: 22px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 11px;
  background: var(--border); cursor: pointer; transition: background .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--orange); }
.toggle-track::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* Club subtitle below competitor name */
.col-name-wrap { display: flex; flex-direction: column; gap: 1px; overflow: hidden; align-self: center; justify-content: center; }
.col-club-sub {
  font-size: 11px; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1;
}

/* Gender group pills */
.filter-top-row { display:flex; align-items:center; justify-content:space-between; padding:8px 14px 6px; gap:8px; }
.view-mode-toggle { display:flex; background:var(--surface2); border-radius:20px; padding:3px; gap:2px; }
.view-mode-btn { border:none; border-radius:17px; padding:5px 14px; font-family:'Barlow Condensed',sans-serif; font-size:13px; font-weight:700; cursor:pointer; transition:all .15s; background:none; color:var(--text-mid); -webkit-tap-highlight-color:transparent; }
.view-mode-btn.active { background:var(--white); color:var(--orange); box-shadow:0 1px 4px rgba(0,0,0,0.10); }
.filter-top-row .club-filter-btn { margin:0; }

.gender-row {
  display: flex; gap: 0; padding: 10px 16px 0;
  max-width: 680px; margin: 0 auto; width: 100%;
  overflow: hidden;
  max-height: 60px;
  opacity: 1;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
}
.gender-row.hidden {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0;
}
.gender-btn {
  flex: 1; border: 1.5px solid var(--border); border-right: none;
  padding: 7px 4px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-mid); background: var(--white);
  cursor: pointer; transition: all .18s; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.gender-btn:first-child { border-radius: 8px 0 0 8px; }
.gender-btn:last-child  { border-right: 1.5px solid var(--border); border-radius: 0 8px 8px 0; }
.gender-btn.active { background: var(--orange); border-color: var(--orange); color: white; z-index:1; position:relative; }
.gender-btn:active { opacity: .8; }

/* Class chips */
/* Wrapper handles the fade mask + centering */
.class-chip-wrap {
  position: relative;
}
.class-chip-wrap::before,
.class-chip-wrap::after {
  content: '';
  position: absolute; top: 0; bottom: 0; width: 24px;
  z-index: 2; pointer-events: none;
}
.class-chip-wrap::before {
  left: 0;
  background: linear-gradient(to right, var(--white), transparent);
}
.class-chip-wrap::after {
  right: 0;
  background: linear-gradient(to left, var(--white), transparent);
}
.class-chip-row {
  display: flex; gap: 6px; padding: 8px 16px 10px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  justify-content: center; flex-wrap: nowrap;
}
/* When chips overflow, left-align so scrolling works naturally */
.class-chip-row.overflowing { justify-content: flex-start; }
.class-chip-row::-webkit-scrollbar { display: none; }
.class-chip {
  flex-shrink: 0; border: 1.5px solid var(--border); border-radius: 20px;
  padding: 5px 12px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-mid); background: var(--white);
  cursor: pointer; transition: all .18s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;

}

.class-chip:active { transform: scale(.95); }
.class-chip.active { background: var(--orange); border-color: var(--orange); color: white; }

.class-chip.has-match { border-color: var(--orange-border); color: var(--orange); }



/* ── Jump to top button ── */
.jump-top {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 20px;
  z-index: 90;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--orange);
  border: none;
  color: white;
  box-shadow: 0 4px 16px rgba(232,99,26,0.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s, transform .2s;
}
.jump-top.visible { opacity: 1; pointer-events: all; transform: translateY(0); }
.jump-top:active { transform: scale(.92); }
@media (min-width: 768px) {
  .jump-top              { right: auto; left: 50%; transform: translateX(-50%) translateY(12px); }
  .jump-top.visible      { transform: translateX(-50%) translateY(0); }
  .jump-top:active       { transform: translateX(-50%) scale(.92); }
}

/* ── Class chip count badge ── */
.chip-count {
  font-size: 10px; font-weight: 600;
  opacity: 0.7;
  margin-left: 3px;
}
.class-chip.active .chip-count { opacity: 0.85; }

/* ── Medal icons for top 3 ── */
.medal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 800;
  line-height: 1; flex-shrink: 0;
}
.medal-1 { background: #FFD700; color: #7a5c00; }
.medal-2 { background: #C0C0C0; color: #555; }
.medal-3 { background: #CD7F32; color: #fff; }

/* Plain place numbers get same fixed width as medals so columns align */
.place-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
}

/* ── Progress bar ── */
.stat-progress {
  display: flex; align-items: center; gap: 6px;
  margin-top: 5px;
}
.stat-progress-bar {
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--surface2); overflow: hidden;
  min-width: 40px;
}
.stat-progress-fill {
  height: 100%; border-radius: 2px;
  background: var(--orange);
  transition: width .6s cubic-bezier(.34,1.1,.64,1);
}
.stat-progress-pct {
  font-size: 11px; font-weight: 700;
  color: var(--orange); white-space: nowrap;
}

/* ── Filters block (scrolls with page) ── */
.filters-block {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.filters-inner {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}
/* Override gender-row and club filter padding inside filters block */
.filters-inner .gender-row {
  padding: 8px 16px 0;
  max-width: none;
  margin: 0;
  border-bottom: none;
}
.filters-inner #clubFilterWrap {
  display: flex; align-items: center;
}
/* Class chip wrap sits at bottom of filter block */
.filters-inner .class-chip-wrap {
  padding-bottom: 2px;
}

/* ── Main ── */
.main {
  padding: 14px 16px; max-width: 680px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
  flex: 1; /* pushes footer to bottom */
  width: 100%;
}

/* ── Footer ── */
.footer {
  margin-top: auto;
  padding: 18px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
}
.footer a { color: var(--text-soft); text-decoration: none; }
.footer a:hover { color: var(--text-mid); text-decoration: underline; }
.footer-sep { margin: 0 6px; }

/* Event info */
.event-links {
  padding: 8px 14px 12px;
  display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid var(--border);
}
.event-link-row {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; padding: 4px 0 4px 10px;
  overflow: hidden;
}
.event-link-row:hover .event-link-label { color: var(--orange); }
.event-link-row svg { flex-shrink: 0; color: var(--text-soft); }
.event-link-text { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.event-link-label {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .15s;
}
.event-link-url {
  font-size: 11px; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.livelox-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; padding: 5px 10px;
  overflow: hidden; border-radius: 8px;
  border: 1.5px solid var(--orange-border);
  background: var(--orange-dim);
}
.livelox-link:hover { border-color: var(--orange); }
.livelox-link svg { flex-shrink: 0; color: var(--orange); }

.event-info {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden;
  border-top: 3px solid var(--orange);
}
.event-info-body { padding: 14px 16px; }
.event-header-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.event-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 21px; font-weight: 800; color: var(--text);
  letter-spacing: 0.02em; line-height: 1.1;
}
.organizer-logo {
  height: 52px; width: auto; max-width: 180px; min-width: 40px;
  border-radius: 8px; border: 1px solid var(--border); flex-shrink: 0;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center; padding: 6px 10px;
}
.organizer-logo img { height: 100%; width: auto; max-width: 100%; object-fit: contain; display: block; }
.organizer-logo-placeholder {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px; font-weight: 700; color: var(--text-soft);
  text-align: center; line-height: 1.2; padding: 4px;
}
.event-meta { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.event-meta-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-mid);
}
.event-stats { display: flex; border-top: 1px solid var(--border); }
.stat-pill {
  flex: 1; padding: 10px 6px; text-align: center;
  border-right: 1px solid var(--border);
}
.stat-pill:last-child { border-right: none; }
.stat-number {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px; font-weight: 800; color: var(--orange); line-height: 1;
}
.stat-label {
  font-size: 10px; color: var(--text-soft); margin-top: 2px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
}



/* Search banner */
.search-banner {
  background: var(--orange-dim); border: 1px solid var(--orange-border);
  border-radius: var(--radius-sm); padding: 9px 14px;
  font-size: 13px; color: var(--orange); font-weight: 600; display: none;
}
.search-banner.visible { display: block; }
