/* -------------------------------------------------------
   4. SECTION B: OWNER DEFAULTS (owner-only)
   
   Shown only when passVars.isOwner is true.
   Contains: riding style controls, entry defaults, save btn
   ------------------------------------------------------- */
.horsepage_owner_section {
  background: var(--ehr-surface-bg);
  /* border: 1px solid var(--ehr-border); */
  /* border-radius: var(--hp-radius); */
  /* box-shadow: var(--ehr-table-box-shadow); */
  margin-bottom: var(--hp-gap);
  overflow: hidden;
}

.horsepage_owner_title {
  background: var(--ehr-surface-subtle);
  border-bottom: 1px solid var(--hp-border);
  color: var(--ehr-text-primary);
  font-weight: 700;
  padding: 8px var(--hp-pad);
  text-transform: uppercase;
  min-height: 45px;
  display: flex;
  align-items: center;
}

.horsepage_owner_grid {
  display: flex;
  flex-direction: column;
  gap: var(--hp-gap);
  padding: 8px var(--hp-pad);
}

.horsepage_control_group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start; /* WILLSELECT_20261104 (run list 567, Will): rows fit their contents, not the full width */
}

.horsepage_control_row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.horsepage_control_label {
  min-width: 90px;
  font-weight: 600;
  font-size: 13px;
}

.horsepage_control_input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--ehr-border);
  border-radius: var(--hp-radius-sm);
  font-size: 13px;
  font-family: var(--hp-font);
}

.horsepage_entry_defaults {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.horsepage_entry_title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.horsepage_checkbox_row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.horsepage_checkbox_item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}

.horsepage_checkbox_item input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.horsepage_save_btn {
  padding: 8px 20px;
  background: var(--hp-green);
  color: white;
  border: none;
  border-radius: var(--hp-radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--hp-font);
  transition: background 0.2s;
  align-self: flex-end;
}

.horsepage_save_btn:hover {
  background: var(--hp-green-dark);
}

/* -------------------------------------------------------
   5. SECTION C: PAST PERFORMANCES (public)
   
   Uses <table> with progressive column hiding via 
   horsepage_hide_XXX utility classes. Expand button reveals
   hidden data on small screens.
   ------------------------------------------------------- */
.horsepage_pps_section {
  background: var(--ehr-surface-bg);
  /* border: 1px solid var(--ehr-border); */
  /* border-radius: var(--hp-radius); */
  /* box-shadow: var(--ehr-table-box-shadow); */
  margin-bottom: var(--hp-gap);
  overflow: hidden;        /* NEVER side scroll */
  container-type: inline-size;
}

.horsepage_pps_title {
  background: var(--ehr-surface-subtle);
  border-bottom: 1px solid var(--hp-border);
  color: var(--ehr-text-primary);
  font-weight: 700;
  padding: 8px var(--hp-pad);
  text-transform: uppercase;
  min-height: 45px;
  display: flex;
  align-items: center;
}
.horsepage_pps_title.button_toggle {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 2em;
}
/* PHONEFIT_20261022: on a phone the heading and its buttons (Show Calls, Show RAFI) wrap instead of running off the screen */
@media (max-width: 640px) {
  .horsepage_pps_title.button_toggle { flex-wrap: wrap; row-gap: 6px; }
  .horsepage_pps_title .toggle_buttons { flex-wrap: wrap; }
}
.horsepage_pps_heading {
  display: flex;
  align-items: center;
}

/* WILL2UI_20260924: "Show Calls" is a narrow-panel control (it toggles the
   data-mobile-show / data-mobile-hide cells). From 1000px of PP-panel width
   C1-C3 are already on screen (.horsepage_hide_800 reveals at @container 1000px,
   ehr_horsepage_05), so the button could only hide Sex/Age/Race under a label
   that says "Show". The query resolves against .horsepage_pps_section. */
@container (min-width: 1000px) {
  .horsepage_pps_title .show-btn { display: none; }
}
/* QA9_20260924: what "Show Calls" does (horsepageToggleColumns toggles the class), scoped to the same narrow
   panels the button is shown on -- widen past 1000px and the table is the normal wide table again. Beats the
   .horsepage_hide_* rules (0,1,0 !important) on specificity. */
