/* Page-specific styles. Shared primitives live in site.css. */

/* Home */
.home-hero h1 { max-width: 26ch; }
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--space-6);
  align-items: start;
}
.home-grid > section { min-width: 0; }
.now-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
}
.now-card h3 { margin: 8px 0 4px; font-size: 20px; line-height: 1.25; }
.now-card .now-side { display: flex; align-items: center; gap: var(--space-4); }
.now-card .stat-value { font-size: 26px; }
.now-card .now-more { color: var(--blue-dark); font-weight: 700; white-space: nowrap; }
.now-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.session-list { display: grid; gap: 8px; }
.session-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.session-row-main { display: grid; flex: 1 1 220px; gap: 2px; min-width: 0; }
.session-row-title { font-weight: 700; overflow-wrap: anywhere; }
.session-row-meta { color: var(--muted); font-size: 13px; }
.session-row .badge { margin-left: auto; }
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}
.news-card .cover { display: block; overflow: hidden; }
.news-card h2 { margin: 0 0 6px; font-size: 17px; line-height: 1.25; }
.news-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Filters */
.filter-bar {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-bar.filters { margin-bottom: var(--space-5); }
.filter-bar .field { flex: 0 1 260px; max-width: 320px; }
.filter-bar .field.grow { flex: 1 1 240px; max-width: none; }
.pager { margin-top: var(--space-4); }

/* Calendar */
.calendar-now { margin-bottom: var(--space-5); }
.calendar-month { margin-bottom: var(--space-6); }
.calendar-month h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stage-card { margin-bottom: var(--space-3); overflow: hidden; }
.stage-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 14px 18px;
  list-style: none;
  cursor: pointer;
}
.stage-card-head::-webkit-details-marker { display: none; }
.stage-card-head::after {
  content: "\25BE";
  color: var(--muted);
  font-size: 12px;
}
.stage-card[open] > .stage-card-head::after { content: "\25B4"; }
.stage-flag { display: inline-flex; align-items: center; gap: 6px; }
.stage-name { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.stage-name a { color: var(--text); }
.stage-meta, .stage-count { color: var(--muted); font-size: 13px; }
.stage-count { white-space: nowrap; }
.stage-card-head .badge { margin-left: auto; }
.stage-card.is-past { opacity: 0.8; }
.stage-card.is-past .stage-name a { color: var(--muted); }
.stage-races { border-top: 1px solid var(--line); }
.calendar-race {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.calendar-race:last-child { border-bottom: 0; }
.calendar-race:hover { background: var(--surface-2); text-decoration: none; }
.calendar-race-date {
  display: inline-flex;
  flex-direction: column;
  min-width: 92px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.calendar-race-time { color: var(--muted); font-size: 13px; font-weight: 600; }
.calendar-race-main { display: grid; flex: 1 1 220px; gap: 2px; min-width: 0; }
.calendar-race-title { font-weight: 600; overflow-wrap: anywhere; }
.calendar-race-winner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}
.calendar-race .badge { margin-left: auto; }
.calendar-stage-empty {
  margin: 0;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 14px;
}
.calendar-retry { margin-top: var(--space-3); }
.skeleton-card { margin-bottom: var(--space-3); padding: 16px 18px; }
.skeleton-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ice) 25%, var(--surface-2) 37%, var(--ice) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}
.skeleton-line + .skeleton-line { margin-top: 10px; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w25 { width: 25%; }
@keyframes skeleton {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

/* Race header */
.race-head { align-items: flex-start; }
.race-head-main { min-width: 0; }
.race-head .eyebrow a { color: inherit; }
.race-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}
.race-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.race-code { display: inline-flex; align-items: center; gap: 6px; }
.race-state { padding-top: 4px; }
.race-head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* Live */
.live-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 var(--space-4);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.live-note[hidden] { display: none; }
.live-note.is-error { border-color: var(--live); background: var(--live-bg); color: #b31f1f; }
.live-note .live-updated { margin-left: auto; font-variant-numeric: tabular-nums; }
.live-note.is-error .live-updated { color: #b31f1f; }

/* Race page v2 */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: 13px;
}
.crumbs a { color: var(--blue-dark); font-weight: 600; }
.crumbs .sep { color: var(--line); }
.tabs[hidden] { display: none; }
.race-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}
.race-signup-state { color: var(--muted); font-size: 13px; }
.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: var(--space-3);
}
.empty-actions { margin: 0 0 var(--space-5); }
.session-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: var(--space-4);
}
.session-cta-main { display: grid; gap: 2px; min-width: 0; }
.session-cta-main a { color: var(--text); }
.session-cta-main .badge { justify-self: start; margin-top: 4px; }
table.data tbody .startlist-session th {
  background: var(--ice);
  color: var(--blue-dark);
  font-size: 12px;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
}
.tabs button.is-highlight { animation: race-tab-flash 1.2s ease; }
@keyframes race-tab-flash {
  0%, 100% { background: transparent; }
  35% { background: var(--ice); }
}
@media (min-width: 1000px) {
  #tab-results .table-wrap { overflow-x: auto; }
}

