/* ===== KsK Racing - Main Stylesheet ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --grad-start: #000000; --grad-end: #3600ad;
  --text: #ffffff; --text-dim: #afafaf;
  --container-bg: rgba(31, 0, 77, 0.75); --content-bg: rgba(0, 0, 0, 0.66);
  --border: rgba(227, 227, 227, 0.80); --accent: #4da6ff;
  --card-bg: rgba(31, 0, 77, 0.85); --card-hover: rgba(55, 10, 120, 0.9);
  --nav-bg: rgba(10, 0, 40, 0.85); --nav-hover-bg: rgba(95, 0, 204, 0.40);
  --nav-active-bg: rgba(200, 200, 200, 0.15);
  --btn-start: #3600ad; --btn-end: #5b2de0;
  --border-hover: rgba(77,166,255,0.3); --focus-glow: rgba(77,166,255,0.2);
  --glow-color: rgba(100,100,255,0.5); --glow-alt: #afafaf;
}

html { scroll-behavior: smooth; }
body {
  position: relative; z-index: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text); min-height: 100vh;
  background: #000;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background: linear-gradient(359deg, var(--grad-start), var(--grad-end));
  background-size: 400% 400%;
  animation: bgFlow 9s ease infinite;
  z-index: 1;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 100vh;
  background: url('/assets/images/logos/flag-bottom.png') bottom center / 100% auto no-repeat;
  z-index: 2;
  pointer-events: none;
}
@keyframes bgFlow {
  0% { background-position: 50% 0% }
  50% { background-position: 51% 100% }
  100% { background-position: 50% 0% }
}

/* ===== Animations ===== */
.animate-zoom { animation: zoomIn 0.6s ease-out; }
@keyframes zoomIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.textglow {
  text-shadow: 1px 1px 2px black, 0 0 20px var(--glow-color), 0 0 8px var(--glow-color);
  animation: textFade 9s ease infinite alternate;
}
@keyframes textFade {
  0%, 20%, 80%, 100% { color: #fff; } 40%, 60% { color: var(--glow-alt); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.5s ease-out forwards; }

/* ===== Top Navigation ===== */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 56px;
  background: var(--nav-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  transition: background 0.3s;
}
.nav-brand { display: flex; align-items: center; gap: 10px; cursor: pointer; flex-shrink: 0; }
.nav-logo { height: 36px; width: auto; }
.nav-title { font-size: 1.2em; font-weight: bold; font-style: italic; white-space: nowrap; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  color: var(--text); text-decoration: none; padding: 8px 14px;
  border-radius: 6px; font-size: 0.9em; transition: all 0.2s;
  white-space: nowrap;
}
/* .nav-links a:hover { background: rgba(255,255,255,0.12); color: var(--accent); } */
/* .nav-links a.active { background: rgba(77, 166, 255, 0.2); color: var(--accent); } */
/* .nav-links a:hover { background: rgba(255,255,255,0.12); color: #b366ff; } */
/* .nav-links a.active { background: rgba(200, 200, 200, 0.15); color: #b366ff; } */
/* .nav-links a:hover { background: rgba(255,255,255,0.10); color: #7002ed; } */
/* .nav-links a.active { background: rgba(200, 200, 200, 0.15); color: #e0e0e0; } */
.nav-links a:hover { background: var(--nav-hover-bg); color: #e0e0e0; }
.nav-links a.active { background: var(--nav-active-bg); color: #e0e0e0; }

/* Hamburger */
.hamburger {
  display: none; flex-direction: column; gap: 5px; background: none;
  border: none; cursor: pointer; padding: 8px; z-index: 1001;
}
.hamburger span { display: block; width: 24px; height: 2px; background: #fff; transition: all 0.3s; }
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Mobile Menu */
.mobile-menu {
  position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 999;
  background: var(--nav-bg); backdrop-filter: blur(15px);
  display: none; overflow-y: auto;
}
.mobile-menu.open { display: block; }
.mobile-menu-content { padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.mobile-menu-content a {
  color: var(--text); text-decoration: none; font-size: 1.2em;
  padding: 14px 20px; border-radius: 8px; transition: all 0.2s;
  display: flex; align-items: center; gap: 12px;
}
.mobile-menu-content a:hover { background: rgba(255,255,255,0.1); }
.mobile-menu-content a .nav-icon { font-size: 1.3em; }

@media (max-width: 918px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .hero { padding: 10px 20px 18vh; }
}

/* ===== Pages ===== */
.page { display: none; padding-top: 56px; min-height: 100vh; position: relative; z-index: 3; }
.page.active { display: block; }

/* Hero */
.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px); text-align: center; padding: 20px 20px 12vh;
}
.hero-logo { max-width: min(80vw, 600px); height: auto; }
.hero-title { font-size: clamp(1.5em, 4vw, 2.5em); margin-top: 20px; font-style: italic; }
.hero-subtitle { font-size: clamp(1em, 3vw, 1.5em); margin-top: 8px; font-style: italic; }

/* Content Wrapper */
.content-wrapper {
  max-width: 1200px; margin: 0 auto; padding: 30px 20px 80px;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 15px; margin-bottom: 25px;
  padding-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.15);
}
.page-header h2 { font-size: 1.6em; font-style: italic; }
.season-selector select {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 12px; border-radius: 6px; font-size: 0.95em;
  accent-color: var(--accent); color-scheme: dark;
}
.season-selector select option { background: var(--card-bg, #1a0040); color: #fff; }
.season-selector select option:checked { background: var(--nav-hover-bg, rgba(95,0,204,0.4)); }

/* ===== Event Cards ===== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.event-card {
  background: var(--card-bg); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 20px; transition: all 0.3s;
  animation: fadeIn 0.5s ease-out both;
}
.event-card:hover { background: var(--card-hover); border-color: var(--border-hover); transform: translateY(-2px); }
.event-card .event-date { color: var(--accent); font-size: 1.1em; font-weight: bold; margin-bottom: 4px; }
.event-card .event-name { font-size: 1.15em; font-weight: 600; margin-bottom: 10px; }
.event-card .event-track { color: var(--accent); text-decoration: none; font-size: 0.95em; }
.event-card .event-track:hover { text-decoration: underline; }
.event-card .event-details { color: var(--text-dim); font-size: 0.85em; line-height: 1.6; margin-top: 10px; }
.event-card .event-details strong { color: #fff; }
.event-card .result-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.8em;
  font-weight: bold; margin-top: 8px;
}
.result-badge.win { background: rgba(255,215,0,0.35); color: #ffd700; font-size: 0.9em; }
.result-badge.top3 { background: rgba(255,215,0,0.20); color: #ffd700; }
.result-badge.top5 { background: rgba(192,192,192,0.25); color: #c0c0c0; }
.result-badge.top10 { background: rgba(205,127,50,0.25); color: #cd7f32; }

/* ===== Gallery ===== */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.gallery-card {
  position: relative; border-radius: 10px; overflow: hidden;
  cursor: pointer; aspect-ratio: 4/3; background: var(--content-bg);
  transition: transform 0.3s; animation: fadeIn 0.5s ease-out both;
}
.gallery-card:hover { transform: scale(1.03); }
.gallery-card img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card .gallery-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 30px 15px 15px; color: #fff;
}
.gallery-card .gallery-name { font-size: 1em; font-weight: 600; }
.gallery-card .gallery-count { font-size: 0.8em; color: var(--text-dim); }

.gallery-viewer { animation: fadeIn 0.3s; }
.back-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; padding: 8px 16px; border-radius: 6px; cursor: pointer;
  margin-bottom: 15px; font-size: 0.9em;
}
.back-btn:hover { background: rgba(255,255,255,0.2); }
.gallery-images {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px;
}
.gallery-images img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px;
  cursor: pointer; transition: transform 0.2s;
}
.gallery-images img:hover { transform: scale(1.05); }

/* ===== Videos ===== */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.video-card {
  background: var(--card-bg); border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1); transition: all 0.3s;
  animation: fadeIn 0.5s ease-out both;
}
.video-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.video-card .video-thumb {
  position: relative; aspect-ratio: 16/9; background: #000; cursor: pointer;
}
.video-card .video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-card .video-thumb .play-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.3s; font-size: 3em;
}
.video-card:hover .play-overlay { opacity: 1; }
.video-card .video-info { padding: 12px 15px; }
.video-card .video-title { font-weight: 600; margin-bottom: 4px; }
.video-card .video-date { color: var(--text-dim); font-size: 0.85em; }
.video-card .video-desc { color: var(--text-dim); font-size: 0.85em; margin-top: 6px; }

