/* =========================================================
   1. FARVER OG BASE
   ========================================================= */

:root {
  --page-bg: #fffaf4;
  --light-bg: #f8eadc;
  --hero-bg: #fff3e7;
  --soft-pink: #f4ded3;
  --red: #b51d17;
  --text: #000;
  --ring: #e2d2c5;
  --white: #fff;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --thumb-ratio: 4 / 3;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--page-bg);
  color: var(--text);
  font:
    16px/1.4 Arial,
    Helvetica,
    sans-serif;
}

/* =========================================================
   2. TILGÆNGELIGHED
   ========================================================= */

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

/* =========================================================
   3. HEADER PÅ SPILSIDEN
   ========================================================= */

.games-header {
  padding: 18px 16px 8px;
  background-color: var(--page-bg);
}

.games-header__logo {
  display: block;
  width: 80px;
  height: auto;
}

/* =========================================================
   4. SIDEINDHOLD
   ========================================================= */

.page {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 14px 110px;
  background-color: var(--page-bg);
}

.games-intro h1 {
  margin-bottom: 4px;
  color: var(--text);
}

.games-intro p {
  margin-top: 0;
  color: var(--text);
}

/* =========================================================
   5. SØGNING
   ========================================================= */

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;

  background: var(--white);
  border: 1px solid var(--ring);
  border-radius: 999px;

  padding: 8px 12px;
  margin: 10px 0 8px;

  box-shadow: var(--shadow);
}

.searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;

  font: inherit;
  font-size: 16px;
  color: var(--text);
}

.icon-btn {
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
}

/* =========================================================
   6. FILTERKNAP
   ========================================================= */

.filter-actions {
  margin: 12px 0 20px;
}

.filter-action {
  width: 100%;
  min-height: 44px;
  border-radius: 24px;

  font: inherit;
  font-weight: 600;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.filter-action__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.filter-action--primary {
  background: var(--red);
  color: var(--white);
  border: 2px solid var(--red);
}

/* =========================================================
   7. FILTERPANEL
   ========================================================= */

.filter-panel[hidden] {
  display: none;
}

.filter-panel {
  margin: 24px 0 30px;
}

.filter-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 6px;
}

.filter-panel__header h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--text);
}

.filter-panel__header p {
  color: var(--text);
}

.filter-panel__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);

  font-size: 28px;
  line-height: 1;

  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-panel__content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* =========================================================
   8. FILTERGRUPPER
   ========================================================= */

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-group h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-option {
  appearance: none;

  min-height: 40px;
  padding: 8px 14px;

  border: 1px solid var(--ring);
  border-radius: 999px;

  background: transparent;
  color: var(--text);

  font: inherit;
  font-size: 14px;
  font-weight: 500;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.filter-option:hover {
  border-color: var(--red);
}

.filter-option:focus-visible {
  outline: 3px solid rgba(181, 29, 23, 0.25);
  outline-offset: 2px;
}

.filter-option.active,
.filter-option[aria-pressed="true"] {
  background: var(--red);
  border-color: var(--red);
  color: var(--white);
}

.filter-option.active:hover {
  background-color: #9f1b16;
}

/* =========================================================
   9. FILTERPANEL – KNAPPER
   ========================================================= */

.filter-panel__actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.filter-show-results {
  width: 100%;
  min-height: 44px;

  border: 0;
  border-radius: 999px;

  background: var(--red);
  color: var(--white);

  font: inherit;
  font-size: 14px;
  font-weight: 700;

  cursor: pointer;
}

.clear-pill {
  width: 100%;
  min-height: 44px;

  border: 1px solid var(--ring);
  border-radius: 999px;

  background: transparent;
  color: var(--text);

  padding: 10px 16px;

  font: inherit;
  font-size: 14px;
  font-weight: 600;

  cursor: pointer;
}

.clear-pill:hover,
.clear-pill:focus-visible {
  border-color: var(--red);
}

/* =========================================================
   10. AKTIVE FILTRE
   ========================================================= */

.active-filters {
  margin-top: 22px;
  margin-bottom: 18px;
}

.active-filters h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

.active-filters__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 9px 13px;

  border: none;
  border-radius: 999px;

  background-color: var(--soft-pink);
  color: #a91f1a;

  font-size: 14px;
  font-weight: 600;

  cursor: pointer;
}

.active-filter:hover {
  background-color: #edd0c3;
}

.active-filter:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

/* =========================================================
   11. SPILOVERSIGT
   ========================================================= */

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
}

.card {
  background: var(--light-bg);
  color: var(--text);

  border-radius: 16px;
  padding: 10px;

  border: 0;
  box-shadow: none;
}

