/**
 * Size It Games - Shared Stylesheet
 * Contains suite-wide design tokens, navigation components, and game utility styles.
 */

:root {
  --si-brand-blue: #1f4f8e;
  --si-brand-accent: #c83225;
  --si-brand-target: #ff6b5c;
  --si-brand-dark: #16202e;
  --si-brand-bg: #f7f9fc;
  --si-brand-surface: #ffffff;
  --si-brand-border: #16202e17;
  --si-brand-text: #16202e;
  --si-brand-text-dim: #596779;
}

html.dark {
  --si-brand-bg: #0d121a;
  --si-brand-surface: #141c27;
  --si-brand-border: #ffffff17;
  --si-brand-text: #e8edf4;
  --si-brand-text-dim: #9aa6b6;
}

/* =========================================================================
   SUITE-WIDE UNIFIED HEADER SYSTEM
   Applied across HomePage, HigherOrLower, Sizele, SortIt, StackIt & SiteHeader
   ========================================================================= */

.site-header,
.hol-header,
.sizele-header,
.sort-header,
.stack-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--line, rgba(22, 32, 46, 0.12));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-sizing: border-box;
}

.header-left,
.hol-header-left,
.sizele-header-left,
.sort-header-left,
.stack-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.header-actions,
.hol-header-right,
.sizele-header-right,
.sort-header-right,
.stack-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text, #16202e);
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint, #7a889b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
  white-space: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  border: 1px solid var(--line, rgba(22, 32, 46, 0.12));
  background: var(--surface, #ffffff);
  color: var(--text, #16202e);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
  user-select: none;
}

.icon-btn:hover {
  background: var(--surface-raise, rgba(22, 32, 46, 0.08));
  border-color: var(--line-strong, rgba(22, 32, 46, 0.22));
}

html.dark .icon-btn {
  background: var(--surface, #141c27);
  border-color: var(--line, rgba(255, 255, 255, 0.12));
  color: var(--text, #e8edf4);
}

html.dark .icon-btn:hover {
  background: var(--surface-raise, rgba(255, 255, 255, 0.08));
}

/* Games Selector Menu / Pill */
.games-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.games-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-raise-2, rgba(22, 32, 46, 0.06));
  border: 1px solid var(--line, rgba(22, 32, 46, 0.12));
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #16202e);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  white-space: nowrap;
}

.games-dropdown-btn > * {
  pointer-events: none;
}

.games-dropdown-btn:hover {
  background: var(--surface-raise, rgba(22, 32, 46, 0.1));
  border-color: rgba(255, 107, 92, 0.4);
  box-shadow: 0 2px 8px rgba(255, 107, 92, 0.12);
}

.games-dropdown-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.games-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff4742 0%, #ff7a45 100%);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(255, 71, 66, 0.35);
  animation: gamesBadgePulse 3.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes gamesBadgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 1px 4px rgba(255, 71, 66, 0.35);
  }
  45% {
    transform: scale(1.06);
    box-shadow: 0 0 10px rgba(255, 71, 66, 0.55);
  }
  60% {
    transform: scale(1);
    box-shadow: 0 1px 4px rgba(255, 71, 66, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .games-badge-count {
    animation: none;
  }
}

html.dark .games-dropdown-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

html.dark .games-dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 107, 92, 0.5);
  box-shadow: 0 2px 10px rgba(255, 107, 92, 0.18);
}

.games-dropdown-btn .dropdown-chevron {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.games-dropdown.open .games-dropdown-btn {
  background: var(--surface-raise, rgba(22, 32, 46, 0.1));
  border-color: var(--siu-board, #1f4f8e);
}

.games-dropdown.open .dropdown-chevron {
  transform: rotate(180deg);
}

.games-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line-strong, rgba(22, 32, 46, 0.16));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 28, 46, 0.14), 0 2px 6px rgba(15, 28, 46, 0.08);
  min-width: 250px;
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
  padding: 6px;
  z-index: 1000;
  display: none;
}

.games-dropdown.open .games-dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.games-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text, #16202e);
  transition: background 0.12s ease;
  line-height: 1.25;
}

