/* ═══════════════════════════════════════════════════════════
   COMPONENTS — Calm Paper / Indigo design system
   Requires tokens.css to be loaded first
   ═══════════════════════════════════════════════════════════ */

/* ── Inline SVG icon (bx-icon sprite) ────────────────────── */
.bx-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: currentColor;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background: var(--c-bg);
  color: var(--c-ink);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--c-ink);
  line-height: 1.3;
}

h1 { font-size: var(--text-xl); margin-bottom: var(--sp-2); }
h2 { font-size: var(--text-lg); margin-bottom: var(--sp-2); }
h3 { font-size: var(--text-md); margin-bottom: var(--sp-1); }

a { color: var(--c-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: #1E293B;
  color: #CBD5E1;
  padding: 3rem 1.5rem 1.5rem;
  margin-top: 4rem;
  border-top: 1px solid #334155;
}

.footer-container { max-width: 1200px; margin: 0 auto; }

.footer-nav {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #334155;
}

.footer-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 2rem;
  margin: 0; padding: 0;
}

.footer-nav a {
  color: #F1F5F9;
  font-weight: 500;
  font-size: var(--text-sm);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  display: inline-block;
}

.footer-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
  text-decoration: none;
}

.footer-countries {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #334155;
}

.footer-countries h3 {
  text-align: center;
  color: #F9FAFB;
  font-size: var(--text-md);
  margin: 0 0 1.5rem;
  font-weight: 600;
}

.country-links {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0; padding: 0;
}

.country-links a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #F9FAFB;
  font-size: var(--text-sm);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  background: rgba(255,255,255,.05);
  text-decoration: none;
}

.country-links a:hover {
  background: rgba(255,255,255,.1);
  transform: translateX(4px);
  text-decoration: none;
}

