/* Home — readable layout + similar-games grid */
body.page-index {
  --page-hero-overlay-alpha: 0.9;
  --home-logo-shadow: 0 1px 2px rgba(30, 25, 78, 0.5);
  --home-accent-x: #c4b5fd;
  --home-accent-x-dim: rgba(196, 181, 253, 0.22);
  --home-text: #f0edfa;
  --home-text-muted: #afa8c9;
  --home-surface: #1e194e;
  --home-surface-elevated: #16143a;
  --home-border: #3a3a5a;
}

body.page-index .page-hero-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background-color: #100c1f;
  pointer-events: none;
}

body.page-index .page-hero-bg picture,
body.page-index .page-hero-bg .page-hero-bg-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

body.page-index .page-hero-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background-color: rgba(16, 12, 31, var(--page-hero-overlay-alpha));
  pointer-events: none;
}

body.page-index .content-container {
  position: relative;
  z-index: 2;
}

body.page-index .main-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

#home-flow {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 3rem;
  box-sizing: border-box;
}

/* —— Hero / game picker —— */
.home-top-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1.5rem 0.5rem 0;
  text-align: center;
}

.home-top-bar .home-sentence {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  margin: 0;
  width: 100%;
  max-width: min(36rem, 100%);
  font-size: clamp(1.875rem, 4.5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--home-text);
  text-shadow: var(--home-logo-shadow);
}

.home-top-bar .home-sentence-lead {
  display: block;
  width: 100%;
  text-align: center;
}

.home-top-bar .home-picker-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.home-top-bar .home-sentence-lead,
.home-top-bar .home-picker-trigger {
  font: inherit;
  text-shadow: inherit;
}

.home-top-bar .home-sentence-lead {
  color: inherit;
}

.home-top-bar .home-picker-trigger.home-accent-x,
.home-top-bar .home-picker-trigger.home-accent-x .home-picker-label {
  color: var(--home-accent-x);
}

.home-sentence-lead {
  white-space: nowrap;
}

.home-source-thumbnail {
  margin: 0.65rem 0 0;
  padding: 0;
  line-height: 0;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}

.home-source-thumbnail.is-thumbnail-out {
  opacity: 0.22;
  transform: translateY(8px);
}

.home-source-thumbnail.hidden {
  display: none !important;
}

.home-source-thumbnail:not(.hidden) {
  display: block;
}

.home-source-thumbnail img {
  display: block;
  width: 5rem;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top center;
  border-radius: 0.5rem;
  border: 2px solid rgba(119, 81, 255, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .home-source-thumbnail {
    transition: none;
    transform: none;
  }

  .home-source-thumbnail.is-thumbnail-out {
    opacity: 1;
    transform: none;
  }
}

.home-top-hint {
  margin: 0.75rem 0 0;
  max-width: 28rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--home-text-muted);
}

.home-inline-picker {
  position: relative;
  display: block;
  max-width: min(20em, 92vw);
}

.home-picker-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.1em 0.2em;
  margin: 0;
  border: none;
  border-radius: 0.35em;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s ease;
}

.home-picker-trigger:not(:disabled):hover,
.home-picker-trigger[aria-expanded="true"] {
  background: rgba(119, 81, 255, 0.14);
}

.home-accent-x {
  color: var(--home-accent-x);
  box-shadow: inset 0 -0.12em 0 var(--home-accent-x-dim);
}

.home-picker-trigger.home-accent-x[aria-expanded="true"] {
  box-shadow: inset 0 -0.12em 0 rgba(196, 181, 253, 0.45);
}

.home-top-bar .home-picker-trigger.home-accent-x {
  max-width: min(18em, 72vw);
  min-width: 0;
  overflow: hidden;
}

.home-picker-trigger .home-picker-label {
  min-width: min-content;
}

.home-picker-label {
  display: inline-block;
  max-width: 100%;
  min-height: 1.35em;
  overflow: hidden;
  text-align: center;
  color: inherit;
}

.home-picker-label-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: inherit;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.48s ease, transform 0.48s ease;
}

.home-picker-label.is-label-out .home-picker-label-text {
  opacity: 0;
  transform: translateY(0.28em);
}

@media (prefers-reduced-motion: reduce) {
  .home-picker-label-text {
    transition: none;
    transform: none;
  }

  .home-picker-label.is-label-out .home-picker-label-text {
    opacity: 1;
    transform: none;
  }
}

.home-picker-chevron {
  flex-shrink: 0;
  width: 0.5em;
  height: 0.5em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-0.1em);
  opacity: 0.9;
}

.home-picker-panel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 0.5rem);
  z-index: 120;
  min-width: min(340px, calc(100vw - 2rem));
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.75rem;
  text-align: left;
  background: #16143a;
  border: 2px solid rgba(119, 81, 255, 0.55);
  border-radius: 0.75rem;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(119, 81, 255, 0.12);
}

