/* ==========================================================================
   Wrapper CSS – combined layout + SPORTSYSTEMS table class overrides
   ========================================================================== */

/* ── Reset & box-sizing ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* ── Site header (visible on all sizes) ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    height: 3.5rem;
}

.site-header .header-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.header-logo {
    height: 2.25rem;
    width: auto;
    flex-shrink: 0;
}

.event-title {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* ── Hamburger button ── */
.nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 0.25rem;
    position: relative;
    z-index: 120;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    display: block;
    width: 1.25rem;
    height: 2px;
    border-radius: 1px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
}

.hamburger::before { transform: translateY(-6px); }
.hamburger::after  { transform: translateY(6px); }

/* Animate to X when open */
.nav-open .hamburger { background-color: transparent !important; }
.nav-open .hamburger::before { transform: rotate(45deg); }
.nav-open .hamburger::after  { transform: rotate(-45deg); }

/* ── Overlay ── */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #00000073;
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 3.5rem;
    left: 0;
    bottom: 0;
    width: min(380px, 90vw);
    z-index: 95;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-inner {
    padding: 1rem;
    padding-bottom: 3rem;
}

/* ── Main content ── */
.content {
    flex: 1;
    padding: 1rem;
    overflow-x: auto;
    min-width: 0;
}

/* Welcome / default state */
.content .welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    padding: 2rem;
}

.welcome-logo {
    max-width: 280px;
    height: auto;
    margin-bottom: 1.5rem;
}

.content .welcome h2 {
    margin-bottom: 3rem;
}

/* ── Mobile menu hint (hidden on desktop where sidebar is always visible) ── */
.mobile-hint {
    display: none;
}

@media (max-width: 767px) {
    .mobile-hint {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        margin-top: 1.25rem;
        font-size: 0.85rem;
        opacity: 0.7;
    }
}

.mobile-hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.15);
    vertical-align: middle;
    font-size: 1rem;
    line-height: 1;
}

/* ── Responsive tables ── */
.content table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* On small screens, make result tables horizontally scrollable */
@media (max-width: 767px) {
    .content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
}