@container (max-width: 999px) {
  .horsepage_pps_table.mobile-columns-expanded [data-mobile-show] { display: table-cell !important; }
  .horsepage_pps_table.mobile-columns-expanded [data-mobile-hide] { display: none !important; }
}

.horsepage_pps_table_container {
  padding: .5em
}
.horsepage_pps_table {
  border-collapse: collapse;
  table-layout: auto;     /* Let columns size to content; hide classes handle responsiveness */
  width: 100%;
}

.horsepage_pps_table thead {
  background: var(--ehr-table-header-bg);
  color: var(--ehr-table-header-text);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* WILLMERGE_20261006 (R6): the red [x] on the "[x] Close <horse>" tab (horsepage_master.jinja). The tab is dark in main,
   derby and light, but #E0E0E0 in dark, where the light red fails; a deeper red there only. */
/* WILLMERGE_20261017: the close tab is now --ehr-theme-base (navy / green / black / light grey): light red on the three dark tabs,
   dark red on the light theme's grey (5:1 and up; the 10-06 pair measured 2.2-3.2:1 on the new tabs) */
.hp_close_x { color: #f87171; }
[data-theme="light"] .hp_close_x { color: #b91c1c; }

.horsepage_pps_table th {
  padding: 8px 6px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.2);
  border-bottom: 1px solid var(--ehr-border-on-brand);
}

.horsepage_pps_table th:last-child {
  border-right: none;
}

.horsepage_pps_table td {
  padding: 6px 6px;
  text-align: center;
  border: none;
  color: var(--ehr-text-primary);
  vertical-align: middle;
  white-space: nowrap;
  /* overflow: hidden; */
  text-overflow: ellipsis;
  position: relative;
  font-variant-numeric: tabular-nums;
}

.horsepage_pps_table tbody tr {
  transition: background 0.15s;
}

.horsepage_pps_table tbody tr:hover {
  /* filter: brightness(0.96); */
  background-color: #ebebeb;
}
/* WILLMERGE_20261006 (R10): in the dark theme the td text is #E0E0E0; the light row hover and the pastel off-track
   Date cells (below) need dark text there. Other themes already have dark text. */
/* WILLMERGE_20261108 (run list 607, render): the surface rows are dark tints in this theme now, so only the unfilled owner-change row turns pale on hover */
[data-theme="dark"] .horsepage_pps_table tbody tr.horsepage_pp_owner_row:hover td,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_dirtoff,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_turfoff,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_turfyld,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_polyoff,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_yellow,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_darkyellow,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_green,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_darkgreen,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_peach,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_purple,
[data-theme="dark"] .horsepage_pps_table td.horsepage_pprow_blue { color: #000; }

/* PP row background colors — surface-based striping.
   HTML emits horsepage_pprow_dirt / surf_dirt-mkw etc.
   The old class names (yellow/green/purple) didn't match HTML output.
   Legacy color-name aliases kept at bottom for any old templates. */

.horsepage_pprow_dirt,    .surf_dirt-mkw    { background: var(--hp-row-dirt) !important; color: var(--ehr-text-primary); }
.horsepage_pprow_dirtoff, .surf_dirtoff-mkw { background: var(--hp-row-dirtoff) !important; color: var(--ehr-text-primary); }
.horsepage_pprow_turf,    .surf_turf-mkw    { background: var(--hp-row-turf) !important; color: var(--ehr-text-primary); }
.horsepage_pprow_turfoff, .surf_turfoff-mkw { background: var(--hp-row-turfoff) !important; color: var(--ehr-text-primary); }
.horsepage_pprow_turfyld, .surf_turfyld-mkw { background: var(--hp-row-turfyld) !important; color: var(--ehr-text-primary); }
.horsepage_pprow_poly,    .surf_poly-mkw    { background: var(--hp-row-poly) !important; color: var(--ehr-text-primary); }
.horsepage_pprow_polyoff, .surf_polyoff-mkw { background: var(--hp-row-polyoff) !important; color: var(--ehr-text-primary); }

/* Divider under each status-tinted row. Covers the class on the <tr> or on the <td>. */
[class*="horsepage_pprow_"] > td,
[class*="surf_"][class*="-mkw"] > td,
td[class*="horsepage_pprow_"],
td[class*="surf_"][class*="-mkw"] {
  box-shadow: inset 0 -1px 0 var(--ehr-row-divider);
}

/* Results tab on phones: each entry is two lines.
   Line 1: expand arrow, horse name (takes the leftover width), type, M/L, C/R.
   Line 2: clipboard, 2D, 3D.
   The header row uses the same flex widths as line 1, so its labels line up.
   (Header class names re_th_expand / _horse / _type / _ml / _cr are assumed to
   mirror the re_td_* ones: check them with Inspect.) */
@container content (max-width: 420px) {

  .stable_horse_list_table.re_list_results { --re-expand-w: 28px; --re-cell-pad: 4px; }
 
  /* the table becomes blocks so rows can be flex containers */
  /* .stable_horse_list_table.re_list_results,
  .stable_horse_list_table.re_list_results > tbody,
  .stable_horse_list_table.re_list_results > thead { display: block; } */
 
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"],
  .stable_horse_list_table.re_list_results > thead > tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
 
  /* header cells stretch to the full row height, so the empty cell's bottom border sits at the bottom like the others
     (with align-items: center an empty cell is only as tall as its padding and its border floats mid-row) */
  .stable_horse_list_table.re_list_results > thead > tr { align-items: stretch; }
 
  /* ---- line 1: one set of widths for the header and the rows ---- */
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_expand,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_expand { flex: 0 0 var(--re-expand-w); }
 
  /* the name cell takes the leftover width, so the line fills the row and the divider runs edge to edge */
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_horse,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_horse { flex: 1 1 auto; min-width: 0; text-align: left; }
 
  /* the three right-hand cells get fixed widths so they line up down the list */
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_type,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_type { flex: 0 0 48px; text-align: center; }
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_ml,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_ml   { flex: 0 0 44px; text-align: center; }
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_cr,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_cr   { flex: 0 0 40px; text-align: center; }
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_post,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_post   { flex: 0 0 40px; text-align: center; }
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_age,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_age   { flex: 0 0 40px; text-align: center; }
 
  /* header: hide every label, then show the ones that sit above line 1 */
  .stable_horse_list_table.re_list_results > thead > tr > th { display: none; }
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_expand,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_horse,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_type,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_ml,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_cr,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_age,
  .stable_horse_list_table.re_list_results > thead > tr > th.re_th_post { display: block; }
 
  /* ---- line 2: clipboard, 2D, 3D on their own full-width line ---- */
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_action {
    display: flex;
    gap: 6px;
    flex: 0 0 100%;
    order: 99;
    box-shadow: inset 0 -1px 0 var(--ehr-row-divider);   /* one divider under the whole entry */
    justify-content: flex-end;
  }
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td.re_td_action > a:not(.wv_btn) {
    flex: 0 0 auto;   /* the clipboard icon keeps its own size */
  }
 
  /* no divider on line 1's cells (the action cell draws it) */
  .stable_horse_list_table.re_list_results > tbody > tr[id^="re_mainrow_"] > td:not(.re_td_action) { box-shadow: none; }
}

/* WILLMERGE_20261006 (R5): Will dropped the .surf_*-mkw:before bars (the PP Date cell keeps its bar through the
   .horsepage_pprow_*:before rules above). Owner 10-06: keep the 5px bar on the Entries rows (stable_entries.j2 td.re_row). */
.re_row.surf_dirt-mkw:before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--hp-dirt); }
.re_row.surf_turf-mkw:before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--hp-turf); }
.re_row.surf_poly-mkw:before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--hp-poly); }

