/*
  ==========================================================================
  Design tokens
  ==========================================================================
*/
:root {
  --color-primary: #e98b26;
  --color-border: #ddd;
  --color-border-light: #ccc;
  --color-row-alt: #f2f2f2;
  --color-spinner-bg: #f3f3f3;
  --color-spinner-accent: #3498db;
  --overlay-weak: rgba(0,0,0,0.50);   /* spinner overlay (unchanged) */
  --overlay-strong: rgba(0,0,0,0.55); /* athlete overlay (unchanged) */
  --shadow-overlay: 0 4px 18px rgba(0,0,0,0.25);
  --color-danger-bg: #fdd;
  --color-danger-outline: #d00;
}

/*
  ==========================================================================
  Base
  ==========================================================================
*/
body { font-family: Arial, Helvetica, sans-serif; line-height: 1.6; }
body.disabled { overflow: hidden; }

/* Typography: ensure normal text uses 1em */
body, p, li, td, th { font-size: 1em; }
/* Make related labels/links/controls match normal text on desktop */
.form-group label,
#progn-link,
#back-normal-link,
#back-button { font-size: 1em; }

/* Form groups: flex layout used around dropdowns/links */
.form-group { display:flex; align-items:center; gap:0.75em; flex-wrap:wrap; }

/* Prognose and back-to-normal links under dropdowns */
#progn-link,
#back-normal-link { text-decoration: underline; white-space: nowrap; margin-left: 0; }
#progn-link { display:flex; align-items:center; gap:0.4em; }
/* Place link on its own row under the dropdown */
.form-group #progn-link,
.form-group #back-normal-link { flex-basis: 100%; margin-top: 0.25em; }

/* Global search form placement: below back button, left-aligned */
#athlete-search-form { margin: 0.75em 0 0.25em 0; display:flex; justify-content:flex-start; align-items:center; gap:0.5em; position: static; background: transparent; z-index: 10; max-width:100%; }
/* Match input and button text to normal text size */
#athlete-search-form input,
#athlete-search-form button { font-size: 1em; }
/* Ensure placeholder text follows the input font size */
#athlete-search-form input::placeholder { font-size: inherit; }
/* Make search input responsive on narrow screens */
@media (max-width: 37.5em), (hover: none) and (pointer: coarse) {
  #athlete-search-form input { width: 100%; max-width: 420px; }
  /* Bump input/button font size to match mobile text size */
  #athlete-search-form input,
  #athlete-search-form button { font-size: 1.1em; }
}

/* Spinner */
.spinner-container { display:none; justify-content:center; align-items:center; position:fixed; inset:0; background-color: var(--overlay-weak); z-index:1000; }
.spinner { border:16px solid var(--color-spinner-bg); border-top:16px solid var(--color-spinner-accent); border-radius:50%; width:120px; height:120px; animation: spin 2s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg);} 100% { transform: rotate(360deg);} }

/*
  ==========================================================================
  Tables
  ==========================================================================
*/
#data-table { width:100%; border-collapse:collapse; }
#data-table th, #data-table td { padding:10px; text-align:left; border:1px solid var(--color-border); }
#data-table thead { background-color: var(--color-primary); color:#fff; }
#data-table thead th { position:sticky; top:0; background-color: var(--color-primary); z-index:5; }
#data-table tbody th { position:static; }
#data-table tbody th.section-header { position:sticky; top:44px; z-index:4; }
#data-table tr:nth-child(even) { background-color: var(--color-row-alt); }
#data-table th.right-align, #data-table td.right-align { text-align:right; }
.narrow-column { width:50px; }

