/* A single semantic results table becomes a card layout on small screens. */
.results-controls {
  display:flex;
  flex-wrap:wrap;
  gap:.75rem;
  align-items:end
}
.results-controls>div {
  min-width:7rem;
  flex:1
}
.results-controls>.search-control {
  min-width:min(100%,16rem);
  flex:3
}
.results-controls label {
  display:block;
  font-size:.75rem;
  color:#a1a1aa;
  margin-bottom:.4rem
}
.results-input {
  display:block;
  width:100%;
  min-height:2.75rem;
  padding:.65rem .8rem;
  background:#3f3f46;
  color:white;
  border:1px solid #52525b;
  border-radius:.5rem
}
.results-input:focus {
  outline:2px solid white;
  outline-offset:2px
}
.results-button {
  display:inline-block;
  background:#c90015;
  color:white;
  font-weight:600;
  padding:.75rem 1.1rem;
  border-radius:.5rem;
  font-size:.875rem;
  white-space:nowrap
}
.results-button:hover {
  background:#a30012
}
.pagination-link {
  display:inline-flex;
  min-width:2.5rem;
  min-height:2.5rem;
  align-items:center;
  justify-content:center;
  padding:.5rem;
  border:1px solid #3f3f46;
  border-radius:.5rem
}
.race-results td {
  overflow-wrap:anywhere
}
.race-results .mobile-label {
  display:none
}
/* Names are always bold on mobile cards and in print; desktop follows the field's is_bold. */
.print-page .race-results [data-field-key="name"] {
  font-weight:700
}
@media(max-width:1023px) {
  .race-results [data-field-key="name"] {
    font-weight:700
  }
}
/* The race page and /results show beta's loading state instead (below); other HTMX pages fade the control. */
#results-region:not([data-race-id]):not([data-search-region]) .htmx-request {
  opacity:.65
}
[data-loading-overlay][hidden],[data-loading-idle][hidden] {
  display:none
}
[data-results-panel][aria-busy="true"] [data-results-content] {
  opacity:.4;
  pointer-events:none
}
[data-results-fade][aria-busy="true"] {
  opacity:.5
}
.race-picker [hidden] {
  display:none
}
.results-dropdown>summary {
  list-style:none;
  cursor:pointer
}
.results-dropdown>summary::-webkit-details-marker {
  display:none
}
@media(max-width:1023px) {
  .race-results:not(.print-page *) thead {
    position:absolute;
    width:1px;
    height:1px;
    padding:0;
    margin:-1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
    border:0
  }
  .race-results:not(.print-page *),.race-results:not(.print-page *) tbody {
    display:block
  }
  .race-results:not(.print-page *) tr[data-participant-id] {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    padding:.85rem 1rem;
    gap:.65rem 1rem;
    border-left:4px solid #c9001580
  }
  .race-results:not(.print-page *) td {
    display:flex;
    justify-content:space-between;
    gap:1rem;
    grid-column:1/-1;
    padding:0;
    text-align:right
  }
  .race-results:not(.print-page *) .mobile-label {
    display:inline;
    text-align:left;
    font-family:Poppins,sans-serif;
    font-weight:400
  }
  .race-results:not(.print-page *) [data-field-key="placement"] {
    grid-column:1;
    grid-row:1;
    justify-content:start
  }
  .race-results:not(.print-page *) [data-field-key="name"] {
    grid-column:2;
    grid-row:1;
    justify-content:end;
    align-self:start
  }
  .race-results:not(.print-page *) .identity-cell .mobile-label {
    display:none
  }
  .race-results:not(.print-page *) [data-field-key="bib_number"] {
    grid-column:2;
    grid-row:2;
    justify-content:end;
    font-size:.75rem;
    color:#a1a1aa
  }
  .race-results:not(.print-page *) [data-field-key="bib_number"] .mobile-label {
    display:inline
  }
  .race-results:not(.print-page *) .subresults-cell {
    display:block;
    overflow-x:auto
  }
}
.print-page {
  background:white;
  color:#18181b;
  min-height:100vh;
  font:13px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  padding:24px;
  max-width:1100px;
  width:100%;
  margin:auto
}
.print-toolbar {
  display:flex;
  justify-content:space-between;
  padding-bottom:24px
}
.print-toolbar button {
  background:#c90015;
  color:white;
  padding:8px 16px;
  border-radius:5px
}
.print-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:2px solid #18181b;
  padding-bottom:20px;
  margin-bottom:24px;
  gap:16px
}
.print-header h1 {
  font-size:24px;
  font-weight:700
}
.print-header p {
  color:#52525b;
  margin-top:8px
}
.print-race {
  margin:24px 0;
  break-inside:avoid
}
.print-race h2 {
  font-size:18px;
  font-weight:700;
  margin-bottom:12px
}
.print-page .race-results {
  border-collapse:collapse;
  font-size:12px
}
.print-page .race-results thead {
  background:#f4f4f5;
  color:#18181b
}
.print-page .race-results td,.print-page .race-results th {
  padding:7px;
  border-bottom:1px solid #d4d4d8
}
.print-page .race-results tr {
  background:transparent;
  color:#18181b
}
.print-page .mobile-label {
  display:none
}
.print-page summary {
  display:none
}
@media(max-width:600px) {
  .print-page {
    padding:16px
  }
  .print-race {
    overflow-x:auto
  }
}
@media print {
  @page {
    margin:12mm
  }
  body {
    background:white!important;
    color:black!important
  }
  .print-page {
    max-width:none;
    padding:0;
    font-size:10px
  }
  .print-toolbar {
    display:none!important
  }
  .print-header h1 {
    font-size:22px
  }
  .print-race {
    overflow:visible
  }
  .print-page .race-results {
    font-size:9px
  }
  .print-page .race-results td,.print-page .race-results th {
    padding:4px 6px
  }
  .print-page details::details-content {
    display:block
  }
  .print-page .race-results thead {
    display:table-header-group
  }
  .print-page a {
    text-decoration:none;
    color:black
  }
}

