/* ============================================================
   C.R.I. PICKS — Master Design System
   "Caymanas Race Intelligence"
   Light authority theme — editorial, data-rich, professional
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Backgrounds */
    --bg-primary: #F8F9FA;
    --bg-card: #FFFFFF;
    --bg-tertiary: #F1F3F5;
    --bg-hover-row: #E8F5E9;
    --bg-input: #FFFFFF;

    /* Text */
    --text-primary: #1A1A2E;
    --text-secondary: #495057;
    --text-tertiary: #868E96;
    --text-inverse: #FFFFFF;
    --text-link: #0F5132;

    /* Accent — Racing Green */
    --accent: #0F5132;
    --accent-hover: #0A3622;
    --accent-light: #D1E7DD;
    --accent-surface: #E8F5E9;

    /* Position colors */
    --color-win: #198754;
    --color-place: #0DCAF0;
    --color-show: #FFC107;
    --color-loss: #ADB5BD;
    --color-dnf: #DC3545;
    --color-scratched: #DC3545;

    /* Premium / Gold */
    --gold: #D4A843;
    --gold-light: #FFF3CD;
    --gold-text: #856404;

    /* Borders */
    --border: #DEE2E6;
    --border-hover: #0F5132;
    --border-input: #CED4DA;
    --border-focus: #0F5132;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.12);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    /* Typography */
    --font-heading: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --font-body: 'Source Sans 3', 'Segoe UI', -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Menlo', 'Consolas', monospace;

    /* Type scale */
    --text-2xl: 28px;
    --text-xl: 22px;
    --text-lg: 17px;
    --text-base: 15px;
    --text-sm: 14px;
    --text-xs: 12px;

    /* Line heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;

    /* Layout */
    --nav-height: 60px;
    --container-max: 1280px;
    --container-narrow: 960px;
    --bottom-nav-height: 56px;
}


/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 0;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

table {
    border-collapse: collapse;
    width: 100%;
}

ul, ol {
    list-style: none;
}


/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    line-height: var(--leading-tight);
    font-weight: 700;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); margin-bottom: var(--space-4); }
h3 { font-size: var(--text-lg); }

.text-mono {
    font-family: var(--font-mono);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-tertiary {
    color: var(--text-tertiary);
}

.text-accent {
    color: var(--accent);
}

.text-gold {
    color: var(--gold);
}


/* --- Layout --- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-5);
}

.container--narrow {
    max-width: var(--container-narrow);
}

.page-content {
    padding-top: calc(var(--nav-height) + var(--space-6));
    padding-bottom: var(--space-16);
    min-height: 100vh;
}

.section {
    margin-bottom: var(--space-12);
}

.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.section__title {
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section__link {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.section__link:hover {
    color: var(--accent-hover);
}

.section__link svg {
    width: 14px;
    height: 14px;
    transition: transform 0.15s ease;
}

.section__link:hover svg {
    transform: translateX(3px);
}


/* --- Top Navigation --- */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: box-shadow 0.2s ease;
}

.nav--scrolled {
    box-shadow: var(--shadow-md);
}

.nav__inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-5);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
}

.nav__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    flex-shrink: 0;
}

.nav__logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.nav__brand-text {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav__link {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.nav__link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav__link--active {
    color: var(--accent);
    font-weight: 600;
}

.nav__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.nav__search-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.nav__search-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav__search-btn svg {
    width: 20px;
    height: 20px;
}

.nav__hamburger {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.nav__hamburger:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav__hamburger svg {
    width: 22px;
    height: 22px;
}


/* --- Mobile Menu Overlay --- */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--bg-card);
    z-index: 1100;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    overflow-y: auto;
    padding: var(--space-8) var(--space-6);
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu__close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.mobile-menu__close:hover {
    background: var(--bg-tertiary);
}

.mobile-menu__links {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-top: var(--space-8);
}

.mobile-menu__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.mobile-menu__link:hover,
.mobile-menu__link--active {
    color: var(--accent);
    background: var(--accent-surface);
}

.mobile-menu__link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mobile-menu__divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-4) 0;
}

.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}


/* --- Bottom Navigation (mobile) --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 900;
    padding: 0 var(--space-2);
}

.bottom-nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) var(--space-3);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item--active {
    color: var(--accent);
}

.bottom-nav__item svg {
    width: 22px;
    height: 22px;
}


/* --- Search Overlay --- */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-overlay__box {
    width: 90%;
    max-width: 640px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-overlay.active .search-overlay__box {
    transform: translateY(0);
}

.search-overlay__input-wrap {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    gap: var(--space-3);
}

.search-overlay__input-wrap svg {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-overlay__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: var(--text-lg);
    color: var(--text-primary);
    background: transparent;
}

.search-overlay__input::placeholder {
    color: var(--text-tertiary);
}

.search-overlay__close {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.search-overlay__results {
    max-height: 400px;
    overflow-y: auto;
}

.search-overlay__empty {
    padding: var(--space-8) var(--space-5);
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

.search-result {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    cursor: pointer;
    transition: background 0.1s ease;
    text-decoration: none;
    color: inherit;
}

.search-result:hover {
    background: var(--bg-tertiary);
}

.search-result__type {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--accent-surface);
    color: var(--accent);
    flex-shrink: 0;
}

.search-result__type svg {
    width: 16px;
    height: 16px;
}

.search-result__info {
    flex: 1;
    min-width: 0;
}

.search-result__name {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.search-result__meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: 1px;
}

.search-result__form {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}


/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-hover);
}

