/* ==================== VISUAL REFRESH (2026-10) ====================
 * Loaded after all other stylesheets. Modernises the shell and shared components
 * without touching markup/JS behaviour. Remove the <link> in index.html to roll back.
 *
 * Idea: scoreboard typography. Saira (semi-condensed, tabular figures) for headings,
 * countdowns, years and times; everything else stays calm. Filled cyan always
 * carries navy ink (--on-primary) for sunlight-proof contrast.
 */

/* ==================== TYPOGRAPHY ==================== */
.section-title,
.card-title,
.empty-title,
.event-title,
.event-name-large,
.event-card-title,
.hero-event-name,
.logo-text,
.overlay-content h2,
.main-content h1,
.main-content h2 {
    font-family: var(--font-display);
    font-stretch: 92%;
    letter-spacing: -0.005em;
}

.section-title {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: var(--line-height-tight);
}

.logo-text {
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0;
}

/* Numbers that people compare at a glance: years, countdowns, times, points */
.event-year,
.event-countdown-badge,
.hero-countdown,
.stat-value,
.results-count,
.pro-badge-nav,
.times-badge {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
}

.event-year {
    font-weight: 800;
    font-stretch: 88%;
}

.section-link,
.section-action {
    color: var(--primary-text);
    font-weight: 600;
}

/* ==================== HEADER (glass) ==================== */
.app-header {
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid var(--border-light);
    box-shadow: none;
}

.header-content {
    min-height: 60px;
}

.app-header .icon-btn {
    border-radius: var(--radius-full);
}

/* Admin badge was white on orange (2.1:1) */
#admin-mode-badge {
    color: var(--brand-ink) !important;
    border-radius: var(--radius-full) !important;
}

/* ==================== BOTTOM NAV (glass + active pill) ==================== */
.bottom-nav {
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -8px 24px rgba(var(--shadow-color), 0.06);
    padding: 6px 0;
    padding-bottom: calc(6px + var(--safe-bottom));
}

.nav-item,
.nav-slot {
    min-height: 52px;
}

.nav-slot {
    position: relative;
    display: flex;
}

.nav-slot > .nav-item {
    flex: 1;
}

.nav-item {
    isolation: isolate;
    padding: 4px 0;
    gap: 2px;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--primary-text);
}

/* Pill behind the active icon instead of the thin top bar */
.nav-item.active::before {
    top: 2px;
    width: 60px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    z-index: -1;
    transition: background var(--transition-base);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-top: 6px;
}

.pro-badge-nav {
    top: 0;
    background: var(--gold);
    color: var(--brand-ink);
    font-size: 0.5625rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: var(--radius-full);
    box-shadow: none;
}

/* Best-times button: sits beside the profile icon, inside the nav cell */
.times-badge {
    top: 2px;
    right: auto;
    left: calc(50% + 12px);
    width: 26px;
    height: 26px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 5px;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm);
    z-index: 1;
}

/* Larger invisible tap area */
.times-badge::before {
    content: '';
    position: absolute;
    inset: -9px;
}

.times-badge svg {
    width: 12px;
    height: 12px;
}

.times-badge.has-times,
.times-badge.has-times:hover,
.times-badge.has-times:active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--surface);
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    background: var(--primary-gradient);
    color: var(--on-primary);
    font-weight: 700;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glow);
    min-height: 44px;
}

.btn-primary:hover {
    background: var(--primary-gradient);
    filter: brightness(1.05);
    transform: none;
}

.btn-primary:active {
    transform: scale(0.97);
    filter: brightness(0.97);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    font-weight: 600;
    min-height: 44px;
}

.btn-secondary:active {
    transform: scale(0.97);
}

.back-btn {
    color: var(--primary-text);
    min-height: 40px;
    padding: 8px 12px 8px 6px;
}

.back-btn:hover {
    background: var(--primary-soft);
    color: var(--primary-text);
}

.scroll-to-top-btn {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: var(--shadow-glow);
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
}

.scroll-to-top-btn:hover {
    background: var(--primary);
    filter: brightness(1.05);
}

@media (max-width: 768px) {
    .scroll-to-top-btn {
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px);
    }
}

/* ==================== FILTER TABS & CHIPS ==================== */
.filter-tab {
    border-radius: var(--radius-full);
    min-height: 40px;
    padding: 8px 18px;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-tab.active,
.filter-tab.active:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    color: var(--on-primary);
}

.filter-chip {
    min-height: 36px;
    border-radius: var(--radius-full);
}

/* ==================== CARDS ==================== */
.card {
    border-radius: var(--radius-lg);
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .card {
    border-color: var(--border);
}

/* Hover lift only where a pointer can hover; touch gets a press response instead */
.card:hover {
    transform: none;
}

@media (hover: hover) {
    .card-clickable:hover,
    .event-card .card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
}

.card-clickable:active,
.upcoming-event-card:active,
.upcoming-event-card-featured:active,
.quick-action-card:active {
    transform: scale(0.985);
}

.upcoming-event-card,
.upcoming-event-card-featured {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ==================== QUICK ACTIONS ==================== */
/* .quick-actions prefix: home.js injects its own <style> after this file */
.quick-actions .quick-action-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md) var(--spacing-sm);
    gap: 2px;
    box-shadow: var(--shadow-sm);
    min-height: 112px;
}

[data-theme="dark"] .quick-actions .quick-action-card {
    border-color: var(--border);
    background: linear-gradient(160deg, var(--surface-elevated) 0%, var(--surface) 70%);
}