.home-picker-panel.hidden {
  display: none;
}

.home-picker-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--home-text);
  background: #1e194e;
  border: 2px solid rgba(119, 81, 255, 0.35);
  border-radius: 0.5rem;
}

.home-picker-search::placeholder {
  color: #8b85a3;
}

.home-picker-search:focus {
  outline: 2px solid #7751ff;
  outline-offset: 1px;
  border-color: #7751ff;
}

.home-picker-suggestions-label {
  margin: 0.65rem 0 0.35rem;
  padding: 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c4b5fd;
}

.home-picker-suggestions-label.hidden {
  display: none;
}

.home-picker-list {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
}

.home-picker-list.hidden {
  display: none;
}

.home-picker-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.6rem;
  border-radius: 0.4rem;
  cursor: pointer;
  color: var(--home-text);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.home-picker-list li:hover,
.home-picker-list li.active {
  background: rgba(119, 81, 255, 0.22);
}

.home-picker-sg-thumb {
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: cover;
}

.home-picker-list li .home-picker-sg-meta {
  min-width: 0;
  flex: 1;
}

.home-picker-sg-name {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-picker-sg-badge {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8125rem;
  color: var(--home-text-muted);
}

.home-advanced-link {
  margin-top: 1.15rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #9d85ff;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.home-advanced-link:hover {
  color: #c4b5fd;
}

/* —— Panel containers (match game_detail.html) —— */
body.page-index .category-header {
  margin: -1rem -1rem 1rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.5rem 0.5rem 0 0;
  background-color: #7751ff;
  color: #f0edfa;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}

.home-similar-panel,
.home-recent-panel {
  padding: 1rem;
  background: #1e194e;
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

/* —— Results panel —— */
.home-similar-panel {
  margin-bottom: 0;
}

#home-similar-games.similar-games-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}

#home-similar-games.similar-games-grid.is-transitioning-out {
  transition: opacity 0.28s ease;
  opacity: 0.34;
}

#home-similar-games .similar-games-column .similar-games-cards {
  transition: opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}

#home-similar-games.is-suggestions-fading .similar-games-cards {
  opacity: 0.22;
  transform: translateY(8px);
}

#home-similar-games .similar-games-column {
  min-width: 0;
  overflow: visible;
}

#home-similar-games .similar-games-column-header {
  margin: 0 0 0.75rem;
  padding-bottom: 0;
  border-bottom: none;
}

/* Align card rows when side-column subtitles wrap to 2 lines */
@media (min-width: 768px) {
  #home-similar-games
    .similar-games-column:not(.similar-games-column--top-picks)
    .similar-games-section-subtitle {
    min-height: 2.8em;
  }
}

@media (min-width: 1100px) {
  #home-similar-games .similar-games-column-header .similar-games-section-subtitle {
    min-height: 2.8em;
  }
}

.home-section-loading {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  color: var(--home-text-muted);
}

.home-section-loading.hidden {
  display: none;
}

#home-similar-games .similar-games-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (prefers-reduced-motion: reduce) {
  #home-similar-games .similar-games-column .similar-games-cards {
    transition: none;
  }

  #home-similar-games.is-suggestions-fading .similar-games-cards {
    opacity: 1;
    transform: none;
  }
}

#home-similar-games .similar-games-cards-empty {
  padding: 1.25rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: #8b85a3;
  text-align: center;
  border: 1px dashed var(--home-border);
  border-radius: 0.65rem;
  grid-column: 1 / -1;
}

#home-similar-games .similar-games-card {
  overflow: hidden;
  border: 1px solid var(--home-border);
  border-radius: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}

#home-similar-games .similar-games-card:hover {
  border-color: rgba(119, 81, 255, 0.45);
}

#home-similar-games .similar-games-card-title {
  background: var(--home-surface-elevated);
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes home-similar-card-enter {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  #home-similar-games .similar-games-card-item.is-entering {
    animation: home-similar-card-enter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: var(--home-card-enter-delay, 0ms);
  }
}

/* Tablet: Top picks full width, then 2 cols */
@media (min-width: 768px) {
  #home-similar-games.similar-games-grid {
    gap: 2.25rem;
  }

  #home-similar-games.similar-games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #home-similar-games .similar-games-column--top-picks {
    grid-column: 1 / -1;
  }

  #home-similar-games .similar-games-column--top-picks .similar-games-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Desktop: Top picks 3× width of Outsiders / If you liked (9 vs 3 games) */
@media (min-width: 1100px) {
  #home-flow {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  #home-similar-games.similar-games-grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem 2.25rem;
  }

  #home-similar-games .similar-games-column--top-picks {
    grid-column: auto;
  }

  #home-similar-games .similar-games-column {
    padding: 0 0.25rem;
  }

  #home-similar-games .similar-games-column:not(:last-child) {
    padding-right: 1.25rem;
    border-right: 1px solid #3a3a5a;
  }

  #home-similar-games .similar-games-column--top-picks .similar-games-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Screenshot preview */