.results-table-wrap { overflow-x: auto; max-width: 100%; }
.print-empty { color: #6b7280; padding: 16px 0; text-align: left; }
.print-toolbar a { display: inline-flex; align-items: center; padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.print-toolbar button { background: #111; }
.print-header .print-logo { display: none; }
.print-race h2 { font-size: 16px; border-bottom: 1px solid #d1d5db; padding-bottom: 4px; }
@media print { .print-header .print-logo { display: block; } }

/* The picker panel floats above results; opening it never changes page layout. */
.race-picker summary { list-style: none; }
.race-picker summary::-webkit-details-marker { display: none; }
.race-picker[open] .race-picker-chevron { transform: rotate(180deg); }

/* #639: beta parity for the interactive race table (print keeps its own layout). */
.column-scroll { display: none; }
.subresults-mobile { display: none; }
.subresults-chevron { transition: transform .15s; }
[data-subresults-toggle][aria-expanded="true"] .subresults-chevron { transform: rotate(90deg); }
.subresults-row[hidden], [data-subresults-toggle][hidden] { display: none; }
tr[data-has-subresults] { cursor: pointer; }
@media(min-width:1024px) {
  .column-scroll:not([hidden]) { display: flex; }
  .race-results:not(.print-page *) td { white-space: nowrap; overflow-wrap: normal; }
  .race-results .subresults-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
}
@media(max-width:1023px) {
  tr[data-has-subresults] { cursor: auto; }
  .race-results:not(.print-page *) .subresults-toggle { order: 1; grid-column: 1/-1; display: flex; justify-content: start; margin-top: .25rem; width: auto; padding: 0; text-align: left; }
  .race-results:not(.print-page *) .subresults-toggle:empty, .race-results:not(.print-page *) .subresults-toggle:not(:has(button)) { display: none; }
  .race-results:not(.print-page *) .subresults-chevron { width: .75rem; height: .75rem; }
  /* Beta tints the expanded row only on desktop; on cards the splits sit on the card itself
     (same stripe), directly under its toggle: the card drops its bottom padding while open. */
  .race-results:not(.print-page *) .subresults-row:not([hidden]) { display: block; border-left: 4px solid #c9001580; padding: 0 1rem .75rem; }
  .race-results:not(.print-page *) tr[data-participant-id]:has(+ .subresults-row:not([hidden])) { padding-bottom: 0; }
  .race-results:not(.print-page *) .subresults-row:not([hidden]) > td { display: block; padding: 0; }
  .subresults-desktop { display: none; }
  .subresults-mobile { display: block; }
  /* Rank badge and "Bib #12", as on beta's cards. */
  .race-results:not(.print-page *) [data-field-key="placement"] [data-cell-value] { display: inline-flex; align-items: center; justify-content: center; min-width: 2.25rem; padding: .25rem .375rem; border-radius: .5rem; background: #27272a; color: #a1a1aa; font-size: .875rem; font-weight: 700; }
  .race-results:not(.print-page *) [data-field-key="bib_number"] { gap: .25rem; }
  .race-results:not(.print-page *) [data-field-key="bib_number"] [data-cell-value]::before { content: "#"; font-family: Poppins, sans-serif; }
  /* #674: beta's header is the name with "Bib #N" (text-xs, mono digits) right below it, 8px
     above the result rows, and its list draws no rule above the first card. */
  .race-results:not(.print-page *) tbody tr[data-participant-id]:first-child { border-top-width: 0; }
  .race-results:not(.print-page *) [data-field-key="bib_number"] { line-height: 1rem; margin-top: -.25rem; margin-bottom: .25rem; }
  .race-results:not(.print-page *) [data-field-key="bib_number"] [data-cell-value] { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
  /* Beta's field rows are flex items-center: the text-xs label centres against its value. */
  .race-results:not(.print-page *) td[data-field-key]:not(.identity-cell) { align-items: center; }
  /* #682: beta bolds one card value, its primaryField (first bold card field, else the first);
     other values are regular whatever their is_bold. Desktop and print keep is_bold. */
  .race-results:not(.print-page *) td[data-field-key]:not(.identity-cell, [data-card-primary]) [data-cell-value] { font-weight: 400; }
  .race-results:not(.print-page *) td[data-card-primary] [data-cell-value] { font-weight: 700; }
}
@media(max-width:1023px) {
  /* Beta's cards: tight field rows, bib directly under a single-line (truncated) name. */
  .race-results:not(.print-page *) tr[data-participant-id] { gap: .25rem 1rem; padding: .75rem 1rem; }
  .race-results:not(.print-page *) [data-field-key="placement"] { grid-row: 1 / span 2; align-self: start; margin-bottom: .25rem; }
  .race-results:not(.print-page *) [data-field-key="name"] { min-width: 0; }
  .race-results:not(.print-page *) [data-field-key="name"] [data-cell-value] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* #664: a DNS/DNF/DQ card lists no result fields, only beta's right-aligned status pill. */
  .race-results:not(.print-page *) tr[data-status] td[data-field-key]:not(.identity-cell) { display: none; }
  .race-results:not(.print-page *) [data-status-pill] { justify-content: end; }
  .race-results:not(.print-page *) tr[data-status] [data-field-key="placement"] [data-cell-value] { color: rgb(161 161 170 / .5); }
  /* Beta gives -- ranks a grey accent, continuing through expanded splits. */
  .race-results:not(.print-page *) tr[data-status],
  .race-results:not(.print-page *) tr[data-status] + .subresults-row { border-left-color: #3f3f46; }
}

/* #642: beta's /results tabs and search box (state comes from aria-selected / hidden). */
[data-search-hint][hidden], [data-search-clear][hidden] { display: none; }
.results-tab { border-color: transparent; color: #a1a1aa; }
.results-tab:hover { color: #fff; border-color: #d1d5db; }
.results-tab .results-tab-icon { color: #6b7280; }
.results-tab .results-tab-count { background: #3f3f46; color: #a1a1aa; }
.results-tab[aria-selected="true"], .results-tab[aria-selected="true"]:hover { border-color: #c90015; color: #c90015; }
.results-tab[aria-selected="true"] .results-tab-icon { color: #c90015; }
.results-tab[aria-selected="true"] .results-tab-count { background: rgb(201 0 21 / .1); color: #c90015; }
