/* ============================================
   Chess Online — Hand-Crafted Theme
   Colors: #2D1810 (dark wood) / #F5E6C8 (ivory)
           #C9A84C (gold) / #769656 (board green)
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg: #F5E6C8;
  --bg-card: #FFF8EC;
  --text: #2D1810;
  --text-secondary: #5C3A28;
  --gold: #C9A84C;
  --gold-dark: #A88A30;
  --brown: #2D1810;
  --brown-light: #4A2C20;
  --green: #769656;
  --cream: #F5E6C8;
  --cream-light: #FFF8EC;
  --border: #D4C4A0;
  --shadow: rgba(45, 24, 16, 0.12);
  --nav-bg: rgba(245, 230, 200, 0.92);
  --hero-bg: linear-gradient(160deg, #F5E6C8 0%, #E8D5B0 50%, #D4C4A0 100%);
  --canvas-bg: #2D1810;
  --input-bg: #FFF8EC;
  --hover-bg: rgba(201, 168, 76, 0.12);
}

[data-theme="dark"] {
  --bg: #1A0E0A;
  --bg-card: #2D1810;
  --text: #F5E6C8;
  --text-secondary: #C9A84C;
  --gold: #C9A84C;
  --gold-dark: #D4B85A;
  --brown: #F5E6C8;
  --brown-light: #D4C4A0;
  --green: #769656;
  --cream: #1A0E0A;
  --cream-light: #2D1810;
  --border: #4A2C20;
  --shadow: rgba(0, 0, 0, 0.3);
  --nav-bg: rgba(26, 14, 10, 0.92);
  --hero-bg: linear-gradient(160deg, #1A0E0A 0%, #2D1810 50%, #3A2015 100%);
  --canvas-bg: #1A0E0A;
  --input-bg: #2D1810;
  --hover-bg: rgba(201, 168, 76, 0.15);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background 0.35s ease, color 0.35s ease;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--gold);
  color: var(--brown);
}

h1, h2, h3, h4 {
  font-family: 'Crimson Text', Georgia, 'Times New Roman', serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--brown);
}

a { color: var(--gold-dark); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold); }

/* ---------- Page Entrance Animation ---------- */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

main > section { animation: fadeSlideUp 0.6s ease-out both; }
main > section:nth-child(2) { animation-delay: 0.1s; }
main > section:nth-child(3) { animation-delay: 0.2s; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--gold);
  transition: background 0.35s ease;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  text-decoration: none;
}
.logo:hover { color: var(--gold-dark); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Language Dropdown */
.lang-switch { position: relative; }

.lang-btn {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.lang-btn:hover { border-color: var(--gold); }

.lang-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  min-width: 150px;
  box-shadow: 0 6px 20px var(--shadow);
  z-index: 1001;
  overflow: hidden;
}

.lang-switch:hover .lang-dropdown { display: block; }

.lang-dropdown li { padding: 0; }

.lang-dropdown a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.lang-dropdown a:hover {
  background: var(--hover-bg);
  color: var(--gold-dark);
}

/* Theme Toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  line-height: 1;
}
.theme-toggle:hover {
  border-color: var(--gold);
  transform: rotate(15deg);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 2.5rem 1rem 3rem;
  text-align: center;
  background: var(--hero-bg);
  overflow: hidden;
}

.hero::before {
  content: "♔ ♕ ♖ ♗ ♘ ♙";
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
  opacity: 0.06;
  letter-spacing: 0.6em;
  white-space: nowrap;
  color: var(--brown);
  pointer-events: none;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--gold);
  margin-bottom: 0.3rem;
  position: relative;
}

.hero-sub {
  font-size: 1.08rem;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto 2rem;
  position: relative;
}

/* ---------- Game Container ---------- */
.game-container {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px var(--shadow);
  padding: 1rem;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.game-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.game-controls button {
  background: var(--gold);
  color: #2D1810;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.15s;
}
.game-controls button:hover {
  background: var(--gold-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(201, 168, 76, 0.4);
}
.game-controls button:active { transform: translateY(0); }

/* Difficulty Pill Buttons (hidden radio + styled label) */
.difficulty-group {
  display: flex;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--input-bg);
}

.difficulty-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.difficulty-group label {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
  user-select: none;
  white-space: nowrap;
}

.difficulty-group label:hover { color: var(--text); }

.difficulty-group input[type="radio"]:checked + label {
  background: var(--gold);
  color: #2D1810;
  font-weight: 600;
}

/* Chess Canvas */
#chessBoard {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
  cursor: pointer;
  background: var(--canvas-bg);
}

.game-status {
  text-align: center;
  margin-top: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gold);
  min-height: 1.4em;
}

