/*
 * RACE_PROFILER_003B — section visual and responsive refinement.
 *
 * Scope is limited to the manual Race Profiler workspace. It restores a
 * restrained section identity, corrects the Race Conditions lower grid, and
 * makes Define Race Setup contract cleanly at reduced desktop widths.
 */

body[data-workspace-mode="race_profiler"]{
  --rp-section-border:rgba(44,111,214,.32);
  --rp-section-border-strong:rgba(35,126,211,.44);
  --rp-section-head-a:rgba(222,245,255,.97);
  --rp-section-head-b:rgba(232,236,255,.96);
  --rp-section-head-c:rgba(222,251,246,.94);
}

/* Give each major section a clear but restrained Premium Glass boundary. */
body[data-workspace-mode="race_profiler"] #page-builder > .section{
  border-color:var(--rp-section-border)!important;
  box-shadow:
    0 15px 36px rgba(17,44,91,.075),
    0 0 0 1px rgba(255,255,255,.58) inset,
    inset 0 1px 0 rgba(255,255,255,.88)!important;
}
body[data-workspace-mode="race_profiler"] #page-builder > .section:hover{
  border-color:var(--rp-section-border-strong)!important;
}
body[data-workspace-mode="race_profiler"] #page-builder > .section > .section-header{
  border-bottom-color:rgba(42,105,207,.20)!important;
  background:
    radial-gradient(circle at 96% 0%,rgba(45,212,191,.16),transparent 34%),
    linear-gradient(108deg,var(--rp-section-head-a),var(--rp-section-head-b) 58%,var(--rp-section-head-c))!important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.92),
    inset 0 -1px 0 rgba(67,111,202,.06)!important;
}
body[data-workspace-mode="race_profiler"] #page-builder > .section > .section-header::after{
  content:""!important;
  position:absolute!important;
  inset:0 18px auto!important;
  height:1px!important;
  pointer-events:none!important;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.96),rgba(75,148,232,.34),transparent)!important;
}
body[data-workspace-mode="race_profiler"] .profiler-optional-section.profiler-collapsed{
  border-color:var(--rp-section-border)!important;
}

/* Race Conditions: condition flags and jockey restriction occupy the top row. */
body[data-workspace-mode="race_profiler"] #race-conditions .grid.race-top{
  grid-template-columns:minmax(0,1.58fr) minmax(235px,.42fr)!important;
  align-items:stretch!important;
}

/* Field-size row: runner range plus equal Rating and Fences cards. */
body[data-workspace-mode="race_profiler"] #race-conditions .grid.lower-two{
  display:grid!important;
  grid-template-columns:minmax(520px,1.72fr) repeat(2,minmax(185px,.42fr))!important;
  align-items:stretch!important;
  gap:9px!important;
}
body[data-workspace-mode="race_profiler"] #race-conditions .grid.lower-two > *{
  min-width:0!important;
}
body[data-workspace-mode="race_profiler"] #race-conditions #race_profiler_official_rating_slot,
body[data-workspace-mode="race_profiler"] #race-conditions #num_fences_card{
  align-self:stretch!important;
  min-height:0!important;
}
body[data-workspace-mode="race_profiler"] #race-conditions #race_profiler_official_rating_slot .race-conditions-rating-card,
body[data-workspace-mode="race_profiler"] #race-conditions #num_fences_card{
  height:100%!important;
  min-height:126px!important;
  padding:10px!important;
  display:flex!important;
  flex-direction:column!important;
  align-items:center!important;
  justify-content:center!important;
}
body[data-workspace-mode="race_profiler"] #race-conditions #race_profiler_official_rating_slot .race-profiler-mini-note,
body[data-workspace-mode="race_profiler"] #race-conditions #num_fences_card .note{
  max-width:230px!important;
  margin:5px auto 8px!important;
  font-size:8.25px!important;
  line-height:1.25!important;
  text-align:center!important;
}
body[data-workspace-mode="race_profiler"] #race-conditions #race_profiler_official_rating_slot .race-profiler-official-rating-inputs{
  width:min(100%,190px)!important;
  margin:0 auto!important;
}
body[data-workspace-mode="race_profiler"] #race-conditions #num_fences_card .inline-inputs{
  width:min(100%,190px)!important;
  margin-left:auto!important;
  margin-right:auto!important;
}

/* Define Race Setup: remove single-line pressure from Class 1 subtypes. */
body[data-workspace-mode="race_profiler"] #race #group_grade_listed_card .chips.single-line{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  align-items:stretch!important;
  gap:7px!important;
  width:100%!important;
}
body[data-workspace-mode="race_profiler"] #race #group_grade_listed_card .chips.single-line .chip{
  min-width:0!important;
  width:100%!important;
  padding-left:7px!important;
  padding-right:7px!important;
  white-space:normal!important;
  overflow-wrap:anywhere!important;
  text-align:center!important;
  line-height:1.16!important;
}
body[data-workspace-mode="race_profiler"] #race .race-meta-row1,
body[data-workspace-mode="race_profiler"] #race .race-meta-ages,
body[data-workspace-mode="race_profiler"] #race .race-meta-class-row{
  min-width:0!important;
}
body[data-workspace-mode="race_profiler"] #race :is(.meta-country,.meta-race-code,.meta-handicap,.meta-age,.meta-class,.meta-class-subtypes){
  min-width:0!important;
}

@media(max-width:1700px){
  body[data-workspace-mode="race_profiler"] #race #group_grade_listed_card .chips.single-line{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  body[data-workspace-mode="race_profiler"] #race-conditions .grid.lower-two{
    grid-template-columns:minmax(0,1.55fr) repeat(2,minmax(175px,.45fr))!important;
  }
}

@media(max-width:1500px){
  body[data-workspace-mode="race_profiler"] #race .race-meta-row1{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  body[data-workspace-mode="race_profiler"] #race .race-meta-row1 .meta-handicap{
    grid-column:1/-1!important;
  }
  body[data-workspace-mode="race_profiler"] #race .race-meta-class-row{
    grid-template-columns:1fr!important;
  }
  body[data-workspace-mode="race_profiler"] #race-conditions .grid.lower-two{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  body[data-workspace-mode="race_profiler"] #race-conditions .runners-hybrid-card{
    grid-column:1/-1!important;
  }
}

@media(max-width:1180px){
  body[data-workspace-mode="race_profiler"] #race .race-meta-row1,
  body[data-workspace-mode="race_profiler"] #race .race-meta-ages,
  body[data-workspace-mode="race_profiler"] #race-conditions .grid.race-top{
    grid-template-columns:1fr!important;
  }
  body[data-workspace-mode="race_profiler"] #race #country_chip_group,
  body[data-workspace-mode="race_profiler"] #race #race_code_group,
  body[data-workspace-mode="race_profiler"] #race .meta-age .chips{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:7px!important;
  }
}

@media(max-width:760px){
  body[data-workspace-mode="race_profiler"] #race #group_grade_listed_card .chips.single-line,
  body[data-workspace-mode="race_profiler"] #race #country_chip_group,
  body[data-workspace-mode="race_profiler"] #race #race_code_group,
  body[data-workspace-mode="race_profiler"] #race .meta-age .chips,
  body[data-workspace-mode="race_profiler"] #race-conditions .grid.lower-two{
    grid-template-columns:1fr!important;
  }
  body[data-workspace-mode="race_profiler"] #race-conditions .runners-hybrid-card{
    grid-column:auto!important;
  }
}