.thumb {
  position: relative;

  border-radius: 12px;
  overflow: hidden;

  background: #f5ebdc;

  aspect-ratio: var(--thumb-ratio);

  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb img {
  display: block;
  width: 94%;
  height: 94%;
  object-fit: contain;
}

.card h3 {
  margin: 10px 4px 6px;
  font-size: 16px;
  color: var(--text);
}

.meta,
.extra {
  display: flex;
  gap: 10px;

  margin: 0 4px 4px;

  color: var(--text);
  opacity: 1;

  font-size: 14px;
}

.extra {
  flex-direction: column;
  gap: 2px;
}

/* =========================================================
   12. FAVORITTER OG BADGES
   ========================================================= */

.fav {
  position: absolute;
  top: 8px;
  right: 8px;

  width: 32px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--white);
  color: var(--text);

  border: 1px solid #ddd;
  border-radius: 50%;

  padding: 0;

  font-size: 16px;
  cursor: pointer;
}

.fav.active {
  background: var(--white);
  color: var(--red);
  border-color: var(--red);
}

.badges {
  position: absolute;
  top: 8px;
  left: 8px;

  display: flex;
  gap: 6px;
}

.badge {
  background: var(--white);
  color: var(--text);

  padding: 3px 7px;

  font-size: 12px;
  font-weight: 600;

  border-radius: 999px;
  border: 1px solid var(--ring);
}

/* =========================================================
   13. FAVORIT FEEDBACK
   ========================================================= */

.favourite-feedback {
  position: fixed;
  left: 50%;
  bottom: 82px;
  transform: translateX(-50%);

  width: calc(100% - 32px);
  max-width: 440px;

  display: flex;
  align-items: center;
  gap: 12px;

  padding: 15px 18px;

  background-color: #2d2d2d;
  color: var(--white);

  border-radius: 12px;

  font-size: 16px;
  font-weight: 600;

  z-index: 1000;
}

.favourite-feedback[hidden] {
  display: none;
}

.favourite-feedback__check {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 22px;
  height: 22px;

  border: 1.5px solid var(--white);
  border-radius: 50%;

  font-size: 13px;
}

.favourite-feedback__close {
  margin-left: auto;
  padding: 4px;

  border: none;
  background: transparent;
  color: var(--white);

  font-size: 24px;
  line-height: 1;

  cursor: pointer;
}

.favourite-feedback__close:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

/* =========================================================
   14. MODAL – SPILDETALJER
   ========================================================= */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 4000;

  display: grid;
  place-items: center;

  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-card {
  position: relative;
  z-index: 1;

  width: min(920px, 100%);
  max-height: 90vh;

  display: flex;
  flex-direction: column;

  overflow: hidden;

  background: var(--light-bg);
  color: var(--text);

  border: 1px solid var(--ring);
  border-radius: 18px;

  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;

  width: 36px;
  height: 36px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--white);
  color: var(--text);

  border: 1px solid var(--ring);
  border-radius: 50%;

  font-size: 22px;
  line-height: 1;

  padding: 0;
  cursor: pointer;
}

.modal-media {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #f5ebdc;

  padding: 0.5rem;

  border-bottom: 1px solid var(--ring);
}

.modal-media img {
  display: block;

  width: 100%;
  height: auto;
  max-height: 350px;

  object-fit: contain;
}

.modal-body {
  flex: 1;
  overflow-y: auto;

  display: grid;
  gap: 10px;

  padding: 1rem 1.5rem;
}

.modal-body h2 {
  margin: 0;
  font-size: clamp(20px, 3.2vw, 28px);
  color: var(--text);
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  opacity: 1;
  color: var(--text);
}

.modal-details {
  display: grid;
  gap: 6px;
}

.modal-details span {
  opacity: 1;
}

/* =========================================================
   15. REGLER I MODAL
   ========================================================= */

.rules-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;

  margin-top: 1rem;

  background: none;
  border: 0;

  color: var(--red);

  font-size: 1.1rem;
  font-weight: 600;

  cursor: pointer;
}

.rules-btn[aria-expanded="true"]::before {
  content: "▾";
}

.rules-btn[aria-expanded="false"]::before {
  content: "▸";
}

.rules-content {
  max-height: 0;
  overflow: hidden;

  transition: max-height 0.3s ease;
}

.rules-content.open {
  max-height: 600px;
}

#modal-rules {
  margin-top: 0.5rem;
  padding: 0.75rem;

  background: var(--hero-bg);
  border-radius: 6px;

  white-space: pre-wrap;
  line-height: 1.4;
}

/* =========================================================
   16. RESPONSIVT DESIGN
   ========================================================= */

/* Tablet */
@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Større tablet / mindre desktop */
@media (min-width: 900px) {
  .page,
  .games-header {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Desktop */
@media (min-width: 1200px) {
  .page,
  .games-header {
    max-width: 1400px;
  }

  .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* =========================================================
   17. REDUCERET BEVÆGELSE
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
