/* --- Premium Modern Redesign - ATS Themed --- */
/* Design tokens: css/variables.css (loaded in header.php) */

/* --- Global Styles --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: 16px;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

main {
    padding: 2rem 0;
    min-height: calc(100vh - 160px); /* Adjust based on header/footer */
}

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

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

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--primary-dark);
    margin-top: 0;
    line-height: 1.2;
}

h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

/* --- Header --- */
.site-header {
    background: var(--primary-gradient);
    color: var(--text-on-primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid var(--accent-color);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo-area {
    display: flex;
    align-items: center;
    text-decoration: none;
    /* Take the room between the logo and the nav so the competition name fits */
    flex: 1 1 auto;
    min-width: 0;
    margin-right: 1rem;
}

.logo-area img {
    height: 40px;
    width: auto;
    margin-right: 1rem;
    flex-shrink: 0;
}

.logo-text {
    font-family: var(--font-display);
    /* Auto-fit: scale up to fill available room, ellipsis if too long */
    font-size: clamp(0.85rem, 3vw, 1.25rem);
    font-weight: 700;
    color: white;
    letter-spacing: 0.04em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Navigation */
.main-nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

.main-nav a {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
}

.main-nav a:hover, .main-nav a.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Hamburger for Mobile */
.hamburger-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    height: 20px;
    width: 24px;
    padding: 0;
}

.hamburger-menu span {
    display: block;
    height: 2px;
    width: 100%;
    background-color: white;
    border-radius: 2px;
}

/* Mobile Nav */
.mobile-nav {
    display: none;
    background-color: var(--primary-color);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-nav ul {
    list-style: none;
    padding: 1rem 1.5rem;
    margin: 0;
}

.mobile-nav li {
    margin-bottom: 0.5rem;
}

.mobile-nav a {
    display: block;
    color: white;
    font-size: 1.1rem;
    padding: 0.5rem 0;
}

/* --- Hero Section --- */
.intro-section {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--bg-card) 0%, #ffffff 100%);
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
}

.intro-section h1 {
    color: var(--primary-dark);
    margin-bottom: 0.75rem;
}

.intro-section p,
.intro-tagline {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    font-size: var(--text-base);
}

/* --- Card Grid System --- */
.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.event-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.25rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.event-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.event-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

.event-card:hover::before {
    transform: scaleX(1);
}

.event-card h3 {
    font-size: 1.05rem;
    line-height: 1.35;
    margin: 0 0 0.85rem;
    color: var(--primary-dark);
    font-family: var(--font-heading);
    font-weight: 700;
    /* Keep cards aligned regardless of title length (reserve 2 lines) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(1.05rem * 1.35 * 2);
}

.event-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.meta-icon {
    flex-shrink: 0;
    opacity: 0.9;
    font-size: 0.95rem;
    line-height: 1;
}

.btn-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin-top: auto;
    text-align: center;
    background-color: var(--bg-accent-tint);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid transparent;
}

.btn-card::after {
    content: '\2192';
    font-size: 1.05em;
    line-height: 1;
    transition: transform 0.2s ease;
}

.event-card:hover .btn-card {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.event-card:hover .btn-card::after {
    transform: translateX(4px);
}

/* --- Results Page Header --- */
.results-header-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--accent-color);
    transform: translateX(-4px);
}

/* --- Search Bar --- */
.search-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 2rem;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    font-size: 1rem;
    border: 2px solid var(--border-subtle);
    border-radius: 8px;
    background-color: white;
    transition: all 0.2s ease;
    font-family: var(--font-body);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 71, 42, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* --- Footer --- */
.site-footer {
    background-color: var(--primary-dark);
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
    border-top: 3px solid var(--accent-color);
}

.footer-links  {
    margin-bottom: 1rem;
}

.footer-links a {
    color: white;
    margin: 0 0.75rem;
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .main-nav { display: none; }
    .hamburger-menu { display: flex; }
    
    .mobile-nav.active { display: block; }

    .header-container { padding: 0 0.75rem; height: 50px; }

    .logo-area img {
        height: 30px;
        margin-right: 0.5rem;
    }

    .logo-text {
        /* Competition name fills the room between logo and menu button */
        font-size: clamp(0.8rem, 3.4vw, 1.05rem);
        letter-spacing: 0.03em;
        max-width: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    h1 { font-size: 1.2rem; }
    
    .event-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Auto Refresh Badge --- */
.refresh-badge {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: rgba(255, 255, 255, 0.85);
    padding: 12px;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    font-size: 1.25rem;
    color: var(--primary-color);
    z-index: 999;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-badge:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.refresh-badge.refreshing {
    animation: spin 1s linear infinite;
    background: var(--primary-color);
    color: white;
    border-color: transparent;
}

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

@media print { 
    .refresh-badge { display: none; } 
}

/* --- Shared utilities (used across PHP templates) --- */
.font-headline {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.intro-section-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.year-filter-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.year-filter-form label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.year-filter-form select {
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--text-main);
    background: var(--bg-card);
    cursor: pointer;
}

.year-filter-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.no-events {
    text-align: center;
    grid-column: 1 / -1;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-events-card {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

.no-events-card p {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    margin: 0;
}

.results-button,
.results-button-small {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    background: var(--primary-gradient);
    color: var(--text-on-primary) !important;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.results-button-small {
    padding: 0.4rem 0.875rem;
    font-size: var(--text-xs);
}

.results-button:hover,
.results-button-small:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: var(--primary-gradient-soft);
    color: var(--text-on-primary) !important;
}

.control-panel {
    max-width: 700px;
    margin: 0 auto 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--gold-soft);
    border: 1px solid #fcd34d;
    border-radius: var(--radius-md);
}

.control-panel h3 {
    margin: 0 0 0.75rem;
    font-size: var(--text-sm);
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-panel-actions {
    margin-top: 0.75rem;
    text-align: right;
}

.info-text {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.error-message {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.success-message {
    background: var(--bg-accent-tint);
    color: var(--primary-color);
    border: 1px solid #a7d7b5;
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

#back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-pill);
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    z-index: 900;
    font-size: 1.25rem;
    line-height: 1;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* --- PWA Install Prompt --- */
.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 150%);
    width: 90%;
    max-width: 400px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
}

.pwa-install-prompt.active {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.pwa-install-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pwa-install-icon {
    display: flex;
    justify-content: center;
}

.pwa-install-icon img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.pwa-install-text {
    text-align: center;
}

.pwa-install-text strong {
    display: block;
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.pwa-install-text p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pwa-install-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.pwa-btn {
    flex: 1;
    padding: 0.6rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.pwa-btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.pwa-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.pwa-btn-secondary {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.pwa-btn-secondary:hover {
    background: var(--bg-accent-tint);
    color: var(--primary-dark);
}
