/* -------------------------------------------------------
   6. SECTION D: RACE FINDER / RAFI (logged-in only)
   
   Left panel (filters) + right panel (results).
   Side-by-side at desktop, stacked on mobile.
   ------------------------------------------------------- */

.rafi-container {
  display: grid;
  grid-template-columns: 1fr;
}
.rafi-container.sbs_grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1em;
  flex-direction: column;
  container-type: inline-size;  
}

/* WILL2UI_20260924: was 600px. Split view is switched on automatically when RAFI
   opens (toggleRafiSection), and the Split View button is hidden at <=1000px
   (below) -- so 601-1000px was a forced two-column split with no way out.
   Stacking at the same breakpoint the button disappears keeps the two in step. */
@media (max-width: 1000px) {
  .rafi-container.sbs_grid {
    grid-template-columns: 1fr;
  }
}

.horsepage_rafi_section {
  background: var(--hp-card-bg);
  /* border-radius: var(--hp-radius); */
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  /* margin-bottom: var(--hp-gap); */
  overflow: hidden;
  container-type: inline-size;
}
.horsepage_rafi_section.hidden {
  display: none;
}

.horsepage_rafi_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_rafi_body {
  display: grid;
  grid-template-columns: 275px 1fr;
  /* gap: .5em; */
  align-items: stretch;
  /* RAFISCROLL_20261116 (run list 713, owner 11-16: "scrolling up and down has also been removed from Rafi"): side by side
     the results and the filters scroll inside this window only while it has a height to fill. Round 6 (702) dropped
     height:100%, so the results grew to their full length and the section (overflow:hidden) cut them off with no scroll.
     Back, with the 450px of round 6. Stacked (1000px and under) the block below sets height:auto as before. */
  height: 100%;
  max-height: 450px;
}

@media (max-width: 1000px) {
  .horsepage_rafi_title button { /* hide split view */
    display: none;
  }

  .horsepage_rafi_body {
    /* PHONEFIT_20261022 (player note 10-22, Android: the Enter button off to the right, no way to scroll): 1fr grew to the
       results row width (366px in a 290px box at 360px), so the whole stack ran off the screen. minmax(0, 1fr) keeps it in
       the box; the results shrink to fit and .horsepage_rafi_right still scrolls sideways if a row is wider. */
    grid-template-columns: minmax(0, 1fr);
    /* RAFIMOBILE_20261019 (player 10-19, phone: "the hot race is basically cut off when she searches for it"):
       height:100% made this body as tall as the WHOLE section (a stretched grid item), so under the 62px title it ran
       62px past the section, whose overflow:hidden cut that off: stacked, that is the results, and a single hot race
       showed as a strip under the header. Stacked, the body takes its content height and the results get their own
       325px window (the desktop view is side by side and keeps both rules above). */
    height: auto;
    max-height: none;
  }

  .horsepage_rafi_right {
    max-height: 325px;
  }

}

/* RAFI left panel (filters) */
.horsepage_rafi_left {
  /* min-width: 260px; */
  /* width: 260px; */
  background: #e6f3ff;
  color: var(--hp-text);   /* WILLMERGE_20261024: fixed light panel keeps dark text in every theme (the wrapper no longer sets it) */
  border-right: 1px solid var(--hp-border);
  padding: var(--hp-pad-sm);
  flex-shrink: 0;
  /* RAFIFIT_20261023 (player note 10-23: "After adding the Condition Filter on the Typ/DT tab, the buttons are cut off at
     the bottom"): side by side, the body is a 325px window and the section clips what runs past it; the Cond block made
     Typ/DT taller than that. The filter panel now scrolls inside the window instead of being cut, and the blocks sit
     closer (gap below). Stacked (1000px and under) the body takes its content height, so nothing changes there. */
  overflow-y: auto;
  min-height: 0;
}

.horsepage_rafi_tabs {
  display: flex;
  margin-bottom: 10px;
  background: #d0e8ff;
  border-radius: 3px;
  overflow: hidden;
}