/* Legacy color-name aliases (backward compat) */
.horsepage_pprow_yellow     { background: #fff9c4 !important; }
.horsepage_pprow_darkyellow,
.surf_darkyellow-mkw        { background: #ffe082 !important; }
.horsepage_pprow_green,
.surf_green-mkw             { background: #c8e6c9 !important; }
.horsepage_pprow_darkgreen,
.surf_darkgreen-mkw         { background: #81c784 !important; }
.horsepage_pprow_peach,
.surf_peach-mkw             { background: #f2d6c1 !important; }
.horsepage_pprow_purple,
.surf_purple-mkw            { background: #ce93d8 !important; }
.horsepage_pprow_blue,
.surf_blue-mkw              { background: #90caf9 !important; }
.surf_yellow-mkw            { background: #fff9c4 !important; }

/* === PP CELL BADGE COLORS ===
   Individual cells get colored backgrounds for quick visual scanning.
   Applied to <span> elements inside <td>. */

/* Shared badge base styles */
.horsepage_cell_sex_m,
.horsepage_cell_sex_f,
.horsepage_cell_age_2,
.horsepage_cell_age_3,
.horsepage_cell_age_3p,
.horsepage_cell_age_4p,
.horsepage_cell_surf_dfst,
.horsepage_cell_surf_dother,
.horsepage_cell_surf_tfrm,
.horsepage_cell_surf_tyld,
.horsepage_cell_surf_tother,
.horsepage_cell_surf_poly,
.horsepage_cell_rtype_a,
.horsepage_cell_rtype_c,
.horsepage_cell_rtype_mc,
.horsepage_cell_rtype_m,
.horsepage_cell_rtype_s,
.horsepage_cell_rtype_st,
.horsepage_cell_rtype_g1,
.horsepage_cell_rtype_g2,
.horsepage_cell_rtype_g3,
.horsepage_cell_rtype_o {
  display: inline-block;
  padding: 1px 5px;
  border-radius:3px;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  min-width: 28px;
}

/* Sex badges */
/* .horsepage_cell_sex_m { background: #5b9bd5; color: white; }
.horsepage_cell_sex_f { background: #e57398; color: white; } */

/* Age badges */
/* .horsepage_cell_age_2  { background: #7e57c2; color: white; }
.horsepage_cell_age_3  { background: #26a69a; color: white; }
.horsepage_cell_age_3p { background: #66bb6a; color: #000; }
.horsepage_cell_age_4p { background: #42a5f5; color: white; } */

/* Surface/Condition badges */
/* .horsepage_cell_surf_dfst   { background: #a1887f; color: white; }
.horsepage_cell_surf_dother { background: #6d4c41; color: white; }
.horsepage_cell_surf_tfrm   { background: #81c784; color: #000; }
.horsepage_cell_surf_tyld   { background: #8d6e63; color: white; }
.horsepage_cell_surf_tother { background: #2e7d32; color: white; }
.horsepage_cell_surf_poly   { background: #7e57c2; color: white; } */

/* Race Type badges */
/* .horsepage_cell_rtype_a            { background: #ef5350; color: white; }
.horsepage_cell_rtype_c,
.horsepage_cell_rtype_mc           { background: #8d6e63; color: white; }
.horsepage_cell_rtype_m            { background: #ff7043; color: white; }
.horsepage_cell_rtype_s,
.horsepage_cell_rtype_st           { background: #fdd835; color: #333; }
.horsepage_cell_rtype_g1,
.horsepage_cell_rtype_g2,
.horsepage_cell_rtype_g3           { background: #ab47bc; color: white; }
.horsepage_cell_rtype_o            { background: #26a69a; color: white; } */

:root {
  /* Sex */
  --badge-sex-m-bg:  #5b9bd5;        --badge-sex-m-text:  #fff;
  --badge-sex-f-bg:  #e57398;        --badge-sex-f-text:  #fff;

  /* Age */
  --badge-age-2-bg:  #7e57c2;      --badge-age-2-text:  #fff;
  --badge-age-3-bg:  #006666;        --badge-age-3-text:  #fff;
  --badge-age-3p-bg: #66bb6a;        --badge-age-3p-text: #000;
  --badge-age-4p-bg: #42a5f5;         --badge-age-4p-text: #fff;

  /* Surface / condition */
  --badge-surf-dfst-bg:   #a1887f;        --badge-surf-dfst-text:   #000;
  --badge-surf-dother-bg: #6d4c41;      --badge-surf-dother-text: #fff;
  --badge-surf-tfrm-bg:   #81c784;    --badge-surf-tfrm-text:   #000;
  --badge-surf-tyld-bg:   #8d6e63;       --badge-surf-tyld-text:   #fff;
  --badge-surf-tother-bg: #2e7d32;      --badge-surf-tother-text: #fff;
  --badge-surf-poly-bg:   #7e57c2;     --badge-surf-poly-text:   #fff;

  /* Race type */
  --badge-rtype-a-bg:  #ef5350;       --badge-rtype-a-text:  #fff;
  --badge-rtype-c-bg:  #8d6e63;      --badge-rtype-c-text:  #fff;  /* c and mc */
  --badge-rtype-m-bg:  #ff7043;    --badge-rtype-m-text:  #fff;
  /* RTBADGE_20261114 (run list 674, Will 11-13: Starter Allowance and Stakes looked the same): S gets indigo, a colour no
     race type used; ST keeps the yellow. Was one token for both: --badge-rtype-s-bg #fdd835 / -text #333, s and st */
  --badge-rtype-s-bg:  #3949ab;    --badge-rtype-s-text:  #fff;  /* s, starter allowance */
  --badge-rtype-st-bg: #fdd835;    --badge-rtype-st-text: #333;  /* st, stakes */
  --badge-rtype-g1-bg:  #ffffff;    --badge-rtype-g1-text:  #000000; --badge-rtype-g1-border:  #CFB53B;  /* g1 */
  --badge-rtype-g2-bg:  #ffffff;    --badge-rtype-g2-text:  #000000; --badge-rtype-g2-border:  #CCCCCC; /* g2 */
  --badge-rtype-g3-bg:  #ffffff;    --badge-rtype-g3-text:  #000000; --badge-rtype-g3-border:  #CE8946; /* g3 */
  --badge-rtype-o-bg:  #26a69a;      --badge-rtype-o-text:  #fff;
}

/* Sex badges */
.horsepage_cell_sex_m { background: var(--badge-sex-m-bg); color: var(--badge-sex-m-text); }
.horsepage_cell_sex_f { background: var(--badge-sex-f-bg); color: var(--badge-sex-f-text); }
/* Age badges */

.horsepage_cell_age_2  { background: var(--badge-age-2-bg);  color: var(--badge-age-2-text); }
.horsepage_cell_age_3  { background: var(--badge-age-3-bg);  color: var(--badge-age-3-text); }
.horsepage_cell_age_3p { background: var(--badge-age-3p-bg); color: var(--badge-age-3p-text); }
.horsepage_cell_age_4p { background: var(--badge-age-4p-bg); color: var(--badge-age-4p-text); }

/* Surface/Condition badges */
.horsepage_cell_surf_dfst   { background: var(--badge-surf-dfst-bg);   color: var(--badge-surf-dfst-text); }
.horsepage_cell_surf_dother { background: var(--badge-surf-dother-bg); color: var(--badge-surf-dother-text); }
.horsepage_cell_surf_tfrm   { background: var(--badge-surf-tfrm-bg);   color: var(--badge-surf-tfrm-text); }
.horsepage_cell_surf_tyld   { background: var(--badge-surf-tyld-bg);   color: var(--badge-surf-tyld-text); }
.horsepage_cell_surf_tother { background: var(--badge-surf-tother-bg); color: var(--badge-surf-tother-text); }
.horsepage_cell_surf_poly   { background: var(--badge-surf-poly-bg);   color: var(--badge-surf-poly-text); }

/* Race Type badges */
.horsepage_cell_rtype_a  { background: var(--badge-rtype-a-bg); color: var(--badge-rtype-a-text); }
.horsepage_cell_rtype_c,
.horsepage_cell_rtype_mc { background: var(--badge-rtype-c-bg); color: var(--badge-rtype-c-text); }
.horsepage_cell_rtype_m  { background: var(--badge-rtype-m-bg); color: var(--badge-rtype-m-text); }
.horsepage_cell_rtype_s  { background: var(--badge-rtype-s-bg); color: var(--badge-rtype-s-text); }
.horsepage_cell_rtype_st { background: var(--badge-rtype-st-bg); color: var(--badge-rtype-st-text); }  /* RTBADGE_20261114: own token */
.horsepage_cell_rtype_g1 { background: var(--badge-rtype-g1-bg); color: var(--badge-rtype-g1-text); border: 2px solid var(--badge-rtype-g1-border); }
.horsepage_cell_rtype_g2 { background: var(--badge-rtype-g2-bg); color: var(--badge-rtype-g2-text); border: 2px solid var(--badge-rtype-g2-border); }
.horsepage_cell_rtype_g3 { background: var(--badge-rtype-g3-bg); color: var(--badge-rtype-g3-text); border: 2px solid var(--badge-rtype-g3-border); }
.horsepage_cell_rtype_o  { background: var(--badge-rtype-o-bg); color: var(--badge-rtype-o-text); }

.horsepage_rtype_wrap {
  --rt-bg: var(--badge-rtype-a-bg);   /* default if the inline var is missing */
  --ehr-theme-base:      var(--ehr-text-on-light);
  --ehr-text-primary:    var(--ehr-text-on-light);
  --ehr-text-secondary: #555555;

  display: flex;
  gap: .25em;
  padding: 0 .5em 0 .5em;
  margin-left: 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--rt-bg) 35%, #fff);
  color: var(--ehr-text-on-light);
}

.horsepage_racename {
  font-size: 11px !important;
  width: 0;          /* contributes nothing to the cell's width calculation */
  min-width: 100%;   /* but fills the cell once the other content has set its width */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pedigree position badges — S / DS / DDS */
.horsepage_ped_badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  min-width: 22px;
  margin-right: 4px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}
.horsepage_ped_badge_s   { background: #0c420c; color: #fff; }
.horsepage_ped_badge_ds  { background: #1565c0; color: #fff; }
.horsepage_ped_badge_dds { background: #6a1b9a; color: #fff; }

/* Generic fallbacks (backward compat) */
.horsepage_cell_blue   { background: #5b9bd5; color: white; font-weight: 700; border-radius: 3px; }
.horsepage_cell_green  { background: #66bb6a; color: #000; font-weight: 700; border-radius: 3px; }
.horsepage_cell_teal   { background: #26a69a; color: white; font-weight: 700; border-radius: 3px; }
.horsepage_cell_brown  { background: #8d6e63; color: white; font-weight: 700; border-radius: 3px; }
.horsepage_cell_red    { background: #ef5350; color: white; font-weight: 700; border-radius: 3px; }

/* Superscript in PP cells */
.horsepage_sup {
  font-size: 0.75em;
  opacity: .75;   /* WILLMERGE_20261017 (render R10): was .6 -- 4.2-4.5:1 on the turf / poly row tints */
  vertical-align: super;
  margin-left: 3px;
  position: relative;
  top: -1px;
}

/* PP icons (3D, video, chart) */
.horsepage_pp_icons {
  display: flex;
  gap: 2px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}

.horsepage_pp_icon {
  width: 20px;
  height: 20px;
  border: 1px solid #999;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  flex-shrink: 0;
}

.horsepage_pp_icon_3d    { background: linear-gradient(135deg, #4fc3f7 0%, #0288d1 100%); color: white; }
.horsepage_pp_icon_video { background: #666; color: white; }
.horsepage_pp_icon_chart { background: #e0e0e0; color: #333; }
/* PPICONS_20260927: the icons are links now (replay + race chart) */
a.horsepage_pp_icon       { text-decoration: none; cursor: pointer; }
a.horsepage_pp_icon:hover { filter: brightness(1.15); }

/* Expand/collapse button */
.horsepage_pp_expand_cell {
  width: 40px;
  min-width: 40px;
  padding: 4px !important;
}

.horsepage_pp_expand_btn {
  /* background: var(--hp-yellow); */
  border: none;
  padding: 3px 6px;
  font-weight: 700;
  border-radius: var(--hp-radius-sm);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
  width: 100%;
}

.horsepage_pp_expand_btn:hover {
  background: #ffcd38;
}

/* Expanded detail row */
.horsepage_pp_detail_row {
  display: none;
  background: #f8f8f0 !important;
}

.horsepage_pp_detail_row.horsepage_show {
  display: table-row;
}

.horsepage_pp_detail_row td {
  padding: 10px 12px !important;
  text-align: left !important;
  border-bottom: 2px solid #ccc;
}

.horsepage_pp_detail_grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.horsepage_pp_detail_item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 5px 8px;
  border-left: 3px solid var(--hp-green);
}

.horsepage_pp_detail_label {
  font-weight: 700;
  color: var(--hp-text-muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.horsepage_pp_detail_value {
  font-weight: 600;
  font-size: 13px;
  color: var(--hp-text);
}

/* Color-coded left borders for specific detail cards */
.horsepage_pp_detail_item_track  { border-left-color: #4a90e2; }
.horsepage_pp_detail_item_dist   { border-left-color: #ff9800; }
.horsepage_pp_detail_item_time   { border-left-color: #607d8b; }
.horsepage_pp_detail_item_speed  { border-left-color: #e53935; }
.horsepage_pp_detail_item_odds   { border-left-color: #fdd835; }
.horsepage_pp_detail_item_jockey { border-left-color: #ab47bc; }

/* Detail cards that get FULL colored value badges (matching table cells) */
.horsepage_pp_detail_item_sex    { border-left-color: #5b9bd5; }
.horsepage_pp_detail_item_sex .horsepage_pp_detail_value {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 12px;
}
.horsepage_pp_detail_item_sex.horsepage_dv_m .horsepage_pp_detail_value {
  background: #5b9bd5; color: white;
}
.horsepage_pp_detail_item_sex.horsepage_dv_f .horsepage_pp_detail_value {
  background: #e57398; color: white;
}

.horsepage_pp_detail_item_age { border-left-color: #26a69a; }
.horsepage_pp_detail_item_age .horsepage_pp_detail_value {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 12px;
}
.horsepage_pp_detail_item_age.horsepage_dv_2 .horsepage_pp_detail_value   { background: #7e57c2; color: white; }
.horsepage_pp_detail_item_age.horsepage_dv_3 .horsepage_pp_detail_value   { background: #26a69a; color: white; }
.horsepage_pp_detail_item_age.horsepage_dv_3p .horsepage_pp_detail_value  { background: #66bb6a; color: #000; }
.horsepage_pp_detail_item_age.horsepage_dv_4p .horsepage_pp_detail_value  { background: #42a5f5; color: white; }

.horsepage_pp_detail_item_surf { border-left-color: #8d6e63; }
.horsepage_pp_detail_item_surf .horsepage_pp_detail_value {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 12px;
}
.horsepage_pp_detail_item_surf.horsepage_dv_dfst .horsepage_pp_detail_value   { background: #a1887f; color: white; }
.horsepage_pp_detail_item_surf.horsepage_dv_dother .horsepage_pp_detail_value { background: #6d4c41; color: white; }
.horsepage_pp_detail_item_surf.horsepage_dv_tfrm .horsepage_pp_detail_value   { background: #81c784; color: #000; }
.horsepage_pp_detail_item_surf.horsepage_dv_tyld .horsepage_pp_detail_value   { background: #8d6e63; color: white; }
.horsepage_pp_detail_item_surf.horsepage_dv_tother .horsepage_pp_detail_value { background: #2e7d32; color: white; }
.horsepage_pp_detail_item_surf.horsepage_dv_poly .horsepage_pp_detail_value   { background: #7e57c2; color: white; }

.horsepage_pp_detail_item_rtype { border-left-color: #ef5350; }
.horsepage_pp_detail_item_rtype .horsepage_pp_detail_value {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 12px;
}
.horsepage_pp_detail_item_rtype.horsepage_dv_a .horsepage_pp_detail_value  { background: #ef5350; color: white; }
.horsepage_pp_detail_item_rtype.horsepage_dv_c .horsepage_pp_detail_value  { background: #8d6e63; color: white; }
.horsepage_pp_detail_item_rtype.horsepage_dv_mc .horsepage_pp_detail_value { background: #8d6e63; color: white; }
.horsepage_pp_detail_item_rtype.horsepage_dv_m .horsepage_pp_detail_value  { background: #ff7043; color: white; }
.horsepage_pp_detail_item_rtype.horsepage_dv_s .horsepage_pp_detail_value  { background: var(--badge-rtype-s-bg); color: var(--badge-rtype-s-text); }  /* RTBADGE_20261114: was #fdd835 / #333 */
.horsepage_pp_detail_item_rtype.horsepage_dv_st .horsepage_pp_detail_value { background: var(--badge-rtype-st-bg); color: var(--badge-rtype-st-text); }
.horsepage_pp_detail_item_rtype.horsepage_dv_o .horsepage_pp_detail_value  { background: #26a69a; color: white; }
.horsepage_pp_detail_item_rtype.horsepage_dv_g .horsepage_pp_detail_value  { background: #ab47bc; color: white; }

.horsepage_ped_section {
  background: var(--ehr-surface-bg);
  /* border: 1px solid var(--ehr-border); */
  /* border-radius: var(--hp-radius); */
  /* box-shadow: var(--ehr-table-box-shadow); */
  margin-bottom: var(--hp-gap);
  overflow: hidden;
}

.horsepage_ped_section .panel {
  padding: .5em;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* PEDLINK_20261004: stallion names on the horse page open the sire page (.js-sire-open, automated.js).
   Colour inherits the cell / line colour so the blue/pink chart and dark mode are untouched; the dotted
   underline shows it is a link without hover (phones have no hover). */
.hp_ped_sire { color: inherit; text-decoration: underline dashed; text-underline-offset: 4px; text-decoration-color: var(--ehr-theme-strong); cursor: pointer; } /* WILLMERGE_20261017: was a 2nd text-decoration shorthand (a colour only), which reset the underline to none */
.hp_ped_sire:hover, .hp_ped_sire:focus { text-decoration-style: solid; }

/* PPOWNER_20261016 (paste 322): the owner-change line between two starts in the horse page PPs (horsepage_pps.jinja).
   The starts above it ran for the new owner. */
.horsepage_pp_owner_row td {
  text-align: left;
  font-size: 11px;
  font-style: italic;
  padding: 2px 8px;
  border-top: 1px dashed #999;
  border-bottom: 1px dashed #999;
  white-space: normal;
}
/* HISTORY_20261016 (paste 324): the gelded line, red like the old game "Horse was gelded"; a lighter red on the dark
   theme rows (the dark hover rule above still turns it black on the light hover background). */
.horsepage_pps_table .horsepage_pp_gelded_row td { color: #c62828; font-weight: 700; }
[data-theme="dark"] .horsepage_pps_table .horsepage_pp_gelded_row td { color: #f87171; }
/* WILLMERGE_20261017: PP cells are #000 now (Will: every PP row has its pastel surface fill). The owner-change row has no fill, so in
   the dark theme it sat black on #3b3b3b; the gelded row keeps its red, the hover keeps the dark text. */
[data-theme="dark"] .horsepage_pps_table tr.horsepage_pp_owner_row:not(.horsepage_pp_gelded_row):not(:hover) td { color: var(--ehr-text-primary); }
/* WILLMERGE_20261017 (render R5): Will's dark theme sets color-scheme: dark, so a button with no colour of its own gets white text */
.horsepage_pp_expand_btn { color: #000; }
/* WILLMERGE_20261108 (run list 607, render): the arrow lost its amber fill and the race name was #333, both on what are now dark rows. Hover keeps the amber and the black. */
[data-theme="dark"] .horsepage_pp_expand_btn:not(:hover) { color: var(--ehr-text-primary); }
[data-theme="dark"] .horsepage_racename { color: var(--ehr-text-primary); }