.captured-area {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.4rem;
  font-size: 1.1rem;
  min-height: 1.8em;
  padding: 0 0.5rem;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
}

/* ---------- Highlights Section ---------- */
.highlights {
  max-width: 1100px;
  margin: 3rem auto;
  padding: 0 1.2rem;
}

.highlights h2 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}

.highlights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
}

.highlight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.3rem;
  transition: box-shadow 0.3s, transform 0.2s, border-color 0.2s;
}

.highlight-card:hover {
  box-shadow: 0 6px 20px var(--shadow);
  transform: translateY(-2px);
  border-color: var(--gold);
}

.highlight-card h3 {
  font-size: 1.08rem;
  color: var(--gold-dark);
  margin-bottom: 0.4rem;
}

/* Auto-split pipe-separated titles: "Title | Desc" */
.highlight-card h3::after {
  content: "";
  display: block;
  width: 36px;
  height: 2px;
  background: var(--gold);
  margin-top: 0.3rem;
  opacity: 0.5;
}

.highlight-card p {
  font-size: 0.93rem;
  color: var(--text-secondary);
}

/* ---------- FAQ Section ---------- */
.faq {
  max-width: 800px;
  margin: 3rem auto 3rem;
  padding: 0 1.2rem;
}

.faq h2 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}

.faq details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  transition: border-color 0.2s;
}

.faq details + details { margin-top: 0; }

.faq details[open] { border-color: var(--gold); }

.faq summary {
  padding: 0.85rem 1.1rem;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  transition: background 0.2s;
  font-family: 'Crimson Text', Georgia, serif;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary::marker { display: none; content: ""; }

.faq summary:hover { background: var(--hover-bg); }

.faq summary::after {
  content: "+";
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--gold);
  transition: transform 0.25s;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.faq details[open] summary::after {
  content: "−";
  transform: rotate(180deg);
}

.faq details p {
  padding: 0 1.1rem 1rem;
  font-size: 0.93rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---------- Footer ---------- */
footer {
  background: #2D1810;
  color: #F5E6C8;
  margin-top: 3rem;
  padding: 2rem 1.2rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.9rem;
}

.footer-inner a {
  color: #C9A84C;
}

.footer-inner a:hover { color: #F5E6C8; }

.footer-inner nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Cookie Banner ---------- */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #2D1810;
  color: #F5E6C8;
  padding: 1rem 1.5rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  border-top: 2px solid #C9A84C;
  animation: slideUp 0.4s ease-out;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.cookie-banner[hidden] { display: none; }

.cookie-banner button {
  background: #C9A84C;
  color: #2D1810;
  border: none;
  padding: 0.4rem 1.4rem;
  border-radius: 20px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.cookie-banner button:hover { background: #D4B85A; }

/* ---------- About / Privacy / 404 ---------- */
.page-content {
  max-width: 720px;
  margin: 3rem auto;
  padding: 0 1.2rem;
}

.page-content h1 {
  font-size: 2.2rem;
  color: var(--gold);
  margin-bottom: 1rem;
}

.page-content h2 {
  font-size: 1.4rem;
  margin-top: 1.8rem;
  margin-bottom: 0.6rem;
}

.page-content p,
.page-content ul {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.98rem;
}

.page-content ul { padding-left: 1.4rem; }
.page-content ul li { margin-bottom: 0.35rem; }

/* 404 specific */
.error-page { text-align: center; padding: 3rem 1rem; }
.error-page h1 { font-size: 5rem; color: var(--gold); }
.error-page p { font-size: 1.15rem; margin-bottom: 1.5rem; }
.error-page .home-link {
  display: inline-block;
  background: var(--gold);
  color: #2D1810;
  padding: 0.7rem 1.8rem;
  border-radius: 24px;
  font-weight: 600;
  font-size: 1rem;
}
.error-page .home-link:hover { background: var(--gold-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .nav-inner {
    padding: 0.4rem 0.8rem;
  }

  .logo { font-size: 1.2rem; }

  .lang-btn { font-size: 0.78rem; padding: 0.3rem 0.5rem; }

  .hero { padding: 1.8rem 0.8rem 2rem; }

  .game-container { padding: 0.6rem; }

  .highlights-grid {
    grid-template-columns: 1fr;
  }

  .highlight-card { padding: 1rem; }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  h1 { font-size: 1.8rem; }
}

@media (max-width: 480px) {
  .game-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .difficulty-group {
    justify-content: center;
  }

  .difficulty-group label {
    padding: 0.35rem 0.6rem;
    font-size: 0.76rem;
  }

  .lang-dropdown {
    right: -20px;
    min-width: 130px;
  }

  .hero::before { display: none; }
}