/* Tooltips */
.tooltip-header { position:relative; cursor:pointer; }
.tooltip-header::after { content: attr(data-tooltip); position:absolute; background:#000; color:#fff; font-weight:bold; padding:5px; border-radius:5px; top:100%; left:100%; transform: translateX(-100%); white-space:nowrap; display:none; z-index:1; }
.tooltip-header:hover::after { display:block; }

/* Dropdowns */
#season-dropdown, #category-dropdown { padding:10px; border:1px solid var(--color-border); font-size: 1em; }
#category-dropdown:hover, #category-dropdown:focus { border-color: var(--color-primary); }

/*
  ==========================================================================
  Athlete info overlay
  ==========================================================================
*/
#athlete-info-overlay { position:fixed; inset:0; background: var(--overlay-strong); display:none; align-items:center; justify-content:center; z-index:2000; padding:1rem; }
#athlete-info-overlay.show { display:flex; }
#athlete-info-overlay .athlete-overlay-content { background:#fff; padding:1.2rem 1.5rem 1.4rem; border-radius:8px; max-width:320px; width:100%; position:relative; box-shadow: var(--shadow-overlay); font-size:0.95rem; }
#athlete-info-overlay .overlay-close { position:absolute; top:4px; right:6px; border:none; background:transparent; font-size:1.4rem; line-height:1; cursor:pointer; }
.info-btn { margin-left:6px; background: var(--color-primary); color:#fff; border:none; width:20px; height:20px; border-radius:50%; cursor:pointer; font-size:0.8rem; font-weight:700; line-height:20px; text-align:center; padding:0; }
.info-btn:hover { background: var(--color-primary); }

/*
  ==========================================================================
  Stages / cells
  ==========================================================================
*/
td.stage-cell { text-align:center; padding-bottom:6px; }
td.stage-cell br { line-height:4px; }
td.stage-cell .stage-info-btn { margin-top:2px; margin-left:0; width:18px; height:18px; padding:0; line-height:18px; font-weight:700; display:inline-flex; align-items:center; justify-content:center; font-size: 1rem; }
td.stage-cell .stage-info-btn:active { transform:scale(.92); }
th.stage-col, td.stage-cell { width:40px; min-width:40px; max-width:40px; padding:3px 3px; }
.name-wrapper { display:inline-flex; align-items:center; gap:4px; width:100%; }
.name-wrapper a { min-width:0; }
td.stage-cell.projection-excluded { background: var(--color-danger-bg); outline:1px dashed var(--color-danger-outline); }

/*
  ==========================================================================
  Responsive adjustments
  ==========================================================================
*/
/* Phone-only typography bump (keeps tablets/laptops unchanged) */
@media (max-width: 37.5em), (hover: none) and (pointer: coarse) {
  body, p, li, td, th { font-size: 1.1em; }
  /* Match labels and prognose link to normal text size on mobile/touch */
  .form-group label,
  #progn-link,
  #back-normal-link,
  #back-button { font-size: 1.1em; }
  /* Make dropdown values same size as normal text on mobile/touch */
  #season-dropdown,
  #category-dropdown { font-size: 1.1em; }
  /* Ensure summary elements scale too (e.g., explain box) */
  summary { font-size: 1.1em; }
  /* Add breathing room inside stage headers/cells on phones & touch */
  th.stage-col,
  td.stage-cell { padding: 6px 6px; width: 44px; min-width: 44px; max-width: 44px; }
  /* Loosen the line break inside stage cells for better vertical spacing */
  td.stage-cell br { line-height: 8px; }

  /* Visual separators between stage columns on phones/touch */
  th.stage-col,
  td.stage-cell { box-shadow: inset -1px 0 0 var(--color-border-light); }
  /* Subtle zebra striping for stage columns to aid scanning */
  th.stage-col:nth-child(even),
  td.stage-cell:not(.projection-excluded):nth-child(even) { background-color: rgba(0,0,0,0.02); }
}

/* Optional stacked-table pattern (opt-in via class) */
@media (max-width: 37.5em) {
  table.stack-on-small thead { display: none; }
  table.stack-on-small tr { margin-bottom: 10px; display: block; border-bottom: 2px solid var(--color-border); }
  table.stack-on-small td { display: block; text-align: right; border-bottom: 1px dotted var(--color-border-light); }
  table.stack-on-small td::before { content: attr(data-label); float: left; text-transform: uppercase; font-weight: bold; }

  /* Stage result numbers smaller on phones */
  td.stage-cell {
    font-size: 0.9em;
  }

  /* Give stage cells and headers a little more padding on phones */
  th.stage-col,
  td.stage-cell {
    padding: 6px 6px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
  }

  /* Loosen the line break inside stage cells for better vertical spacing */
  td.stage-cell br { line-height: 8px; }

  /* Make stage info "i" buttons ~1.5x larger on phones */
  td.stage-cell .stage-info-btn {
    width: 27px;
    height: 27px;
    line-height: 27px;
    font-size: 1.1rem; /* match normal text size on phones */
  }

  /* Visual separators between stage columns on phones */
  th.stage-col,
  td.stage-cell { box-shadow: inset -1px 0 0 var(--color-border-light); }
  /* Subtle zebra striping for stage columns to aid scanning */
  th.stage-col:nth-child(even),
  td.stage-cell:not(.projection-excluded):nth-child(even) { background-color: rgba(0,0,0,0.02); }
}