.horsepage_rafi_tab {
  flex: 1;
  padding: 5px 4px;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  background: #b8d4f0;
  border: 1px solid #8bb3d9;
  cursor: pointer;
  transition: background 0.2s;
}

.horsepage_rafi_tab:hover {
  background: #a0c4e0;
}

.horsepage_rafi_tab.horsepage_active {
  background: var(--hp-green);
  color: white;
  border-color: var(--hp-green-dark);
}

.horsepage_rafi_panel {
  display: none;
}

.horsepage_rafi_panel.horsepage_active {
  /* display: block; */
  display: grid;
  gap: .6em;  /* RAFIFIT_20261023: was 1em */
  grid-template-columns: 1fr;
}

@media (max-width: 1000px) {
  .horsepage_rafi_panel {
    grid-template-columns: 1fr 1fr 1fr !important;
  }
  .horsepage_rafi_panel.col-2 {
    grid-template-columns: 1fr 1fr !important;
  }
}
/* PHONEFIT_20261022: three filter blocks did not fit a phone (327px in 274px at 360px, Distance Range cut off); they wrap */
@media (max-width: 640px) {
  .horsepage_rafi_panel.horsepage_active {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

.horsepage_rafi_panel h4 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--hp-blue-dark);
}

/* Checkbox groups in RAFI */
.horsepage_rafi_checks {
  display: flex;
  flex-flow: row wrap;
  gap: 1em;
}

.horsepage_rafi_checks label {
  display: flex;
  align-items: center;
  font-size: 11px;
  cursor: pointer;
}

.horsepage_rafi_checks input[type="checkbox"] {
  margin-right: 5px;
  width: 13px;
  height: 13px;
}

/* Two-column checkbox layout */
.horsepage_rafi_2col {
  display: flex;
  align-items: flex-start;
  gap: 1em;
}

.horsepage_rafi_2col .horsepage_rafi_col {
  flex: 1;
  min-width: 0;

  display: grid;
  gap: .25em;
}

.horsepage_rafi_col label {
  display: flex;
  align-items: center;
  gap: .5em;
  font-size: 11px;
  margin-bottom: 3px;
  cursor: pointer;
}

/* Select inputs in RAFI */
.horsepage_rafi_select_row {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  gap: .25em;
  margin-bottom: 5px;
}

.horsepage_rafi_select_row label {
  font-size: 11px;
  font-weight: 700;
  min-width: 28px;
}

.horsepage_rafi_select_row select {
  flex: 1;
  padding: 4px;
  font-size: 11px;
  background: #fff;
  /* PHONEFIT_20261022 (player note 10-22, dark mode: the Travel and Distance boxes all white): the panel stays light in
     every theme, but the dark theme gave the box white text on this white background */
  color: var(--hp-text);
  border: 1px solid #ccc;
  border-radius: var(--hp-radius-sm);
}

.horsepage_rafi_select_row span {
  font-size: 10px;
}

/* TRAVELHINT_20261104 (run list 560): the one line under Travel (horsepage_rafi.jinja): where Travel counts from, or the
   never-raced line. The filter panel stays light in every theme, so the fixed muted grey (#666 on #e6f3ff, 5.1:1).
   rev2 (owner 11-04: "one short line below"): side by side the filter panel is a 325px window (RAFIFIT_20261023) with
   about 12px to spare on D/S/Trv, so the line is 12px tall and sits 4px up in the Travel row's 5px bottom margin: it
   adds 8px and the window does not scroll. Stacked (1000px and under) there is no height limit and the narrow Travel
   column wraps the line, so it gets normal line spacing there. */
.horsepage_rafi_hint {
  font-size: 11px;
  line-height: 12px;
  color: var(--hp-text-muted);
  margin: -4px 0 0;
}

@media (max-width: 1000px) {
  .horsepage_rafi_hint {
    line-height: 1.3;
    margin-top: -2px;
  }
}