.flag-icon {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* Flag SVGs (inline data URIs) */
.flag-icon-us { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect fill="%23B22234" width="60" height="30"/><path d="M0,3.46h60M0,6.92h60M0,10.38h60M0,13.84h60M0,17.3h60M0,20.76h60M0,24.22h60M0,27.68h60" stroke="%23fff" stroke-width="2.3"/><rect fill="%233C3B6E" width="24" height="17.3"/></svg>'); }
.flag-icon-cn { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40"><rect fill="%23DE2910" width="60" height="40"/><polygon fill="%23FFDE00" points="10,5 12,11 18,11 13,15 15,21 10,17 5,21 7,15 2,11 8,11"/></svg>'); }
.flag-icon-in { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40"><rect fill="%23FF9933" width="60" height="13.33"/><rect fill="%23fff" y="13.33" width="60" height="13.33"/><rect fill="%23138808" y="26.66" width="60" height="13.33"/><circle fill="%23000080" cx="30" cy="20" r="5"/></svg>'); }
.flag-icon-br { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40"><rect fill="%23009739" width="60" height="40"/><polygon fill="%23FEDD00" points="30,5 55,20 30,35 5,20"/><circle fill="%23002776" cx="30" cy="20" r="7"/></svg>'); }
.flag-icon-ph { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect fill="%23CE1126" width="60" height="15"/><rect fill="%230038A8" y="15" width="60" height="15"/><polygon fill="%23fff" points="0,0 25,15 0,30"/></svg>'); }
.flag-icon-tr { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40"><rect fill="%23E30A17" width="60" height="40"/><circle fill="%23fff" cx="22" cy="20" r="8"/><circle fill="%23E30A17" cx="24" cy="20" r="6.5"/></svg>'); }
.flag-icon-de { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40"><rect width="60" height="13.33"/><rect fill="%23D00" y="13.33" width="60" height="13.33"/><rect fill="%23FFCE00" y="26.66" width="60" height="13.33"/></svg>'); }
.flag-icon-jp { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40"><rect fill="%23fff" width="60" height="40"/><circle fill="%23BC002D" cx="30" cy="20" r="9"/></svg>'); }

.footer-description {
  text-align: center;
  font-size: var(--text-xs);
  line-height: 1.8;
  color: #94A3B8;
  max-width: 800px;
  margin: 0 auto;
}

.footer-description strong { color: #F9FAFB; }
.footer-description a { color: #60A5FA; }
.footer-description a:hover { text-decoration: underline; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 48px;
  padding: 0 var(--sp-6);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--c-brand-light);
  color: var(--c-brand);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--c-brand);
  color: #fff;
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--c-brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--c-brand-hover);
  color: #fff;
}

/* Keep old .btn-blue alias working */
.btn-blue {
  background: var(--c-brand);
  color: #fff;
}

.btn-success {
  background: var(--c-teal);
  color: #fff;
}

.btn-danger {
  background: var(--c-rose);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--c-ink-2);
  box-shadow: none;
  border: 1px solid var(--c-border);
}

.btn-ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-ink);
}

/* Start-screen oversized btn (keep backward compat) */
.start-screen .btn {
  height: 64px;
  width: 90%;
  max-width: 320px;
  font-size: var(--text-lg);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
}

.control-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

/* ── Game Layout ──────────────────────────────────────────── */
.game-header-section {
  text-align: center;
  margin-bottom: var(--sp-5);
  padding: 0 var(--sp-2);
}

.game-container {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-5);
  align-items: start;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

.numbers-sidebar {
  max-width: 260px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ── Number Pad ───────────────────────────────────────────── */
/* !important on display/direction overrides inline <style> blocks in page PHP files */
.numbers-top {
  display: flex !important;
  flex-direction: column !important;
  gap: var(--sp-2);
  width: fit-content;
  margin: 0 auto var(--sp-2);
}

/* Row of digit buttons */
.num-row {
  display: flex !important;
  gap: var(--sp-1);
}

/* Row of action buttons — stretches to match num-row width */
.actions-row {
  display: flex !important;
  gap: var(--sp-1);
}

.numbers-top .number {
  width: var(--cell-size, 44px) !important;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 600;
  font-feature-settings: "tnum";
  background: var(--c-surface);
  color: var(--c-ink);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0 !important;
  user-select: none;
  box-sizing: content-box !important;
}

.numbers-top .number:hover {
  border-color: var(--c-brand);
  background: var(--c-brand-light);
  color: var(--c-brand);
}

/* ── Action Buttons (Erase / Notes / Hint / Undo) ─────────── */
.numbers-top .delete,
#toggle-notes,
#clear-notes,
#btn-hint,
#btn-undo {
  flex: 1 !important;
  height: 40px;
  min-width: 56px;
  width: auto !important;  /* override inline width:100% from page styles */
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  padding: 0 var(--sp-2);
  grid-row: unset !important;   /* cancel any inline grid-row */
  grid-column: unset !important; /* cancel any inline grid-column */
}

.numbers-top .delete {
  background: var(--c-rose-light);
  color: var(--c-rose);
  border: 1.5px solid transparent;
}

.numbers-top .delete:hover {
  background: var(--c-rose);
  color: #fff;
}

/* ── Game Controls ────────────────────────────────────────── */
#toggle-notes,
#clear-notes {
  background: var(--c-surface);
  color: var(--c-ink-2);
  border: 1.5px solid var(--c-border);
}

#toggle-notes:hover,
#clear-notes:hover {
  border-color: var(--c-brand);
  background: var(--c-brand-light);
  color: var(--c-brand);
}

#toggle-notes.active {
  background: var(--c-brand);
  color: #fff;
  border-color: var(--c-brand);
}

/* Hint button — amber accent */
#btn-hint {
  background: #FFFBEB;
  color: #92400E;
  border: 1.5px solid #FCD34D;
}

#btn-hint:hover {
  background: var(--c-amber, #F59E0B);
  color: #fff;
  border-color: var(--c-amber, #F59E0B);
}

/* Undo button — indigo ghost */
#btn-undo {
  background: var(--c-brand-light, #EEF2FF);
  color: var(--c-brand, #4F46E5);
  border: 1.5px solid #C7D2FE;
}

#btn-undo:hover {
  background: var(--c-brand);
  color: #fff;
  border-color: var(--c-brand);
}

/* ── Game Info Boxes ──────────────────────────────────────── */
.main-game-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
}

.main-game-info-box {
  height: 44px;
  background: var(--c-surface-2);
  color: var(--c-ink);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-4);
  font-size: var(--text-md);
  font-weight: 600;
  font-feature-settings: "tnum";
  border: 1px solid var(--c-border);
}

.game-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-2);
}

/* ── Difficulty Links ─────────────────────────────────────── */
.difficulty-link {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-ink-2);
  background: var(--c-surface);
  transition: all var(--transition);
  text-decoration: none;
  min-width: 56px;
  justify-content: center;
}

.difficulty-link:hover, .difficulty-link.active {
  background: var(--c-brand);
  color: #fff;
  border-color: var(--c-brand);
  text-decoration: none;
}

/* ── Modals (pause / result) ─────────────────────────────── */
.pause-screen, .result-screen {
  background: rgba(250,249,246,0.96);
  backdrop-filter: blur(8px);
}

[data-theme="dark"] .pause-screen,
body.dark .pause-screen,
[data-theme="dark"] .result-screen,
body.dark .result-screen {
  background: rgba(15,23,42,0.96);
}

.result-screen .congrate {
  font-size: var(--text-2xl);
  color: var(--c-brand);
  font-weight: 700;
}

.result-screen .info { color: var(--c-ink-2); font-size: var(--text-md); }
#result-time { color: var(--c-brand); font-size: var(--text-2xl); font-weight: 700; font-feature-settings: "tnum"; }

/* Streak badge in result */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-amber-light);
  color: var(--c-amber);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-xl);
  font-weight: 700;
  font-size: var(--text-lg);
}