/* Icon on a tinted tile (halo via box-shadow - padding on <svg> is unreliable) */
.quick-actions .quick-action-card > svg {
    width: 22px;
    height: 22px;
    margin: 10px 0 18px;
    border-radius: 4px;
    background: var(--primary-soft);
    box-shadow: 0 0 0 11px var(--primary-soft);
    color: var(--primary-text);
}

/* Live tiles keep their red signal colour on a matching tint */
.quick-actions .quick-action-card > svg[style*="FF0000"] {
    background: rgba(255, 0, 0, 0.1);
    box-shadow: 0 0 0 11px rgba(255, 0, 0, 0.1);
}

@media (hover: hover) {
    .quick-actions .quick-action-card:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow-md);
    }
}

/* ==================== COUNTDOWN & BADGES ==================== */
.event-countdown-badge {
    background: var(--primary-soft);
    color: var(--primary-text);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 5px 12px;
    border-radius: 0 0 var(--radius-md) 0;
}

.event-countdown-badge.countdown-upcoming {
    background: var(--primary-soft);
    color: var(--primary-text);
}

.event-countdown-badge.countdown-soon {
    background: var(--gold);
    color: var(--brand-ink);
}

.event-countdown-badge.countdown-today,
.youtube-broadcast-card .youtube-countdown-badge {
    background: var(--error) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .event-countdown-badge.countdown-today,
[data-theme="dark"] .youtube-broadcast-card .youtube-countdown-badge {
    color: #2A0612 !important;
}

.badge {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

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

.badge-info,
[data-theme="dark"] .badge-info {
    background: var(--info-light);
    color: var(--info);
}

/* ==================== OVERLAYS / MODALS ==================== */
.overlay {
    background: var(--overlay);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: max(16px, var(--safe-top)) 16px max(16px, var(--safe-bottom));
}

.overlay-content {
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-xl);
}

[data-theme="dark"] .overlay-content {
    border-color: var(--border);
}

/* ==================== MENU ==================== */
.menu-item {
    border-radius: var(--radius-md);
    min-height: 48px;
}

.menu-item.active {
    color: var(--primary-text);
    background: var(--primary-soft);
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    padding: var(--spacing-xl) var(--spacing-md);
}

.empty-icon {
    width: 64px;
    height: 64px;
    padding: 14px;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary-text);
    opacity: 1;
}

/* ==================== SKELETON ==================== */
.skeleton {
    border-radius: var(--radius-lg);
}

/* ==================== SEARCH ==================== */
.search-input {
    border-radius: var(--radius-full);
    min-height: 48px;
}

/* ==================== CONTRAST FIXES FOR INLINE STYLES ====================
 * Many templates in js/ set colours inline. Instead of editing ~100 templates,
 * these attribute selectors correct the two weak combinations globally.
 */

/* Cyan used as text colour: too light on white (2.4:1) - use the text-safe cyan in light mode */
:root:not([data-theme="dark"]) [style^="color: var(--primary)"],
:root:not([data-theme="dark"]) [style*=" color: var(--primary)"],
:root:not([data-theme="dark"]) [style*=";color: var(--primary)"] {
    color: var(--primary-text) !important;
}

/* White text on filled cyan (2.5:1) - navy ink instead */
[style*="background: var(--primary)"][style*="color: white"],
[style*="background: var(--primary)"][style*="color: #fff"],
[style*="background: var(--primary)"][style*="color: #FFF"],
[style*="background: var(--primary)"][style*="color: #ffffff"],
[style*="background: var(--primary)"][style*="color: #FFFFFF"] {
    color: var(--on-primary) !important;
}

/* Same rule for stylesheet components with white text on cyan */
.athlete-avatar,
.search-mode-tab.active,
.filter-chip.active,
.hero-countdown-soon,
.hero-btn-primary,
.pdf-info-open-btn,
.pwa-install-floating-btn,
.instruction-steps li::before,
.update-banner-icon,
.update-btn-primary {
    color: var(--on-primary);
}

.hero-btn-primary,
.update-btn-primary {
    font-weight: 700;
}

/* ==================== RACE TIMES (scoreboard figures) ==================== */
[style*="font-family: var(--font-mono)"],
.stat-value,
.chrono-time-value {
    font-variant-numeric: tabular-nums;
    font-stretch: 92%;
    letter-spacing: 0.01em;
}

/* Livetiming used a bare 'monospace' */
[style*="font-family: monospace"] {
    font-family: var(--font-mono) !important;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ==================== EVENT MODAL HEADER ====================
 * Long single words ("Stadtmeisterschaften") must not run under the header buttons
 */
.event-modal-header h2 {
    overflow-wrap: break-word;
    hyphens: auto;
}

@media (max-width: 480px) {
    .event-modal-header h2 {
        font-size: 1.25rem !important;
    }
}

/* ==================== PRO BADGE (unified) ====================
 * The PRO badge is copied inline in ~10 templates with sizes from 0.45rem (7px) upward.
 * One look for all: brand gold pill, navy ink, readable minimum size.
 */
[style*="linear-gradient(135deg, #FFD700, #FFA500)"] {
    background: var(--gold) !important;
    color: var(--brand-ink) !important;
    font-family: var(--font-display);
    font-weight: 800 !important;
    font-size: 0.625rem !important;
    border-radius: var(--radius-full) !important;
    padding: 2px 6px !important;
    letter-spacing: 0.02em;
}
