/* HYPER RED — roster
   Styled after a WEC timing screen / pit-wall roster: dense rows, clear
   column alignment, and class sections that read instantly rather than
   a stack of individual driver cards. */

.roster-head {
  position: relative;
  z-index: 0;
  overflow: hidden;
  margin-bottom: var(--sp-5);
}

.roster-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--hr-line);
}

.roster-week-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
}

.roster-week-nav-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.roster-week-nav-btn:hover { background: var(--bg-3); color: var(--text-primary); }

.roster-week-label-wrap {
  padding: 0 10px;
  text-align: center;
  min-width: 150px;
}

.roster-week-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.roster-week-range {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.roster-toolbar-spacer { flex: 1; }

.roster-search {
  position: relative;
  min-width: 160px;
  flex: 1 1 180px;
  max-width: 240px;
}

.roster-search input {
  width: 100%;
  height: 38px;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  padding: 0 12px 0 34px;
  transition: border-color var(--dur-fast);
}

.roster-search input:focus {
  border-color: var(--hr-red);
  outline: none;
}

.roster-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.roster-select {
  height: 38px;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  padding: 0 30px 0 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23848489' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.roster-tool-btn {
  height: 38px;
  padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}

.roster-tool-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.roster-tool-btn svg { width: 14px; height: 14px; }

.roster-section-spaced { margin-top: var(--sp-4); }
.footer-motion-toggle { justify-content: center; margin-top: 10px; }

.roster-summary-line {
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: var(--sp-3);
}

/* ---- Class distribution ----
   A thin proportional bar plus a compact count legend, both driven by
   plain flex-grow ratios rather than a charting library. Segment widths
   are set via JS (element.style.flexGrow, not inline markup — see
   roster.js renderRosterDistribution() for why), colors come from the
   same --class-* tokens used everywhere else in the app. */
.roster-distribution {
  margin-top: var(--sp-4);
}

.roster-distribution-bar {
  display: flex;
  height: 5px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--bg-2);
  gap: 2px;
}

.roster-distribution-seg { min-width: 3px; }
.roster-distribution-seg[data-class="Hypercar"] { background: var(--class-hypercar); }
.roster-distribution-seg[data-class="WEC LMP2"] { background: var(--class-wec-lmp2); }
.roster-distribution-seg[data-class="ELMS LMP2"] { background: var(--class-elms-lmp2); }
.roster-distribution-seg[data-class="LMP3"] { background: var(--class-lmp3); }
.roster-distribution-seg[data-class="LMGT3"] { background: var(--class-lmgt3); }

.roster-distribution-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: 9px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

.roster-distribution-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.roster-distribution-legend-item::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
}
.roster-distribution-legend-item[data-class="Hypercar"]::before { background: var(--class-hypercar); }
.roster-distribution-legend-item[data-class="WEC LMP2"]::before { background: var(--class-wec-lmp2); }
.roster-distribution-legend-item[data-class="ELMS LMP2"]::before { background: var(--class-elms-lmp2); }
.roster-distribution-legend-item[data-class="LMP3"]::before { background: var(--class-lmp3); }
.roster-distribution-legend-item[data-class="LMGT3"]::before { background: var(--class-lmgt3); }
.roster-distribution-legend-item b {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ---- Column legend ----
   A static header row describing the driver-row layout below. Purely
   presentational (aria-hidden — the data itself is still linear reading
   order per row), and its flex sizing must stay in lockstep with
   .driver-row's. Hidden below the breakpoint where driver rows collapse
   to a stacked layout. */
.roster-columns-legend {
  display: none;
}

@media (min-width: 760px) {
  .roster-columns-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 8px;
    font-family: var(--font-display);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-faint);
    border-bottom: 1px solid var(--hr-line);
    margin-bottom: 4px;
  }
  .roster-columns-legend > span:nth-child(1) { flex: 0 0 26px; }
  .roster-columns-legend > span:nth-child(2) { flex: 0 0 28px; }
  .roster-columns-legend > span:nth-child(3) { flex: 1 1 0; min-width: 0; }
  .roster-columns-legend > span:nth-child(4) { flex: 0 0 170px; }
  .roster-columns-legend > span:nth-child(5) { flex: 0 0 96px; text-align: right; }
}

/* ---- Grouped roster ---- */
#rosterContainer { counter-reset: hr-class-section; }

.class-section {
  margin-bottom: var(--sp-5);
  counter-increment: hr-class-section;
}

.class-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border-strong);
  margin-bottom: 4px;
}