/* Video Player Modal */
.video-modal {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
}
.video-modal video { max-width: 95vw; max-height: 90vh; }
.video-modal .close-video {
  position: absolute; top: 15px; right: 20px; color: #fff; font-size: 2em;
  background: none; border: none; cursor: pointer;
}

/* ===== Sponsors / Supporters ===== */
.sponsors-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px;
}
.sponsor-card {
  position: relative; border-radius: 10px; overflow: hidden;
  aspect-ratio: 4/3; background: var(--content-bg);
  transition: transform 0.3s; animation: fadeIn 0.5s ease-out both;
}
.sponsor-card:hover { transform: scale(1.03); }
.sponsor-card a { text-decoration: none; color: inherit; display: block; width: 100%; height: 100%; }
.sponsor-card .sponsor-logo-wrap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 25px;
}
.sponsor-card .sponsor-logo-wrap img {
  max-height: 100%; max-width: 100%; object-fit: contain; transition: opacity 0.3s;
}
.sponsor-card .sponsor-logo-wrap .hover-logo {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 25px; opacity: 0;
}
.sponsor-card .sponsor-logo-wrap .hover-logo img { max-height: 100%; max-width: 100%; object-fit: contain; }
.sponsor-card:hover .sponsor-logo-wrap .hover-logo { opacity: 1; }
.sponsor-card:hover .sponsor-logo-wrap .main-logo { opacity: 0; }
.sponsor-card .sponsor-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 30px 15px 15px; color: #fff; pointer-events: none;
}
.sponsor-card .sponsor-name { font-size: 1em; font-weight: 600; }