.games-dropdown-item:hover {
  background: var(--surface-raise-2, rgba(22, 32, 46, 0.06));
}

.games-dropdown-item.active {
  background: rgba(31, 79, 142, 0.1);
  color: var(--siu-board, #1f4f8e);
}

html.dark .games-dropdown-item.active {
  background: rgba(77, 142, 232, 0.15);
  color: #72a8f2;
}

.games-dropdown-item .item-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.games-dropdown-item .item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.games-dropdown-item .item-title {
  font-size: 13px;
  font-weight: 700;
  color: inherit;
}

.games-dropdown-item .item-desc {
  font-size: 11px;
  color: var(--text-dim, #596779);
  margin-top: 1px;
}

.games-dropdown-item .game-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.games-dropdown-item .badge-flagship {
  background: rgba(31, 79, 142, 0.15);
  color: #1f4f8e;
}

.games-dropdown-item .badge-new {
  background: rgba(22, 137, 94, 0.15);
  color: #16895e;
}

.games-dropdown-item .badge-soon {
  background: rgba(100, 116, 139, 0.15);
  color: #64748b;
}

html.dark .games-dropdown-item .badge-flagship {
  background: rgba(77, 142, 232, 0.2);
  color: #72a8f2;
}

html.dark .games-dropdown-item .badge-new {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

html.dark .games-dropdown-item .badge-soon {
  background: rgba(255, 255, 255, 0.1);
  color: #9aa6b6;
}

/* Language Selector Menu / Pill */
.lang-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.lang-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-raise-2, rgba(22, 32, 46, 0.06));
  border: 1px solid var(--line, rgba(22, 32, 46, 0.12));
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #16202e);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.lang-dropdown-btn > * {
  pointer-events: none;
}

.lang-dropdown-btn:hover {
  background: var(--surface-raise, rgba(22, 32, 46, 0.1));
  border-color: var(--line-strong, rgba(22, 32, 46, 0.22));
}

.lang-dropdown-btn .dropdown-chevron {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-dropdown.open .lang-dropdown-btn {
  background: var(--surface-raise, rgba(22, 32, 46, 0.1));
  border-color: var(--siu-board, #1f4f8e);
}

.lang-dropdown.open .dropdown-chevron {
  transform: rotate(180deg);
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line-strong, rgba(22, 32, 46, 0.16));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 28, 46, 0.14), 0 2px 6px rgba(15, 28, 46, 0.08);
  min-width: 170px;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  padding: 6px;
  z-index: 1000;
  display: none;
}

.lang-dropdown.open .lang-dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lang-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text, #16202e);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s ease;
}

.lang-dropdown-item:hover {
  background: var(--surface-raise-2, rgba(22, 32, 46, 0.06));
}

