:root {
    --page-background: #f4f6fb;
    --surface: #ffffff;
    --text: #1f2933;
    --muted-text: #6b7280;
    --border: #e6e8ee;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eaf1ff;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 12px;
    --content-width: 760px;
    --time-font: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--page-background);
    line-height: 1.55;
}

/* Header */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.site-title {
    display: inline-block;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}

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

/* Layout */

.site-main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.site-footer {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
    color: var(--muted-text);
    font-size: 0.85rem;
}

.site-footer a {
    color: inherit;
}

h2 {
    margin: 2.25rem 0 0.75rem;
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

/* Holding page */

.holding-notice h1 {
    margin: 0 0 0.75rem;
    font-size: 1.3rem;
    font-weight: 650;
}

.holding-notice p {
    margin: 0;
    line-height: 1.6;
}

/* Forms */

.field-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-text);
}

.search-form,
.event-form,
.holding-notice {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.search-row {
    display: flex;
    gap: 0.6rem;
}

input[type="text"],
select {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"] {
    flex: 1;
    min-width: 0;
}

select {
    width: 100%;
    cursor: pointer;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
    font: inherit;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.1rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

button:hover {
    background: var(--accent-hover);
}

/* Live search dropdown */

.search-field {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-field input[type="text"] {
    width: 100%;
}

.search-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 10;
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.search-suggestions[hidden] {
    display: none;
}

.search-suggestions li + li {
    border-top: 1px solid var(--border);
}

.search-suggestions a {
    display: block;
    padding: 0.7rem 1.1rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.search-suggestions a:hover {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

/* Search results */

.result-list {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.result-list li + li {
    border-top: 1px solid var(--border);
}

.result-list a {
    display: block;
    padding: 0.85rem 1.1rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.result-list a:hover {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.empty-message {
    color: var(--muted-text);
}

.build-number {
    font-size: 0.7rem;
    color: var(--muted-text);
}

/* Competitor identity */

.competitor {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.competitor-identity {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.competitor-name {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* The name links back up to the competitor's overview. */
.competitor-name a {
    color: inherit;
    text-decoration: none;
}

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

.competitor-meta {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    margin: 0.3rem 0 0;
    color: var(--muted-text);
    font-size: 0.95rem;
}

.competitor-id {
    font-family: var(--time-font);
    letter-spacing: 0.02em;
}

.profile-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.profile-link:hover {
    text-decoration: underline;
}

.profile-link::before {
    content: "·";
    /* inline-block keeps the separator out of the link's hover underline. */
    display: inline-block;
    margin-right: 0.55rem;
    color: var(--border);
}

.external-icon {
    font-size: 0.85em;
}

/* Navigation links */

.new-search {
    margin: 0;
    white-space: nowrap;
}

.new-search a {
    display: inline-block;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent);
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    text-decoration: none;
    transition: background 0.15s ease;
}

.new-search a:hover {
    background: var(--accent-hover);
}

/* Chart */

.chart-title {
    margin: 1.5rem 0 0.75rem;
}

.chart-subtitle {
    margin: -0.5rem 0 0.75rem;
    color: var(--muted-text);
    font-size: 0.9rem;
}

.chart-legend-hint {
    margin: 0.5rem 0 0;
    text-align: center;
    color: var(--muted-text);
    font-size: 0.8rem;
}

.chart-card {
    margin-top: 0;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-wrap {
    position: relative;
    height: 360px;
}

.chart-controls {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.chart-reset {
    font-size: 0.85rem;
    padding: 0.35rem 0.85rem;
    color: var(--accent);
    background: var(--accent-soft);
}

.chart-reset:hover {
    background: var(--accent-soft);
    filter: brightness(0.96);
}

.chart-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.65);
    border-radius: var(--radius);
}

.chart-loading.is-loading {
    display: flex;
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton placeholder rows shown while the overview fetches its per-event data */

.skeleton {
    display: block;
    height: 1rem;
    border-radius: var(--radius);
    background: linear-gradient(
        90deg,
        var(--border) 25%,
        var(--accent-soft) 37%,
        var(--border) 63%
    );
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

@keyframes skeleton-shimmer {
    from {
        background-position: 100% 0;
    }
    to {
        background-position: 0 0;
    }
}

/* Progression tables, side by side */

.progressions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
    /* Match the breathing room .chart-title gives the Consistency heading. */
    margin-top: 1.5rem;
}

.progression h2 {
    margin-top: 0;
}

@media (max-width: 560px) {
    .progressions {
        grid-template-columns: 1fr;
    }

    .competitor-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .profile-link::before {
        content: none;
    }
}

/* Tables */

.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

thead th {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-text);
    background: #fafbfd;
    padding: 0.7rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.7rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
    background: var(--accent-soft);
}

/* Times read best right-aligned and monospaced */

thead th:last-child,
tbody td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--time-font);
}

/* PR map */

.map-wrap {
    position: relative;
}

#pr-map,
#overview-map {
    height: 400px;
    border-radius: calc(var(--radius) - 4px);
    z-index: 0;
}

.map-legend {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.6rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.875rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s ease;
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Overview table: its cells hold ages as words, not times, so keep every column
   left-aligned in the body font, and let the event name link into that event. */
.overview-table thead th:last-child,
.overview-table tbody td:last-child {
    text-align: left;
    font-variant-numeric: normal;
    font-family: inherit;
}

.overview-table tbody td:first-child a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.overview-table tbody td:first-child a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Stretched link: the event <a> expands via ::after to cover the whole row,
   making the entire row a click target without duplicating the href. */
.overview-table tbody tr {
    position: relative;
}

.overview-table tbody td:first-child a::after {
    content: '';
    position: absolute;
    inset: 0;
}

/* Chevron navigation column */
.overview-table .row-nav {
    width: 2rem;
    text-align: right;
    color: var(--muted-text);
    padding-right: 1.1rem;
}

.overview-table thead th:last-child {
    width: 2rem;
}