.class-header::before {
  content: counter(hr-class-section, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.class-header-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* A short color tick ahead of the class name — the class-color system
   used consistently across Signup/Roster/Calendar, applied here as a
   1px-wide accent rather than another colored badge. */
.class-header {
  box-shadow: inset 2px 0 0 var(--border-subtle);
}
.class-header[data-class="Hypercar"] { box-shadow: inset 2px 0 0 var(--class-hypercar); }
.class-header[data-class="WEC LMP2"] { box-shadow: inset 2px 0 0 var(--class-wec-lmp2); }
.class-header[data-class="ELMS LMP2"] { box-shadow: inset 2px 0 0 var(--class-elms-lmp2); }
.class-header[data-class="LMP3"] { box-shadow: inset 2px 0 0 var(--class-lmp3); }
.class-header[data-class="LMGT3"] { box-shadow: inset 2px 0 0 var(--class-lmgt3); }
.class-header[data-class="Hypercar"] .class-header-title { color: var(--class-hypercar); }
.class-header[data-class="WEC LMP2"] .class-header-title { color: var(--class-wec-lmp2); }
.class-header[data-class="ELMS LMP2"] .class-header-title { color: var(--class-elms-lmp2); }
.class-header[data-class="LMP3"] .class-header-title { color: var(--class-lmp3); }
.class-header[data-class="LMGT3"] .class-header-title { color: var(--class-lmgt3); }

.class-count {
  margin-left: auto;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-weight: 600;
}

.slot-group {
  margin: 7px 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.008);
}

.slot-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--hr-grid-line);
  font-size: 11.5px;
  color: var(--text-muted);
}

.slot-group-label {
  font-family: var(--font-display);
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.slot-group-count {
  flex-shrink: 0;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Dense driver row: delete-affordance / driver / discord / session,
   aligned to .roster-columns-legend above. Plain flexbox on purpose —
   the driver name gets flex:1 (all remaining space after the two fixed-
   width columns), so there's no proportional fr/minmax distribution
   left for anything to get wrong. This is the same layout as the legend
   above and the two must be kept in sync. */
.driver-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--hr-grid-line);
  transition: background var(--dur-fast);
  animation: rosterRowIn 220ms var(--ease-standard) both;
}

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

.class-section .slot-group:last-child .driver-row:last-child,
.class-section > .driver-row:last-child {
  border-bottom: none;
}

.driver-row:hover { background: var(--bg-2); }

.driver-row-mine {
  background: rgba(227, 35, 43, 0.06);
  box-shadow: inset 2px 0 0 var(--hr-red);
}

.driver-col { min-width: 0; }
.driver-col-name { flex: 1 1 0; min-width: 0; }

.driver-col-pos {
  flex: 0 0 26px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.delete-entry-btn {
  display: none;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.delete-entry-btn.visible { display: flex; }
.delete-entry-btn:hover { color: var(--status-error); border-color: var(--status-error); }

.driver-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 6px;
  width: 100%;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.driver-name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
}

.driver-you-tag {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hr-red-bright);
  border: 1px solid var(--border-red);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  flex-shrink: 0;
}

/* Discord/Steam moved to private data (Section 3) — this single CONTACT
   column now holds either an admin's already-loaded contact detail, a
   "Show contact" disclosure button on the driver's own row, or an em
   dash for anyone else's row. Kept as one column (not two) since it's
   usually empty/collapsed rather than always showing two values. */
.driver-col-contact {
  flex: 0 1 170px;
  min-width: 90px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.driver-col-contact-private { color: var(--text-faint); }
.driver-contact-discord { font-family: var(--font-mono); }
.driver-contact-steam { color: var(--text-faint); }
.driver-contact-reveal {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-body);
  padding: 3px 8px;
  cursor: pointer;
}
.driver-contact-reveal:hover { color: var(--text-primary); border-color: var(--border-strong); }
.driver-contact-reveal:disabled { cursor: default; opacity: 0.6; }

.driver-col-time {
  flex: 0 0 96px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  text-align: right;
}

/* ---- Admin panel embedded in roster ---- */
.admin-panel {
  margin-top: var(--sp-6);
  border-top: 1px dashed var(--border-strong);
  padding-top: var(--sp-5);
}

.admin-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--sp-4);
}

.admin-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.admin-action-row.danger {
  border-color: rgba(255, 90, 95, 0.35);
  background: rgba(255, 90, 95, 0.06);
}

.admin-action-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-action-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Below 760px: stack each field onto its own full-width line ----
   Below this width there isn't room for name + discord + session to
   share a row comfortably, so each becomes its own line instead: name
   on top (full width, next to the delete button), discord below it,
   session below that. */
@media (max-width: 759px) {
  .driver-row {
    flex-wrap: wrap;
    row-gap: 3px;
    padding: 10px 8px;
  }
  .driver-col-pos { order: 0; flex: 0 0 22px; }
  .driver-col-name { order: 1; flex: 1 1 auto; }
  .delete-entry-btn { order: 2; }
  .driver-col-contact { order: 3; flex: 1 1 100%; }
  .driver-col-time { order: 4; flex: 1 1 100%; text-align: left; }
}

/* Self-service shortcut shown only on rows Driver Control has positively
   identified as the current driver's entry. */
.driver-entry-edit {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--hr-red-bright);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.driver-entry-edit:hover { text-decoration: underline; }
.driver-entry-edit:focus-visible { outline: 2px solid var(--hr-red); outline-offset: 2px; }
