/* Theme toggle control + dark palette (html[data-theme="dark"]) */

.theme-toggle-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.theme-favorite-link {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #ef476f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex: 0 0 auto;
  transition: transform 0.14s ease, background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.theme-favorite-link.has-items {
  color: #e11d48;
}

.theme-favorite-link.is-current-favorite {
  background: #ffe4e6;
  border-color: #fb7185;
}

.theme-favorite-link:hover {
  transform: translateY(-1px);
  background: #fff1f2;
  border-color: #fda4af;
  color: #e11d48;
}

.theme-favorite-link svg {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.theme-favorite-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid #fff;
}

.theme-favorites-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(92vw, 330px);
  max-height: min(65vh, 460px);
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
  padding: 8px;
  z-index: 250;
}

.theme-favorites-popover[hidden] {
  display: none !important;
}

.theme-favorites-empty {
  font-size: 12px;
  color: #6b7280;
  padding: 12px;
  line-height: 1.5;
}

.theme-favorites-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 4px 8px;
}

.theme-favorites-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.theme-favorites-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.28px;
  color: #64748b;
  font-weight: 700;
}

.theme-favorites-count {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 10px;
  font-weight: 700;
}

.theme-favorites-clear {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  height: 24px;
  padding: 0 10px;
  background: #fff;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.theme-favorites-clear:hover:not(:disabled) {
  color: #e11d48;
  border-color: #fda4af;
  background: #fff1f2;
}

.theme-favorites-clear:disabled {
  opacity: 0.55;
  cursor: default;
}

.theme-favorites-search-row {
  padding: 0 4px 8px;
}

.theme-favorites-search {
  width: 100%;
  height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-size: 12px;
  padding: 0 10px;
  outline: none;
}

.theme-favorites-search:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.2);
}

.theme-favorites-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.theme-favorites-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

.theme-favorites-item-link {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: #111827;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 5px;
}

.theme-favorites-item-link:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.theme-favorites-item-thumb {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
}

.theme-favorites-item-thumb--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ef476f;
  border: 1px dashed #fbcfe8;
}

.theme-favorites-item-thumb--fallback svg {
  width: 14px;
  height: 14px;
}

.theme-favorites-item-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.theme-favorites-remove {
  width: 24px;
  height: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
  padding: 0;
}

.theme-favorites-remove:hover {
  color: #e11d48;
  border-color: #fda4af;
  background: #fff1f2;
}

.theme-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
  border-radius: 999px;
}

.theme-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #e8eaef, #d7dbe4);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.75), inset 0 -1px 2px rgba(15, 23, 42, 0.08);
}

.theme-toggle-moon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #94a3b8;
  pointer-events: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.theme-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(165deg, #a855f7 0%, #ec4899 55%, #f472b6 100%);
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.45), 0 1px 2px rgba(15, 23, 42, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.theme-toggle-knob svg {
  width: 12px;
  height: 12px;
  color: #fff;
}

/* Light = knob right (sun) */
html:not([data-theme="dark"]) .theme-toggle-knob {
  transform: translateX(26px);
}

html:not([data-theme="dark"]) .theme-toggle-moon {
  opacity: 0.55;
}

/* Dark = knob left (moon) */
html[data-theme="dark"] .theme-toggle-knob {
  transform: translateX(0);
}

html[data-theme="dark"] .theme-toggle-moon {
  color: #cbd5e1;
  opacity: 1;
}

html[data-theme="dark"] .theme-toggle-knob svg {
  opacity: 0.85;
}

/* ——— Dark theme page chrome ——— */
html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background-color: #0b1220 !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] .site-header {
  --site-header-bg: #0f172a !important;
  --site-header-line: rgba(148, 163, 184, 0.35) !important;
  background: var(--site-header-bg) !important;
  color: #e2e8f0 !important;
  border-bottom-color: var(--site-header-line) !important;
}

html[data-theme="dark"] .site-hamburger {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .site-logo {
  color: #f1f5f9 !important;
}

html[data-theme="dark"] .site-search-wrap input {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] .site-search-wrap button {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .theme-favorite-link {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #fb7185 !important;
}

html[data-theme="dark"] .theme-favorite-link:hover {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #fda4af !important;
}

html[data-theme="dark"] .theme-favorite-link.is-current-favorite {
  background: #4c1d2f !important;
  border-color: #9f1239 !important;
}

html[data-theme="dark"] .theme-favorite-badge {
  border-color: #1e293b !important;
}

html[data-theme="dark"] .theme-favorites-popover {
  background: #0f172a !important;
  border-color: #334155 !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .theme-favorites-empty {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .theme-favorites-label {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .theme-favorites-count {
  background: #1e293b !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .theme-favorites-clear {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

html[data-theme="dark"] .theme-favorites-clear:hover:not(:disabled) {
  background: #4c1d2f !important;
  border-color: #9f1239 !important;
  color: #fda4af !important;
}

html[data-theme="dark"] .theme-favorites-search {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] .theme-favorites-search::placeholder {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .theme-favorites-item-link {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] .theme-favorites-item-link:hover {
  background: #1e293b !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .theme-favorites-item-thumb {
  background: #1e293b !important;
}

html[data-theme="dark"] .theme-favorites-item-thumb--fallback {
  border-color: #475569 !important;
  color: #fb7185 !important;
}

html[data-theme="dark"] .theme-favorites-remove {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

html[data-theme="dark"] .theme-favorites-remove:hover {
  background: #4c1d2f !important;
  border-color: #9f1239 !important;
  color: #fda4af !important;
}

html[data-theme="dark"] .site-static-sidebar {
  background: #0f172a !important;
  border-right-color: #1e293b !important;
}

html[data-theme="dark"] .site-static-link {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .site-static-link:hover {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] #gameList.search-results,
html[data-theme="dark"] .search-results {
  background: #1e293b !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] #gameList .game-item a,
html[data-theme="dark"] .search-results .game-item a {
  color: #f1f5f9 !important;
}

html[data-theme="dark"] #gameList .game-item a:hover,
html[data-theme="dark"] .search-results .game-item a:hover {
  background: #334155 !important;
}

html[data-theme="dark"] .site-home-footer {
  background: #0f172a !important;
  border-top-color: #1e293b !important;
}

html[data-theme="dark"] .site-home-footer .foot-wrap,
html[data-theme="dark"] .site-home-footer .foot-links a {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .player-footer__inner {
  background: #1e293b !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .player-footer__left h1 {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] .player-footer__actions .g-footer__button {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

/* Homepage & category cards */
html[data-theme="dark"] .section,
html[data-theme="dark"] .content,
html[data-theme="dark"] .card,
html[data-theme="dark"] .category-card,
html[data-theme="dark"] .game-card {
  background: #111827 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .category-card .name,
html[data-theme="dark"] footer,
html[data-theme="dark"] .foot-wrap {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] header:not(.site-header) {
  background: #0f172a !important;
}

html[data-theme="dark"] main,
html[data-theme="dark"] .container-fluid {
  color: #e2e8f0;
}

html[data-theme="dark"] .text-custom-text,
html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-700 {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-gray-50 {
  background-color: #1e293b !important;
}

html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-gray-100 {
  border-color: #334155 !important;
}
