/* =====================================================================
   Indoor Games for Adults - main stylesheet
   Mobile-first, CSS custom properties for instant theme switching.
   ===================================================================== */

:root {
  --color-bg: #f7f7fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f1f8;
  --color-text: #1c1c28;
  --color-text-muted: #63637a;
  --color-border: #e3e3ee;
  --color-primary: #7c3aed;
  --color-primary-dark: #5b21b6;
  --color-accent: #ec4899;
  --gradient-brand: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  --gradient-hero: linear-gradient(135deg, #6d28d9 0%, #db2777 60%, #f97316 100%);
  --shadow-sm: 0 2px 8px rgba(28, 28, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(28, 28, 40, 0.10);
  --shadow-lg: 0 16px 40px rgba(28, 28, 40, 0.16);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --success: #16a34a;
  --error: #dc2626;
  --easy: #16a34a;
  --medium: #d97706;
  --hard: #dc2626;
  --transition: 0.25s ease;
}

[data-theme="dark"] {
  --color-bg: #12121a;
  --color-surface: #1b1b27;
  --color-surface-alt: #232332;
  --color-text: #f1f1f8;
  --color-text-muted: #a3a3b8;
  --color-border: #2d2d3f;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 999;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------------------------------------------------------------
   Header / Navigation
   --------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
}

.logo-img {
  border-radius: 10px;
  width: 44px;
  height: 44px;
  object-fit: cover;
}

.logo-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 101;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 24px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  position: fixed;
  top: 0;
  right: -100%;
  height: 100vh;
  width: min(80vw, 320px);
  background: var(--color-surface);
  flex-direction: column;
  justify-content: center;
  transition: right var(--transition);
  box-shadow: var(--shadow-lg);
}
.main-nav.open { right: 0; }
.main-nav a { font-weight: 600; padding: 10px; font-size: 1.1rem; }
.main-nav a:hover { color: var(--color-primary); }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--transition), transform var(--transition);
}
.theme-toggle:hover { transform: rotate(15deg); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

@media (min-width: 860px) {
  .nav-toggle { display: none; }
  .main-nav {
    position: static;
    height: auto;
    width: auto;
    flex-direction: row;
    box-shadow: none;
    background: transparent;
  }
}

/* ---------------------------------------------------------------
   Flash messages
   --------------------------------------------------------------- */
.flash {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  animation: slideDown 0.35s ease;
}
.flash-success { background: rgba(22, 163, 74, 0.12); color: var(--success); border: 1px solid rgba(22,163,74,0.3); }
.flash-error { background: rgba(220, 38, 38, 0.12); color: var(--error); border: 1px solid rgba(220,38,38,0.3); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px);} to { opacity: 1; transform: translateY(0);} }

/* ---------------------------------------------------------------
   Hero
   --------------------------------------------------------------- */
.hero {
  background: var(--gradient-hero);
  color: #fff;
  padding: 64px 20px 90px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.15), transparent 40%),
              radial-gradient(circle at 80% 60%, rgba(255,255,255,0.12), transparent 45%);
}
.hero-content { position: relative; max-width: 720px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0 0 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero p { font-size: 1.15rem; opacity: 0.95; margin: 0 0 30px; }

/* ---------------------------------------------------------------
   Search / Filter bar
   --------------------------------------------------------------- */
.filter-bar {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  margin: -56px auto 40px;
  max-width: 980px;
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 760px) {
  .filter-bar { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
}
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-field label { font-size: 0.8rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.filter-field input,
.filter-field select {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.95rem;
  transition: border-color var(--transition);
  width: 100%;
}
.filter-field input:focus,
.filter-field select:focus {
  outline: none;
  border-color: var(--color-primary);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  text-align: center;
}
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; border: 1.5px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

/* ---------------------------------------------------------------
   Game Cards Grid
   --------------------------------------------------------------- */
.section { padding: 20px 20px 70px; }
.section-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.section-subtitle { color: var(--color-text-muted); margin-bottom: 30px; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.game-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.5s ease both;
}
@media (prefers-reduced-motion: reduce) {
  .game-card { animation: none; }
}
.game-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }

.game-card-img {
  aspect-ratio: 16 / 10;
  width: 100%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2.4rem;
  font-weight: 800;
  overflow: hidden;
  position: relative;
}
.game-card-img img { width: 100%; height: 100%; object-fit: cover; }

.game-card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.game-card-category {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
}
.game-card-title { font-size: 1.15rem; font-weight: 800; margin: 0; }
.game-card-desc { color: var(--color-text-muted); font-size: 0.92rem; flex: 1; }

.game-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; }
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-weight: 600;
}