/* ── Desktop layout (>= 768px) ── */
@media (min-width: 768px) {
    body {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .site-header {
        width: 100%;
        flex-shrink: 0;
    }

    .nav-toggle {
        display: none;
    }

    .nav-overlay {
        display: none !important;
    }

    .sidebar {
        position: sticky;
        top: 3.5rem;
        height: calc(100vh - 3.5rem);
        transform: none;
        flex-shrink: 0;
        width: 380px;
    }

    .content {
        flex: 1;
        min-width: 0;
        max-width: calc(100% - 380px);
        padding: 1.5rem 2rem;
    }
}

/* ── Large desktop (>= 1200px) ── */
@media (min-width: 1200px) {
    .sidebar {
        width: 400px;
    }

    .content {
        max-width: calc(100% - 400px);
    }
}

/* ── Sidebar internal layout overrides ── */
.sidebar table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    border-radius: 0.4rem;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

/* Event menu tables (3-col): override inline widths so columns size to content */
.sidebar table td:nth-child(3) ~ td,
.sidebar table td:first-child:nth-last-child(n+3),
.sidebar table td:first-child:nth-last-child(n+3) ~ td:not(:first-child) {
    width: auto !important;
}

/* First column (event name): allow wrapping to prevent horizontal overflow */
.sidebar table td:first-child:nth-last-child(n+3) {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 3-col tables: shrink link columns, stay centred */
.sidebar table td:first-child:nth-last-child(n+3) ~ td {
    white-space: nowrap;
    width: 1% !important;
    text-align: center;
}

/* 2-col tables (PDFs): equal-width cells, centred, with vertical divider */
.sidebar table td:first-child:nth-last-child(2),
.sidebar table td:first-child:nth-last-child(2) ~ td {
    width: 50% !important;
    text-align: center;
}

.sidebar table td.t1_centre + td.t1_centre,
.sidebar table td.t4_centre + td.t4_centre {
    border-left: 1px solid var(--sidebar-row-border, #dddddd);
}

.sidebar-logo {
    text-align: center;
    padding: 0.75rem 0 0.5rem;
}

.sidebar-logo-img {
    max-width: 200px;
    height: auto;
}

.sidebar h2, .sidebar h3 {
    text-align: center;
}

.sidebar img {
    max-width: 100%;
    height: auto;
}

.sidebar h5 {
    text-align: center;
    padding: 1rem 0;
}

/* Utility: hide the base target tag effect */
.sidebar base {
    display: none;
}

/* ==========================================================================
   SPORTSYSTEMS table class overrides
   (base classes are in style.css; these ensure font-family inherits cleanly)
   ========================================================================== */

h1, h2, h3 { text-align: center; }

td.t2 { font-family: inherit; font-size: 76%; font-weight: bold; text-align: center; vertical-align: middle; }

td.t1_left   { font-family: inherit; font-size: 76%; text-align: left;   vertical-align: middle; }
td.t1_right  { font-family: inherit; font-size: 76%; text-align: right;  vertical-align: middle; }
td.t1_centre { font-family: inherit; font-size: 76%; text-align: center; vertical-align: middle; }
td.t1_split  { font-family: inherit; font-size: 58%; text-align: right;  vertical-align: middle; }

td.t4_left   { font-family: inherit; font-size: 76%; text-align: left;   vertical-align: middle; }
td.t4_right  { font-family: inherit; font-size: 76%; text-align: right;  vertical-align: middle; }
td.t4_centre { font-family: inherit; font-size: 76%; text-align: center; vertical-align: middle; }
td.t4_split  { font-family: inherit; font-size: 58%; text-align: right;  vertical-align: middle; }

td.t5_left   { font-family: inherit; font-size: 66%; text-align: left;   vertical-align: middle; }
td.t5_right  { font-family: inherit; font-size: 66%; text-align: right;  vertical-align: middle; }
td.t5_centre { font-family: inherit; font-size: 66%; text-align: center; vertical-align: middle; }

td.t6_left   { font-family: inherit; font-size: 66%; text-align: left;   vertical-align: middle; }
td.t6_right  { font-family: inherit; font-size: 66%; text-align: right;  vertical-align: middle; }
td.t6_centre { font-family: inherit; font-size: 66%; text-align: center; vertical-align: middle; }

a:link { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================================
   Delight – animations, transitions, live indicator
   ========================================================================== */

/* ── Content fade-in on page load ── */
@keyframes contentSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-enter {
    animation: contentSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Loading shimmer while fetching ── */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.content-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.content-loading::after {
    content: '';
    display: block;
    width: 200px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, #e0e0e0 25%, #cfcfcf 50%, #e0e0e0 75%);
    background-size: 400px 4px;
    animation: shimmer 1.2s ease-in-out infinite;
}


/* ── Sidebar link hover energy ── */
.sidebar table tr {
    position: relative;
    transition: transform 0.15s ease;
}

.sidebar table tr:hover {
    transform: translateX(2px);
}

/* ── Welcome state water ripple ── */
@keyframes ripple {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.15; }
    50% { opacity: 0.06; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.welcome {
    position: relative;
    overflow: hidden;
}

.welcome::before,
.welcome::after {
    content: '';
    position: absolute;
    top: 60%;
    left: 50%;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    pointer-events: none;
    animation: ripple 4s ease-out infinite;
}

.welcome::after {
    animation-delay: 2s;
}

/* ── Respect reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .content-enter {
        animation: none;
        opacity: 1;
    }

    .content-loading::after {
        animation: none;
    }

    .sidebar table tr:hover {
        transform: none;
    }

    .welcome::before,
    .welcome::after {
        animation: none;
    }
}