#home-similar-games .similar-games-screenshot-preview {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 50;
  width: min(280px, 92vw);
  max-width: 100%;
  transform: translateX(-50%) scale(0.98);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 2px solid #7751ff;
  background: var(--home-surface-elevated);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

#home-similar-games .similar-games-screenshot-preview-media {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  background: #0f0d28;
}

#home-similar-games .similar-games-screenshot-preview-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  align-items: center;
  justify-content: center;
  background: #0f0d28;
}

#home-similar-games .similar-games-screenshot-preview-media.is-loading .similar-games-screenshot-preview-loading {
  display: flex;
}

#home-similar-games .similar-games-screenshot-preview-spinner {
  width: 1.75rem;
  height: 1.75rem;
  color: #7751ff;
  animation: homePreviewSpin 0.75s linear infinite;
}

@keyframes homePreviewSpin {
  to { transform: rotate(360deg); }
}

#home-similar-games .similar-games-screenshot-preview-img {
  opacity: 0;
  transition: opacity 0.15s ease;
}

#home-similar-games .similar-games-screenshot-preview-img.is-loaded {
  opacity: 1;
}

#home-similar-games .similar-games-screenshot-preview-meta {
  padding: 0.6rem 0.75rem 0.7rem;
  border-top: 1px solid var(--home-border);
  font-size: 0.8125rem;
}

#home-similar-games .similar-games-card-item.is-preview-active .similar-games-screenshot-preview {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

@media (max-width: 1023px) {
  body.page-index .main-content {
    flex: 0 0 auto;
    overflow: visible;
  }

  body.page-index .footer-content {
    flex-shrink: 0;
    position: relative;
    z-index: 2;
  }
}

@media (max-width: 479px) {
  #home-flow {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  #home-similar-games .similar-games-column--top-picks .similar-games-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* —— Recently added —— */
.home-recent-panel {
  margin-top: 1.5rem;
}

.home-recent-subtitle {
  margin: -0.35rem 0 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #afa8c9;
}

.home-recent-carousel {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.home-recent-carousel.hidden {
  display: none;
}

.home-recent-carousel-viewport {
  flex: 1 1 auto;
  min-width: 0;
  container-type: inline-size;
  container-name: recent-carousel;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.home-recent-carousel-viewport::-webkit-scrollbar {
  display: none;
}

.home-recent-carousel-viewport:focus {
  outline: 2px solid rgba(119, 81, 255, 0.55);
  outline-offset: 2px;
}

#home-recent-games.home-recent-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100cqw;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#home-recent-games .similar-games-card-item {
  min-width: 0;
  scroll-snap-align: start;
}

#home-recent-games .similar-games-card-media {
  height: 5.5rem;
}

#home-recent-games .similar-games-card-release {
  margin: 0;
  padding: 0 0.5rem 0.4rem;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--home-text-muted);
}

#home-recent-games .similar-games-cards-empty {
  flex: 1 1 100%;
  padding: 1.25rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: #8b85a3;
  text-align: center;
  border: 1px dashed var(--home-border);
  border-radius: 0.65rem;
}

.home-recent-carousel-btn {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(119, 81, 255, 0.35);
  border-radius: 999px;
  cursor: pointer;
  color: var(--home-text);
  background: rgba(22, 20, 58, 0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.home-recent-carousel-btn:hover:not(:disabled) {
  border-color: rgba(119, 81, 255, 0.65);
  background: rgba(30, 25, 78, 0.98);
}

.home-recent-carousel-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.home-recent-carousel-btn-icon {
  display: block;
  width: 0.55rem;
  height: 0.55rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.home-recent-carousel-btn--prev .home-recent-carousel-btn-icon {
  transform: rotate(-135deg) translate(1px, -1px);
}

.home-recent-carousel-btn--next .home-recent-carousel-btn-icon {
  transform: rotate(45deg) translate(-1px, 1px);
}

@container recent-carousel (min-width: 640px) {
  #home-recent-games.home-recent-track {
    grid-auto-columns: calc((100cqw - 0.75rem * 2) / 3);
  }
}

@container recent-carousel (min-width: 900px) {
  #home-recent-games.home-recent-track {
    grid-auto-columns: calc((100cqw - 0.75rem * 3) / 4);
  }
}

@container recent-carousel (min-width: 1200px) {
  #home-recent-games.home-recent-track {
    grid-auto-columns: calc((100cqw - 0.75rem * 5) / 6);
  }

  #home-recent-games .similar-games-card-media {
    height: 4.75rem;
  }
}

@media (max-width: 479px) {
  .home-similar-panel,
  .home-recent-panel {
    padding: 1rem;
  }
}