/* Emoji share card */
.share-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  text-align: center;
  font-family: monospace;
  font-size: var(--text-md);
  line-height: 1.4;
  white-space: pre;
}

/* ── FAQ ─────────────────────────────────────────────────── */
.faq-section { max-width: 800px; margin: 2rem auto; padding: 0 var(--sp-4); }

.faq-question {
  width: 100%;
  text-align: left;
  font-weight: 600;
  font-size: var(--text-md);
  padding: var(--sp-4) var(--sp-5);
  border: none;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--c-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

/* chevron icon in .faq-question rotates on open; no ::after needed */
.faq-question .bx,
.faq-question i[class*="bx"],
.faq-question .bx-icon {
  flex-shrink: 0;
  font-size: 22px;
  width: 22px;
  height: 22px;
  color: var(--c-brand);
  transition: transform 0.3s ease;
}

.faq-item.open .faq-question .bx,
.faq-item.open .faq-question i[class*="bx"],
.faq-item.open .faq-question .bx-icon { transform: rotate(180deg); }
.faq-question:hover { background: var(--c-brand-light); }
.faq-answer {
  display: none;
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--c-ink-2);
}

.faq-item.open .faq-answer { display: block; }

/* ── Tips / Info Widgets ─────────────────────────────────── */
.tips-widget {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}

.tips-widget h3 {
  color: var(--c-brand);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Breadcrumbs ─────────────────────────────────────────── */
.breadcrumb {
  font-size: var(--text-xs);
  color: var(--c-ink-3);
  margin-bottom: var(--sp-3);
}

.breadcrumb a { color: var(--c-brand); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span::before { content: " › "; }

/* ── Ad Containers ────────────────────────────────────────── */
.ad-container { text-align: center; }

/* Reserve dimensions to prevent CLS */
.ad-container--leaderboard {
  min-height: 90px;
  width: 100%;
  max-width: 728px;
  margin: var(--sp-4) auto;
}

.ad-container--leaderboard-mobile {
  min-height: 100px;
  width: 100%;
  max-width: 320px;
  margin: var(--sp-4) auto;
}

.ad-container--rectangle {
  min-height: 250px;
  min-width: 300px;
  margin: var(--sp-4) auto;
}

.ad-container--sidebar {
  min-height: 600px;
  min-width: 160px;
}

/* ── Intro / Content Sections ────────────────────────────── */
.intro-text {
  font-size: var(--text-lg);
  color: var(--c-ink-2);
  max-width: 700px;
  margin: var(--sp-4) auto;
  text-align: center;
  line-height: 1.7;
}

.why-play-sudoku {
  margin-top: 3rem;
  background: var(--c-surface);
  padding: var(--sp-8) var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
}

.why-play-sudoku p {
  margin-bottom: var(--sp-4);
  color: var(--c-ink-2);
  line-height: 1.7;
}

/* ── Game Grid Wrapper (homepage card tiles) ─────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
}

.post-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.post-image { aspect-ratio: 16/9; overflow: hidden; }
.post-image img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition); }
.post-card:hover .post-image img { transform: scale(1.04); }
.post-content { padding: var(--sp-5); }
.post-title { font-size: var(--text-md); margin: 0 0 var(--sp-3); line-height: 1.4; }
.post-title a { color: var(--c-ink); }
.post-excerpt { color: var(--c-ink-2); font-size: var(--text-sm); line-height: 1.5; margin-bottom: var(--sp-4); }

.read-more {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-brand);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-sm);
  transition: background var(--transition);
  text-decoration: none;
}

.read-more:hover { background: var(--c-brand-hover); text-decoration: none; }

/* Shimmer loading */
.loading-shimmer {
  display: grid;
  gap: var(--sp-6);
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.shimmer-card {
  height: 350px;
  background: var(--c-surface-2);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.shimmer-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
  animation: shimmer 1.5s infinite;
}

/* ── Feedback Widget ─────────────────────────────────────── */
.feedback-widget {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  text-align: center;
  margin: var(--sp-8) auto;
  max-width: 500px;
}

/* ── Language Banner ─────────────────────────────────────── */
.lang-banner {
  background: var(--c-brand-light);
  border: 1px solid var(--c-brand);
  color: var(--c-brand);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  font-size: var(--text-sm);
}

.lang-banner button {
  background: none;
  border: none;
  color: var(--c-ink-3);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Daily Challenge Badge ───────────────────────────────── */
.daily-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-amber-light);
  color: #92400E;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-xl);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

body.dark .daily-badge { color: var(--c-amber); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .game-container {
    grid-template-columns: 1fr;
  }

  .numbers-sidebar {
    width: 100%;
    max-width: 100%;
  }

  .footer-nav ul { flex-direction: column; gap: 1.25rem; }
  .footer-description { text-align: left; font-size: var(--text-xs); }
  .country-links { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .nav-logo img { width: 120px; }
  .start-screen .btn { font-size: var(--text-md); height: 54px; }
}