/* Sortable table headers */
.th-sort {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
}
.th-sort::after { content: " \2195"; opacity: 0.55; font-size: 10px; }
th[aria-sort="ascending"] .th-sort::after { content: " \2191"; opacity: 1; }
th[aria-sort="descending"] .th-sort::after { content: " \2193"; opacity: 1; }
table.data th.sticky-col { position: sticky; left: 0; z-index: 2; background: var(--navy); color: #fff; }
table.data .sticky-col-2 { left: 68px; }
.standings-table, .matrix-table { min-width: 900px; }
.standings-table .name, .matrix-table .name { min-width: 190px; }
.row-toggle {
  width: 20px;
  height: 20px;
  margin-right: 6px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
}
.row-toggle[aria-expanded="true"] { background: var(--ice); }
.race-detail { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 4px 0; }
.race-detail span { font-size: 13px; }
.standings-close { display: block; margin: 0 0 10px auto; }
#standings-panel.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow: auto;
  padding: 20px;
  background: var(--bg);
}
#standings-panel.is-fullscreen .table-wrap { max-height: calc(100vh - 84px); }
body.has-fullscreen { overflow: hidden; }
@media (max-width: 760px) {
  #standings-panel.is-fullscreen { padding: 10px; }
}

/* Expandable relay rows */
.detail-toggle {
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}
.detail-toggle::after { content: " \25BE"; font-size: 10px; }
.detail-toggle[aria-expanded="true"]::after { content: " \25B4"; }
.row-detail td { padding-top: 10px; padding-bottom: 10px; }
.row-detail[hidden] { display: none; }
.legs-wrap { margin: 0; }
.legs-table { font-size: 13px; }
.leg-list { display: grid; gap: 4px; }
.leg-list span { display: flex; flex-wrap: wrap; gap: 8px; }

/* Splits and course: one table per block, no decorative cards. */
.table-splits, .table-course { min-width: 760px; }
.table-splits th, .table-course th { white-space: nowrap; }
.table-course td.num { font-variant-numeric: tabular-nums; }
.table-splits .muted { color: var(--muted); }

/* Athlete / team profiles */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.stat-grid .stat { padding: 14px 16px; }
.stat-grid .stat-value { font-size: 24px; }
.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: var(--space-4);
  align-items: start;
}
.profile-grid > section { min-width: 0; }
/* Колонки карточек: внутри каждой карточки идут без дырок, высоты не растягиваются. */
.profile-col { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.info-card h2, .form-card h2 { margin: 0 0 var(--space-4); font-size: 18px; }
/* Скин: 3D-просмотр и форма */
.skin-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.skin-card-head h2 { margin: 0; font-size: 18px; }
.skin-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.skin-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--silver); }
.skin-status.is-loaded { color: var(--green); background: var(--green-bg); border-color: transparent; }
.skin-status.is-loaded .skin-status-dot { background: var(--green); }
.skin-status.is-preview { color: var(--yellow); background: #fbf6e8; border-color: transparent; }
.skin-status.is-preview .skin-status-dot { background: var(--gold); }
.skin-layout {
  display: grid;
  grid-template-columns: minmax(200px, 0.9fr) minmax(0, 1.1fr);
  gap: var(--space-5);
  align-items: start;
}
.skin-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 350px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: radial-gradient(circle at 50% 32%, #ffffff 0%, #eef7fc 48%, #dcebf4 100%);
}
.skin-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: 120px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(8, 35, 58, 0.18), transparent 70%);
  pointer-events: none;
}
.skin-stage:has(.skin-empty:not([hidden]))::after,
.skin-stage:has(.skin-fallback-note:not([hidden]))::after { opacity: 0; }
.skin-viewer {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  outline: none;
}
.skin-viewer[hidden] { display: none; }
.skin-viewer:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: var(--radius-sm); }
.skin-head {
  position: relative;
  z-index: 1;
  display: block;
  width: 96px;
  height: 96px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  image-rendering: pixelated;
}
.skin-head[hidden] { display: none; }
.skin-empty {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: var(--space-4);
  text-align: center;
}
.skin-empty > * { max-width: 100%; overflow-wrap: anywhere; }
.skin-empty[hidden] { display: none; }
.skin-empty-icon { color: var(--muted); opacity: 0.7; }
.skin-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(247, 250, 252, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.skin-loading[hidden] { display: none; }
.skin-fallback-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  z-index: 2;
  margin: 0;
  text-align: center;
}
.skin-fallback-note[hidden] { display: none; }
.skin-form .field { gap: 6px; }
.skin-file-meta { margin: 0; color: var(--muted); font-size: 12px; }
.skin-file-meta[hidden] { display: none; }
.file-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px dashed #9fb2c0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.file-picker:hover { border-color: var(--blue); background: var(--ice); }
.file-picker.has-file { border-style: solid; border-color: var(--line); background: var(--surface); }
.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-picker.has-file .file-name { color: var(--text); font-weight: 600; }
#skin-file:focus-visible + .file-picker { outline: 2px solid var(--blue); outline-offset: 2px; }
.member-role { margin-left: 6px; }
.field-error { margin: 0; }
.field-error:empty { min-height: 0; }