.lang-dropdown-item.active {
  background: rgba(31, 79, 142, 0.1);
  color: var(--siu-board, #1f4f8e);
  font-weight: 700;
}

html.dark .lang-dropdown-item.active {
  background: rgba(77, 142, 232, 0.15);
  color: #72a8f2;
}

.lang-dropdown-btn .lang-globe-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

.lang-dropdown-item .lang-item-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.lang-dropdown-item.active .lang-item-name {
  font-weight: 700;
}

.lang-dropdown-item .lang-check {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.8;
}

/* =========================================================================
   SHARED HEADER UTILITY CONTROLS (Share, Info, Dark Mode)
   ========================================================================= */

.icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: 1px solid var(--line, rgba(22, 32, 46, 0.14));
  background: var(--surface, #ffffff);
  color: var(--text-dim, #596779);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  box-sizing: border-box;
}

.icon-btn:hover {
  background: var(--surface-raise-2, rgba(22, 32, 46, 0.06));
  color: var(--text, #16202e);
  border-color: var(--line-strong, rgba(22, 32, 46, 0.24));
}

.icon-btn:active {
  transform: scale(0.94);
}

html:not(.dark) .moon-icon { display: none; }
html.dark .sun-icon { display: none; }

/* =========================================================================
   RESPONSIVE UNIFIED HEADER SYSTEM
   ========================================================================= */

@media (max-width: 768px) {
  .brand-title-extra {
    display: none !important;
  }
  .brand-badge {
    display: none !important;
  }
  .games-dropdown-more {
    display: none !important;
  }
}

@media (max-width: 580px) {
  .hol-header,
  .sizele-header,
  .sort-header,
  .stack-header {
    height: 48px;
    min-height: 48px;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .site-header {
    height: auto !important;
    min-height: 48px;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .header-left,
  .hol-header-left,
  .sizele-header-left,
  .sort-header-left,
  .stack-header-left {
    gap: 6px;
  }

  .header-actions,
  .hol-header-right,
  .sizele-header-right,
  .sort-header-right,
  .stack-header-right {
    gap: 4px;
  }

  /* Compact games button on mobile */
  .games-dropdown-btn {
    padding: 4px 8px;
    font-size: 12px;
    gap: 4px;
  }

  .games-badge-count {
    font-size: 9px;
    padding: 1.5px 5px;
    letter-spacing: 0.02em;
  }

  .icon-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    padding: 0 !important;
    border-radius: 8px;
  }

  .icon-btn svg {
    transform: scale(0.85);
  }

  .lang-dropdown-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    padding: 0 !important;
    justify-content: center !important;
    gap: 0 !important;
    border-radius: 8px;
  }

  .lang-dropdown-btn .lang-btn-name,
  .lang-dropdown-btn .dropdown-chevron {
    display: none !important;
  }

  /* Keep dropdown menus within screen borders on mobile */
  .lang-dropdown-menu {
    left: auto;
    right: 0;
    min-width: 160px;
    max-width: calc(100vw - 16px);
  }

  .games-dropdown-menu {
    left: auto;
    right: 0;
    max-width: calc(100vw - 16px);
  }

  .header-play-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
}

/* Portrait mobile devices (iPhone SE, Galaxy, Pixel, etc.) */
@media (max-width: 500px) {
  /* Hiding text keeps the iconic ruler/scale symbol, freeing 80+ px so all right-side buttons fit cleanly */
  .brand-text {
    display: none !important;
  }

  .brand-icon {
    width: 28px !important;
    height: 28px !important;
  }
}

/* Very narrow devices (Galaxy Fold folded 320px, iPhone 5/SE1) */
@media (max-width: 360px) {
  .header-left,
  .hol-header-left,
  .sizele-header-left,
  .sort-header-left,
  .stack-header-left {
    gap: 4px;
  }

  .header-actions,
  .hol-header-right,
  .sizele-header-right,
  .sort-header-right,
  .stack-header-right {
    gap: 2.5px;
  }

  .icon-btn,
  .lang-dropdown-btn {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    border-radius: 6px;
  }

  .icon-btn svg {
    transform: scale(0.78);
  }

  .games-dropdown-btn {
    padding: 3px 5px;
    font-size: 11px;
    gap: 3px;
  }

  .games-badge-count {
    font-size: 8px;
    padding: 1px 3.5px;
  }
}

/* =========================================================================
   SHARED MODAL SYSTEM
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 18, 30, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-dialog {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line-strong, rgba(22, 32, 46, 0.2));
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  box-sizing: border-box;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line, rgba(22, 32, 46, 0.12));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text, #16202e);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-dim, #596779);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--text, #16202e);
  background: var(--surface-raise-2, rgba(22, 32, 46, 0.06));
}

.modal-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  font-size: 14px;
  color: var(--text-dim, #596779);
  line-height: 1.5;
}

.modal-body p {
  margin: 0 0 12px 0;
  color: var(--text, #16202e);
}

/* =========================================================================
   SHARED TOAST NOTIFICATION
   ========================================================================= */

.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: var(--text, #16202e);
  color: var(--surface, #ffffff);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  white-space: nowrap;
  animation: toastFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast[hidden] {
  display: none !important;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* =========================================================================
   ACCESSIBILITY & SEO UTILITIES
   ========================================================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

