/**
 * Start.gg Tournament Events Styles
 * Bakersfield eSports - 2025
 */

/* ============================================
   TOURNAMENT SECTION
   ============================================ */

.startgg-tournaments-section {
    padding: 3em 0;
    background-color: var(--darker-bg);
}

.startgg-tournaments-section h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5em;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.startgg-tournaments-section .section-description {
    text-align: center;
    margin-bottom: 2em;
    opacity: 0.9;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   EVENTS CONTAINER
   ============================================ */

#startgg-events-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2em;
    margin-bottom: 2em;
}

/* Loading state */
#startgg-events-container[aria-busy="true"] {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 3em 0;
}

/* ============================================
   EVENT CARD
   ============================================ */

.startgg-event {
    background-color: var(--dark-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(236, 25, 77, 0.2);
}

.startgg-event:hover {
    transform: translateY(-8px);
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(236, 25, 77, 0.3);
    border-color: rgba(236, 25, 77, 0.5);
}

.startgg-event:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
}

/* Event image */
.startgg-event img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
}

/* Event info */
.startgg-event .event-info {
    padding: clamp(1rem, 3vw, 1.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.75em;
    flex-grow: 1;
}

.startgg-event h3 {
    color: var(--primary-color);
    margin: 0;
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.startgg-event .event-game {
    color: var(--light-color);
    margin: 0;
    font-size: clamp(0.9rem, 2vw, 1rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.startgg-event .event-game strong {
    color: rgba(255, 255, 255, 0.7);
}

.startgg-event .event-datetime {
    color: var(--light-color);
    margin: 0;
    font-size: clamp(0.875rem, 2vw, 0.95rem);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.startgg-event .event-datetime strong {
    color: rgba(255, 255, 255, 0.7);
}

.startgg-event .event-entrants {
    color: var(--light-color);
    margin: 0;
    font-size: 0.95rem;
}

.startgg-event .event-entrants strong {
    color: rgba(255, 255, 255, 0.7);
}

/* Event badge (online indicator) */
.event-badge {
    display: inline-block;
    padding: 0.3em 0.8em;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5em;
    align-self: flex-start;
}

.event-badge.online {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

/* Registration section */
.event-registration {
    margin-top: auto;
    padding-top: 1em;
    border-top: 1px solid rgba(236, 25, 77, 0.2);
}

.registration-status {
    margin: 0 0 1em 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.registration-status.open {
    color: #10b981;
}

.registration-status.closed {
    color: #ef4444;
    opacity: 0.8;
}

.event-registration .btn {
    width: 100%;
    text-align: center;
    padding: 0.75em 1em;
    margin-bottom: 0.75em;
}

/* Event details link */
.event-details-link {
    display: block;
    text-align: center;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.3s;
}

.event-details-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   NO EVENTS MESSAGE
   ============================================ */

.no-events-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3em 2em;
    background: rgba(236, 25, 77, 0.1);
    border: 1px solid rgba(236, 25, 77, 0.3);
    border-radius: 12px;
}

.no-events-message p {
    margin: 0.5em 0;
    color: var(--light-color);
    font-size: 1.1rem;
}

.no-events-message a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
}

.no-events-message a:hover {
    opacity: 0.8;
}

/* ============================================
   LOADING STATE
   ============================================ */

.loading-tournaments {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4em 0;
}

.loading-tournaments .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(236, 25, 77, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1em;
}

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

.loading-tournaments p {
    font-size: 1.1rem;
    opacity: 0.7;
    color: var(--light-color);
}

/* ============================================
   ERROR MESSAGE
   ============================================ */

.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3em;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 12px;
    color: #ff6b6b;
}

.error-message p {
    margin: 0.5em 0;
}

.error-message a {
    color: var(--primary-color);
    font-weight: 600;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1200px) {
    #startgg-events-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.5em;
    }
}

@media (max-width: 768px) {
    #startgg-events-container {
        grid-template-columns: 1fr;
        gap: 1.5em;
    }

    .startgg-tournaments-section {
        padding: 2em 0;
    }

    .startgg-event img {
        height: 180px;
    }

    .startgg-event .event-info {
        padding: 1.2em;
    }

    .startgg-event h3 {
        font-size: 1.2rem;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header,
    .modal-body {
        padding: 1.5em;
    }

    .modal-game-image {
        height: 150px;
    }

    .info-item {
        flex-direction: column;
        gap: 0.5em;
    }

    .info-label {
        min-width: auto;
    }

    .registration-iframe {
        min-height: 500px;
    }
}

@media (max-width: 480px) {
    .startgg-event img {
        height: 150px;
    }

    .startgg-event .event-info {
        padding: 1em;
        gap: 0.5em;
    }

    .startgg-event h3 {
        font-size: 1.1rem;
    }

    .event-registration .btn {
        font-size: 0.95rem;
        padding: 0.6em 0.8em;
    }
}

/* ============================================
   TOURNAMENT MODAL
   ============================================ */

.tournament-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-tournament-modal-overlay);
    display: none;
    align-items: center;
    justify-content: center;
}

.tournament-modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: var(--dark-bg);
    border-radius: var(--radius-xl);
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(236, 25, 77, 0.3);
    z-index: var(--z-tournament-modal);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(236, 25, 77, 0.2);
    border: 1px solid var(--primary-color);
    color: var(--color-white);
    font-size: 2rem;
    width: 45px;
    height: 45px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-normal);
    z-index: var(--z-tournament-modal-close);
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    background: var(--primary-color);
    transform: rotate(90deg);
}

.modal-header {
    position: relative;
    padding: 2em;
    border-bottom: 1px solid rgba(236, 25, 77, 0.2);
}

.modal-game-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1.5em;
}

.modal-title-section h2 {
    color: var(--primary-color);
    margin: 0 0 0.5em 0;
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.modal-tournament-name {
    color: var(--light-color);
    opacity: 0.9;
    margin: 0;
    font-size: 1.1rem;
}

.modal-body {
    padding: 2em;
}

.modal-info {
    margin-bottom: 2em;
}

.info-item {
    display: flex;
    gap: 1em;
    padding: 0.75em 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-label {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 120px;
}

.info-value {
    color: var(--light-color);
    flex: 1;
}

.info-badge {
    margin-top: 1em;
}

.modal-registration {
    margin-top: 2em;
}

.modal-registration h3 {
    color: var(--primary-color);
    margin: 0 0 1em 0;
    font-size: 1.5rem;
}

#modal-registration-status {
    margin-bottom: 1.5em;
    padding: 1em;
    border-radius: 8px;
    font-weight: 600;
}

#modal-registration-status.open {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    color: #10b981;
}

#modal-registration-status.closed {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
}

.registration-frame-container {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(236, 25, 77, 0.2);
}

.registration-iframe {
    width: 100%;
    min-height: 600px;
    border: none;
    display: block;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
.startgg-event:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
}

/* Remove outline for mouse users */
.startgg-event:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .startgg-event,
    .loading-tournaments .spinner,
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