.badge { padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; color: #fff; }
.badge-easy { background: var(--easy); }
.badge-medium { background: var(--medium); }
.badge-hard { background: var(--hard); }

.game-card-footer { padding: 0 18px 18px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.5; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------
   Game Detail Page
   --------------------------------------------------------------- */
.breadcrumb { font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: 20px; }
.breadcrumb a:hover { color: var(--color-primary); }

.game-detail-hero {
  background: var(--gradient-brand);
  border-radius: var(--radius-lg);
  padding: 44px 32px;
  color: #fff;
  margin-bottom: 32px;
}
.game-detail-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 10px 0; }
.game-detail-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.game-detail-meta .meta-pill { background: rgba(255,255,255,0.18); color: #fff; }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 32px; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 2fr 1fr; } }

.detail-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.detail-card h2 { font-size: 1.3rem; margin-top: 0; }
.detail-card p, .detail-card li { color: var(--color-text-muted); }
.how-to-steps { white-space: pre-line; }

/* ---------------------------------------------------------------
   Forms (contact + admin)
   --------------------------------------------------------------- */
.form-page { max-width: 640px; margin: 0 auto; padding: 50px 20px; }
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 34px;
  box-shadow: var(--shadow-md);
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.92rem; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--color-primary); }
.form-group textarea { min-height: 140px; resize: vertical; }
.field-error { color: var(--error); font-size: 0.82rem; margin-top: 5px; }
.form-row { display: grid; gap: 16px; }
@media (min-width: 600px) { .form-row.two-col { grid-template-columns: 1fr 1fr; } }

/* ---------------------------------------------------------------
   Admin
   --------------------------------------------------------------- */
.admin-shell { display: flex; min-height: calc(100vh - 72px); }
.admin-sidebar {
  width: 220px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 24px 14px;
  flex-shrink: 0;
}
.admin-sidebar a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-muted);
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--color-surface-alt); color: var(--color-primary); }
.admin-main { flex: 1; padding: 30px; min-width: 0; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.admin-table th, .admin-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
.admin-table th { background: var(--color-surface-alt); font-weight: 700; }
.admin-table tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 30px; }
.stat-card { background: var(--color-surface); border-radius: var(--radius-md); padding: 22px; box-shadow: var(--shadow-sm); border: 1px solid var(--color-border); }
.stat-card .stat-num { font-size: 2rem; font-weight: 800; background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card .stat-label { color: var(--color-text-muted); font-size: 0.88rem; font-weight: 600; }

/* ---------------------------------------------------------------
   Skeleton loading
   --------------------------------------------------------------- */
.skeleton { position: relative; overflow: hidden; background: var(--color-surface-alt); border-radius: var(--radius-sm); }
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: shimmer 1.4s infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent); }
@keyframes shimmer { 0% { transform: translateX(-100%);} 100% { transform: translateX(100%);} }

.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */
.site-footer { background: var(--color-surface-alt); border-top: 1px solid var(--color-border); margin-top: 60px; }
.footer-inner { display: grid; grid-template-columns: 1fr; gap: 30px; padding: 50px 20px 30px; }
@media (min-width: 760px) { .footer-inner { grid-template-columns: 2fr 1fr 1fr; } }
.footer-col h4 { margin: 0 0 14px; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; }
.footer-col a { display: block; color: var(--color-text-muted); margin-bottom: 10px; }
.footer-col a:hover { color: var(--color-primary); }
.footer-tagline { color: var(--color-text-muted); font-size: 0.9rem; margin-top: 12px; max-width: 320px; }
.social-links { display: flex; gap: 12px; }
.social-links a { width: 38px; height: 38px; border-radius: 50%; background: var(--color-surface); display: flex; align-items: center; justify-content: center; border: 1px solid var(--color-border); }
.social-links a:hover { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.footer-bottom { padding: 18px 20px; text-align: center; color: var(--color-text-muted); font-size: 0.85rem; border-top: 1px solid var(--color-border); }

/* ---------------------------------------------------------------
   Error pages
   --------------------------------------------------------------- */
.error-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }
.error-code { font-size: clamp(4rem, 12vw, 8rem); font-weight: 900; background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.error-message { font-size: 1.2rem; color: var(--color-text-muted); margin: 14px 0 30px; }

/* ---------------------------------------------------------------
   Utility
   --------------------------------------------------------------- */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