.card--no-hover:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.card__body {
    padding: var(--space-5);
}

.card__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.card__footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
}


/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
}

.btn--primary {
    background: var(--accent);
    color: var(--text-inverse);
    border: 1px solid var(--accent);
}

.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--text-inverse);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 81, 50, 0.25);
}

.btn--outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn--outline:hover {
    background: var(--accent);
    color: var(--text-inverse);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn--ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn--gold {
    background: var(--gold);
    color: #FFFFFF;
    border: 1px solid var(--gold);
}

.btn--gold:hover {
    background: #C49B38;
    border-color: #C49B38;
    color: #FFFFFF;
}

.btn--sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
}

.btn--lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
}

.btn--block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn svg {
    width: 16px;
    height: 16px;
}


/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
}

.badge--green {
    background: var(--accent-surface);
    color: var(--accent);
}

.badge--gold {
    background: var(--gold-light);
    color: var(--gold-text);
}

.badge--gray {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge--accent {
    background: var(--accent);
    color: var(--text-inverse);
}

.badge--win {
    background: #D1E7DD;
    color: #0F5132;
}

.badge--place {
    background: #CFF4FC;
    color: #055160;
}

.badge--show {
    background: #FFF3CD;
    color: #664D03;
}

.badge--loss {
    background: #E9ECEF;
    color: #495057;
}

.badge--dnf {
    background: #F8D7DA;
    color: #842029;
}


/* --- Form Dots (horse recent form visualization) --- */
.form-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.form-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
    cursor: default;
}

.form-dot--win {
    background: var(--color-win);
}

.form-dot--place {
    background: var(--color-place);
}

.form-dot--show {
    background: var(--color-show);
}

.form-dot--mid {
    background: #FD7E14;
}

.form-dot--loss {
    background: var(--color-loss);
}

.form-dot--dnf {
    background: var(--color-dnf);
}