/* ===== About ===== */
.about-content {
  background: var(--content-bg); border-radius: 10px; padding: 30px;
  border: 1px solid rgba(255,255,255,0.1); line-height: 1.7; font-size: 1.05em;
}
.about-content p { margin-bottom: 15px; }
.about-content a { color: var(--accent); }
.about-content .history-toggle {
  color: var(--accent); cursor: pointer; display: inline-block; margin-top: 10px;
}
.about-content .history-section { margin-top: 15px; }

/* ===== Contact Form ===== */
.contact-form {
  max-width: 600px; display: flex; flex-direction: column; gap: 14px;
}
.contact-form input, .contact-form textarea {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; padding: 12px 15px; border-radius: 8px; font-size: 1em;
  font-family: inherit;
}
.contact-form input::placeholder, .contact-form textarea::placeholder { color: rgba(255,255,255,0.5); }
.contact-form input:focus, .contact-form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-glow);
}
.btn-primary {
  background: linear-gradient(135deg, var(--btn-start), var(--btn-end)); color: #fff;
  border: none; padding: 12px 30px; border-radius: 8px; font-size: 1em;
  cursor: pointer; transition: all 0.3s; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.2); transform: translateY(-1px); }
.form-status { font-size: 0.9em; padding: 5px; }
.form-status.success { color: #4caf50; }
.form-status.error { color: #f44336; }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,0.95);
  display: none; align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 90vh; object-fit: contain; }
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute; background: none; border: none; color: #fff;
  font-size: 2.5em; cursor: pointer; padding: 10px; opacity: 0.7;
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { opacity: 1; }
.lightbox-close { top: 10px; right: 20px; }
.lightbox-prev { left: 15px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 15px; top: 50%; transform: translateY(-50%); }


/* ===== Reflex Game ===== */
.reflex-game-wrapper { display: flex; justify-content: center; }
.reflex-game-area {
  background: var(--content-bg); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 40px 30px; text-align: center;
  max-width: 500px; width: 100%; transition: background-color 0.15s;
}
.reflex-game-area h3 { font-size: 1.4em; margin-bottom: 8px; }
.reflex-instructions { color: var(--text-dim); font-size: 0.95em; line-height: 1.6; margin-bottom: 20px; }
.reflex-buttons { display: flex; gap: 16px; justify-content: center; margin-bottom: 20px; }
.btn-reflex {
  padding: 14px 36px; border: none; border-radius: 8px; font-size: 1.1em;
  font-weight: 700; cursor: pointer; transition: all 0.2s; color: #fff;
}
.btn-start { background: linear-gradient(135deg, #2e7d32, #43a047); }
.btn-start:hover { background: linear-gradient(135deg, #388e3c, #4caf50); transform: translateY(-2px); }
.btn-stop { background: linear-gradient(135deg, #c62828, #e53935); }
.btn-stop:hover { background: linear-gradient(135deg, #d32f2f, #ef5350); transform: translateY(-2px); }
.btn-reflex:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.reflex-result {
  font-size: 1.3em; font-weight: bold; min-height: 50px;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px;
}
.reflex-result .time { font-size: 1.6em; color: var(--accent); }
.reflex-result .remark { font-size: 0.9em; color: var(--text-dim); }
.reflex-history { margin-top: 15px; color: var(--text-dim); font-size: 0.85em; }
.reflex-history span { display: inline-block; padding: 3px 8px; margin: 2px; background: rgba(255,255,255,0.08); border-radius: 4px; }

/* ===== Disabled Page Message ===== */
.page-disabled-msg {
  text-align: center; padding: 80px 20px; color: var(--text-dim);
}
.page-disabled-msg h3 { font-size: 1.4em; margin-bottom: 10px; color: var(--text); }
.page-disabled-msg p { font-size: 1.05em; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); font-size: 1.1em; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .cards-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .video-grid { grid-template-columns: 1fr; }
  .sponsors-grid { grid-template-columns: 1fr; }
  .content-wrapper { padding: 20px 12px 60px; }
  .gallery-images { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