/* Auth */
.auth-wrap { max-width: 560px; }
.auth-card h1 { margin: 0 0 6px; font-size: 26px; }
.auth-card .form { margin-top: var(--space-5); }
.auth-alt { margin: var(--space-4) 0 0; color: var(--muted); font-size: 14px; }

/* Article */
.article { max-width: 80ch; padding: var(--space-6); }
.article h1 { margin: 0 0 8px; font-size: clamp(24px, 3.4vw, 36px); line-height: 1.15; }
.article-meta { margin: 0 0 var(--space-5); color: var(--muted); font-size: 13px; }
.article-cover { margin: 0 0 var(--space-5); border-radius: var(--radius); overflow: hidden; }
.article-cover img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.article-body p { margin: 0 0 14px; }
.article-body p:last-child { margin-bottom: 0; }

/* 404 */
.notfound {
  max-width: 640px;
  margin: var(--space-10) auto;
  padding: var(--space-10);
  text-align: center;
}
.notfound h1 { margin: 0 0 10px; font-size: clamp(28px, 5vw, 42px); }
.notfound p { margin: 0 0 var(--space-6); }
.notfound .eyebrow { color: var(--blue); }

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .profile-grid { display: flex; flex-direction: column; align-items: stretch; }
  .profile-col { display: contents; }
  .news-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .skin-layout { grid-template-columns: 1fr; }
  .skin-stage { height: 300px; }
  .skin-card-head { flex-wrap: wrap; }
  .filter-bar .field,
  .filter-bar .field.grow { flex: 1 1 100%; max-width: none; }
  .news-grid { grid-template-columns: 1fr; }
  .now-card { align-items: flex-start; }
  .live-note { gap: 6px; }
  .live-note .live-updated { margin-left: 0; }
  .article { padding: var(--space-4); }
  .notfound { padding: var(--space-6); margin: var(--space-6) auto; }
  .stage-card-head { padding: 12px 14px; }
  .stage-card-head .badge { margin-left: 0; }
  .calendar-race { padding: 10px 14px; }
  .calendar-race-date {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    min-width: 100%;
    font-size: 16px;
  }
  .calendar-race-time { font-size: 14px; }
  .calendar-race-winner { flex: 1 1 100%; }
  .calendar-race .badge { margin-left: 0; }
  .calendar-stage-empty { padding: 12px 14px; }
  .race-head-side { width: 100%; align-items: flex-start; }
  .race-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    text-align: left;
  }
  .race-meta { gap: 4px 12px; }
  .results-toolbar { align-items: flex-start; }
  .session-cta { align-items: flex-start; }
}


/* Race intermediates */
.intermediates-group { margin-bottom: var(--space-5); }
.intermediates-group:last-child { margin-bottom: 0; }
.intermediates-picker { max-width: 320px; margin-bottom: var(--space-4); }
.intermediates-title { margin: 0 0 var(--space-2); font-size: 15px; font-weight: 700; }
.table-intermediates { min-width: 640px; }

/* Numeric headers and full-width sort buttons */
table.data th.num, table.data td.num { text-align: right; }
.th-sort { width: 100%; text-align: inherit; }