/* RAFI buttons */
.horsepage_rafi_buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.horsepage_rafi_buttons button {
  padding: 4px 8px;
  font-size: 10px;
  border-radius: 3px;
  border: 1px solid;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--hp-font);
  transition: filter 0.15s;
}

.horsepage_rafi_buttons button:hover {
  filter: brightness(1.1);
}

.horsepage_rafi_btn_save   { background: #28a745; color: white; border-color: #1e7e34; }
.horsepage_rafi_btn_normal { background: #007bff; color: white; border-color: #0056b3; }
.horsepage_rafi_btn_local  { background: #6f42c1; color: white; border-color: #5a32a3; }
.horsepage_rafi_btn_hot    { background: #dc3545; color: white; border-color: #c82333; }

/* RAFI right panel (results) */
.horsepage_rafi_right {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0;
  overflow-y: auto;
  min-height: 0;  
}

.horsepage_rafi_placeholder {
  color: var(--hp-text-muted);
  font-size: 13px;
  padding: 0;
  text-align: center;
}

/* RAFI results grid header */
/* (horsepage_rafi_results classes removed — template uses .results-header / .results-row) */

.horsepage_rafi_hcell,
.horsepage_rafi_cell {
  padding: 4px 2px;
  text-align: center;
  font-size: 10px;
  border-right: 1px solid rgba(255,255,255,0.15);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horsepage_rafi_cell {
  font-size: 11px;
  border-right: 1px solid var(--hp-border);
}

.results-row > .cell.hash-col a { 
  color: inherit;
  font-weight: 800;
  text-decoration: underline !important;
  text-underline-offset: 4px;
  cursor: default; 
}

/* RAFI result action buttons */
.horsepage_rafi_btn_enter {
  background: #28a745;
  color: white;
  border: 1px solid #1e7e34;
  padding: 2px 6px;
  font-size: 9px;
  border-radius: 2px;
  cursor: pointer;
  min-width: 40px;
  font-family: var(--hp-font);
}

.horsepage_rafi_btn_enter_red {
  background: #a72845;
  color: yellow;
  border: 1px solid #7e1a34;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 2px;
  cursor: pointer;
  min-width: 40px;
}

.horsepage_rafi_btn_enter_pwd {
  background: #4528a7;
  color: yellow;
  border: 1px solid #341a7e;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 2px;
  cursor: pointer;
  min-width: 40px;
  font-family: var(--hp-font);
}

/* RAFI detail/expand rows */
.horsepage_rafi_detail_row {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  margin: 2px 0;
}

.horsepage_rafi_detail_content {
  padding: 8px 10px;
  font-size: 11px;
}

.horsepage_rafi_detail_item {
  display: inline-block;
  margin-right: 10px;
  font-weight: 700;
}

.horsepage_rafi_detail_value {
  font-weight: 400;
  color: var(--hp-blue);
}


/* ============================================================
   NEW-RACER RAFI PROMINENCE (2026-08-12)
   Driven by the login-cookie `newracer` flag. Makes the otherwise
   hidden Race Finder impossible to miss for players still learning.
   ============================================================ */
.rafi_btn_hot {
	background: #1b9e46 !important;
	color: #fff !important;
	font-weight: 800;
	/* WILL2UI_20260924: was border:none + own radius/padding. The button is now a
	   .btn .btn-xs beside "Show Calls"; keeping the 1px border (recoloured) and
	   letting .btn size it keeps the two the same height and shape. */
	border-color: #1b9e46 !important;
	box-shadow: 0 0 0 3px rgba(27,158,70,0.25);
	animation: rafiPulse 1.8s ease-in-out infinite;
}
@keyframes rafiPulse {
	0%, 100% { box-shadow: 0 0 0 3px rgba(27,158,70,0.28); }
	50%      { box-shadow: 0 0 0 7px rgba(27,158,70,0.08); }
}
.rafi_newracer_callout {
	background: #e8f5e9;
	border: 1px solid #a5d6a7;
	border-radius: 8px;
	padding: 10px 14px;
	margin: .5em .5em 0;  /* WILL2UI_20260924: now sits inside the panel under the title bar (was 0 0 10px, above it) */
	font-size: 13px;
	line-height: 1.5;
	color: #1b5e20;
}
.rafi_newracer_callout strong { color: #030369; }

/* New-racer claiming-race warning (2026-08-12) */
.rafi_claim_warnbox { margin-top: 6px; }
/* OVERSEASLINE_20261026 (run 451, owner 10-26): the Enter warning is a full-width line under the race row (rafi.jinja), not a box
   in the Enter cell, where it was cut off. */
.rafi_claim_warnline { margin: 0; padding: 6px 8px 8px; text-align: left; }
.rafi_claim_warn {
	background: #fdecea;
	padding: 10px 12px;
	font-size: 12px;
	line-height: 1.5;
	color: #7a1f1f;
  text-align: left;;
}
.rafi_claim_warn_h { font-weight: 800; color: #b71c1c; margin-bottom: 4px; }
.rafi_claim_warn_b { margin-bottom: 8px; }
.rafi_claim_warn_b strong { color: #b71c1c; }
.rafi_claim_warn_a { display: flex; gap: 8px; flex-wrap: wrap; }
.rafi_claim_cancel {
	background: #eee;
	border: 1px solid #ccc;
	border-radius: 6px;
	padding: 4px 12px;
	cursor: pointer;
	font-weight: 600;
}

/* GLOBALMOVES_20261015 (paste 309): overseas moves -- a horse may move to the other hemisphere and back once a year.
   The plane by the travel cost marks a race in the other hemisphere; red = one move too many (no Enter). */
.rafi-hemi-flag { margin-left: 3px; color: #b26a00; font-weight: 700; cursor: help; }
.rafi-hemi-flag-no { color: #b71c1c; }
.rafi-hemi-no { display: inline-block; font-size: 11px; font-weight: 700; color: #b71c1c; cursor: help; white-space: nowrap; }
.rafi-hemi-text { color: #8a5300; }
.rafi-hemi-text-no { color: #b71c1c; font-weight: 600; }
/* HEMISIDE_20261024 (paste 410, owner 10-24): with Travel = Global, one line above the results: the overseas moves this horse
   used this year and its side of the world (rafi.jinja, from website_fn_json_horse_hemi_side). Same amber as the plane. */
.rafi-hemi-banner {
	background: #fff8e1;
	border: 1px solid #ffe0b2;
	border-radius: 8px;
	padding: 8px 12px;
	margin: 0 0 8px;
	font-size: 12px;
	line-height: 1.5;
	color: #8a5300;
}
.rafi-hemi-banner-h { font-weight: 800; color: #b26a00; margin-right: 4px; }
.rafi-hemi-banner b { color: #5d3700; }
.rafi-hemi-banner-err { background: #fdecea; border-color: #f5c6cb; color: #b71c1c; }

/* CONDSPLIT_20261021 (player note 10-21: "Condition and Claiming Price are grouping together"): the Cond cell wraps instead of
   cutting the text off ("NW2L 10..."): the condition on line 1, the claim tag (smaller) on line 2 (rafi.jinja). The column is
   24px wider than the others, through flex-basis with the same grow as every cell (a bigger flex-grow would put the header and
   the rows out of line, their cell paddings differ). Phones still hide the column (container 420px,
   ehr_horsepage_06_backcompat.css) and show the condition in the detail card. */
.results-header > .header-cell.cond-col,
.results-row > .cell.cond-col { flex-basis: 24px; }
.results-row > .cell.cond-col { white-space: normal; text-overflow: clip; overflow-wrap: break-word; line-height: 1.15; }
.rafi-cond-main,
.rafi-cond-tag { display: block; }
.rafi-cond-tag { font-size: 10px; font-weight: 600; opacity: .8; }