.form-dot[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 6px;
    background: var(--text-primary);
    color: var(--text-inverse);
    font-size: 10px;
    font-family: var(--font-mono);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.form-dot:hover[data-tip]::after {
    opacity: 1;
}


/* --- Data Tables (desktop) --- */
.data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    font-size: var(--text-sm);
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    background: var(--bg-tertiary);
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table th--right,
.data-table td--right {
    text-align: right;
}

.data-table th--center,
.data-table td--center {
    text-align: center;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-hover-row);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* CRI pick row highlight */
.data-table tr--pick {
    border-left: 3px solid var(--accent);
}

.data-table tr--pick td:first-child {
    padding-left: calc(var(--space-4) - 3px);
}

/* Monospace cells for numbers */
.data-table .cell-mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

/* Horse name cell */
.data-table .cell-horse {
    font-weight: 600;
}

.data-table .cell-horse a {
    color: var(--text-primary);
    text-decoration: none;
}

.data-table .cell-horse a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Position cell */
.cell-pos {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    min-width: 36px;
}

.cell-pos--1 { color: var(--color-win); }
.cell-pos--2 { color: var(--color-place); }
.cell-pos--3 { color: var(--color-show); }
.cell-pos--dnf { color: var(--color-dnf); }


/* --- Stat Cards --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    text-align: center;
}

.stat-card__value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-2);
}

.stat-card__value--accent {
    color: var(--accent);
}

.stat-card__label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


/* --- Pills / Stat Inline --- */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-pill__number {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
}


/* --- Filter Tabs --- */
.filter-tabs {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.filter-tab {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.filter-tab:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-tab--active {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}


/* --- Race Card Accordion --- */
.race-accordion {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.race-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.race-row:hover {
    border-color: var(--border-hover);
}

.race-row__header {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    gap: var(--space-4);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.race-row__number {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-surface);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.race-row__info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    min-width: 0;
}

.race-row__detail {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.race-row__detail svg {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
}

.race-row__detail--purse {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

.race-row__entries {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.race-row__toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.race-row__toggle svg {
    width: 18px;
    height: 18px;
}

.race-row.expanded .race-row__toggle {
    transform: rotate(180deg);
}

.race-row__body {
    display: none;
    border-top: 1px solid var(--border);
}

.race-row.expanded .race-row__body {
    display: block;
}

.race-row__conditions {
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}


/* --- Horse Entry Row (inside race card) --- */
.entry-row {
    display: grid;
    grid-template-columns: 36px 1fr auto auto auto auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
    transition: background 0.1s ease;
}

.entry-row:last-child {
    border-bottom: none;
}

.entry-row:hover {
    background: var(--bg-hover-row);
}

.entry-row--pick {
    background: var(--accent-surface);
    border-left: 3px solid var(--accent);
}

.entry-row__pp {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.entry-row__horse {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.entry-row__name {
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-row__name:hover {
    color: var(--accent);
}

.entry-row__sub {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.entry-row__form {
    display: flex;
    gap: 3px;
}

.entry-row__jockey {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    min-width: 80px;
}

.entry-row__weight {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
}

.entry-row__odds {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
    text-align: right;
}


/* --- Distance Chart Bars --- */
.distance-chart {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.distance-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.distance-bar__label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

.distance-bar__track {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.distance-bar__fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.distance-bar__fill--wins {
    background: var(--color-win);
}

.distance-bar__fill--starts {
    background: var(--accent-light);
}

.distance-bar__stat {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 120px;
}

.distance-bar__stat strong {
    color: var(--text-primary);
}

.distance-bar--best .distance-bar__label {
    color: var(--accent);
    font-weight: 700;
}

.distance-bar--best .distance-bar__stat {
    color: var(--accent);
}


/* --- Confidence Bar --- */
.confidence-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.confidence-bar__track {
    width: 80px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-bar__fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.confidence-bar__value {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-primary);
    min-width: 36px;
}


/* --- Tabs --- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    background: none;
}

.tab:hover {
    color: var(--text-primary);
}

.tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-panel {
    display: none;
    padding-top: var(--space-5);
}

.tab-panel.active {
    display: block;
}


/* --- Forms / Inputs --- */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(15, 81, 50, 0.12);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input--lg {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-lg);
}

.form-input--search {
    padding-left: var(--space-12);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23868E96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: var(--space-4) center;
}


/* --- Hero Search (homepage) --- */
.hero-search {
    padding: var(--space-16) 0 var(--space-12);
    text-align: center;
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border);
}

.hero-search__title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    letter-spacing: -0.02em;
}

.hero-search__subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
}

.hero-search__input-wrap {
    max-width: 580px;
    margin: 0 auto var(--space-6);
    position: relative;
}

.hero-search__input {
    width: 100%;
    padding: var(--space-4) var(--space-5) var(--space-4) 52px;
    font-size: 18px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: var(--text-primary);
}

.hero-search__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(15, 81, 50, 0.08);
}

.hero-search__input::placeholder {
    color: var(--text-tertiary);
}

.hero-search__icon {
    position: absolute;
    left: var(--space-5);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.hero-search__icon svg {
    width: 20px;
    height: 20px;
}

.hero-search__pills {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}


/* --- Race Day Banner --- */
.raceday-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    background: var(--accent);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.raceday-banner__text {
    font-size: var(--text-base);
    font-weight: 600;
}

.raceday-banner__detail {
    font-size: var(--text-sm);
    opacity: 0.9;
}

.raceday-banner .btn {
    background: rgba(255,255,255,0.15);
    color: var(--text-inverse);
    border: 1px solid rgba(255,255,255,0.3);
}

.raceday-banner .btn:hover {
    background: rgba(255,255,255,0.25);
    color: var(--text-inverse);
}


/* --- Quick Intelligence Grid --- */
.intel-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
}

.intel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
}

.intel-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.intel-card__title {
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.intel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
}

.intel-item:last-child {
    border-bottom: none;
}

.intel-item__rank {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    width: 20px;
}

.intel-item__name {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: 500;
    margin-left: var(--space-2);
}

.intel-item__name a {
    color: var(--text-primary);
}

.intel-item__name a:hover {
    color: var(--accent);
}

.intel-item__value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--accent);
}


/* --- Locked Content / Premium --- */
.locked-overlay {
    position: relative;
    overflow: hidden;
}

.locked-overlay__blur {
    filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

.locked-overlay__cta {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(248, 249, 250, 0.85);
    gap: var(--space-3);
    text-align: center;
    padding: var(--space-5);
}

.locked-overlay__cta svg {
    width: 32px;
    height: 32px;
    color: var(--gold);
}

.locked-overlay__text {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}


/* --- Page Header --- */
.page-header {
    padding: var(--space-8) 0 var(--space-6);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-6);
}

.page-header__title {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-2);
}

.page-header__subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
}


/* --- Footer --- */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: var(--space-8) 0;
    margin-top: var(--space-16);
}

.footer__inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.footer__brand {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--accent);
}

.footer__links {
    display: flex;
    gap: var(--space-5);
}

.footer__link {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.footer__link:hover {
    color: var(--text-secondary);
}

.footer__copy {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}


/* --- Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-center { text-align: center; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hidden { display: none !important; }

/* Grid system */
.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }


/* --- Horse Profile Specific --- */
.horse-profile-layout {
    display: block;
}

.horse-profile-sidebar {
    display: block;
}

.horse-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-6);
}

.horse-header__stats {
    display: block;
}

.horse-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
}


/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-fade-up {
    animation: fadeUp 0.4s ease;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, #E9ECEF 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton--text {
    height: 14px;
    width: 80%;
    margin-bottom: var(--space-2);
}

.skeleton--title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton--card {
    height: 120px;
}


/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}
