/* ── Spelkorts-hero (app-cards.js) ─────────────────────────────────────────── */

/* ── Wrap ──────────────────────────────────────────────────────────────────── */
#hc-wrap {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 0;
  padding-bottom: 0;
}

/* ── Laddningstext (samma stil som #immersive-loading) ─────────────────────── */
#hc-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;           /* bakom korten (z-index 1–4) */
  white-space: nowrap;
  font-size: 1.0rem;
  color: rgba(255,255,255,0.6);
  font-style: italic;
  animation: kk-pulse 2.2s ease-in-out infinite;
  text-align: center;
}
#hc-loading.hidden { display: none; }

/* ── Tom-höge-text ─────────────────────────────────────────────────────────── */
#hc-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 0;           /* bakom korten */
  padding: 0 24px;
  gap: 10px;
}
#hc-empty.hidden { display: none; }

.hc-empty-line1 {
  font-size: 2.0rem;
  font-weight: 800;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  animation: kk-pulse 2.2s ease-in-out infinite;
}
.hc-empty-line2 {
  font-size: 1.0rem;
  font-style: italic;
  color: rgba(255,255,255,0.5);
  animation: kk-pulse 2.2s ease-in-out infinite;
  animation-delay: 0.3s;
  max-width: 320px;
  line-height: 1.5;
  text-align: center;
}

/* ── Kortleks-wrapper ──────────────────────────────────────────────────────── */
#hc-deck {
  position: relative;
  /* Extra space for stack peek: 48px left + 38px top */
  width: 480px;   /* card width ×1.2 */
  height: clamp(499px, calc(80vh - 208px), 787px);
  margin-top: 32px;
  flex-shrink: 0;
}

/* ── Gemensamma kortstilar ─────────────────────────────────────────────────── */
.hc-card {
  position: absolute;
  width: 432px;   /* 360 × 1.2 */
  height: clamp(499px, calc(80vh - 208px), 787px);
  border-radius: 20px;
  background-color: #0a0a18; /* fallback vid bildladdning */
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 0 0 0 transparent;
  /* All cards get will-change for GPU compositing to prevent flash */
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  /* WebKit ignorerar overflow:hidden med transforms – clip-path klipper korrekt oavsett transform-kontext */
  clip-path: inset(0 round 20px);
}

/* Suddigt bakgrundslager – fyller kortet med en mörkad cover-version av bilden */
.hc-card-bg-blur {
  position: absolute;
  inset: -12%;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.45) saturate(0.7);
  z-index: 0;
}

/* Faktisk bild (contain, top-alignad, 10% beskärning per sida) */
.hc-card-img {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 125%;           /* 100/80 = 1.25 → klipper 10% per sida */
  transform: translateX(-50%);
  object-fit: contain;
  object-position: top center;
  z-index: 1;
}

/* ── Bakre kort (stack-fans, ingen content) ────────────────────────────────── */
.hc-card--back3 {
  left: 0;
  top: 0;
  z-index: 1;
  opacity: 0.28;
  transform: rotate(-3deg) translate(-20px, -10px) scale(0.88);
  transition: transform 0.42s cubic-bezier(0.25,0.8,0.25,1),
              opacity   0.42s cubic-bezier(0.25,0.8,0.25,1);
}
.hc-card--back2 {
  left: 12px;
  top: 10px;
  z-index: 2;
  opacity: 0.48;
  transform: rotate(-2deg) translate(-10px, -5px) scale(0.92);
  transition: transform 0.42s cubic-bezier(0.25,0.8,0.25,1),
              opacity   0.42s cubic-bezier(0.25,0.8,0.25,1);
}
.hc-card--next {
  left: 24px;
  top: 19px;
  z-index: 3;
  opacity: 0.78;
  transform: rotate(-1deg) translate(-5px, -2px) scale(0.96);
  transition: transform 0.42s cubic-bezier(0.25,0.8,0.25,1),
              opacity   0.42s cubic-bezier(0.25,0.8,0.25,1);
}

/* ── Front-kortet ──────────────────────────────────────────────────────────── */
.hc-card--front {
  left: 48px;
  top: 38px;
  z-index: 4;
  opacity: 1;
  transform: rotate(0deg) translate(0, 0);
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.08);
  cursor: pointer;
  /* No transition on front by default — transitions applied when exiting */
}
.hc-card--front:active { cursor: grabbing; }

/* ── Exit-animationer ──────────────────────────────────────────────────────── */
.hc-card--exiting {
  z-index: 6; /* ovanför promoting (5) under hela exit-animationen */
}
.hc-card--exiting.hc-exiting-like {
  transition: transform 0.38s cubic-bezier(0.4,0,0.6,1),
              opacity   0.38s cubic-bezier(0.4,0,0.6,1);
  transform: translateX(560px) rotate(18deg) !important;
  opacity: 0 !important;
}
.hc-card--exiting.hc-exiting-dislike {
  transition: transform 0.38s cubic-bezier(0.4,0,0.6,1),
              opacity   0.38s cubic-bezier(0.4,0,0.6,1);
  transform: translateX(-560px) rotate(-18deg) !important;
  opacity: 0 !important;
}

/* ── Promoting (next → front, smooth) ─────────────────────────────────────── */
/* Startar vid next-position och glider till front-position */
.hc-card--promoting {
  z-index: 5; /* ovanför det exiting front-kortet */
  left: 48px;
  top: 38px;
  opacity: 1;
  transform: rotate(0deg) translate(0, 0) !important;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.08);
  transition: transform   0.38s cubic-bezier(0.25,0.8,0.25,1),
              opacity     0.30s cubic-bezier(0.25,0.8,0.25,1),
              left        0.38s cubic-bezier(0.25,0.8,0.25,1),
              top         0.38s cubic-bezier(0.25,0.8,0.25,1),
              box-shadow  0.38s cubic-bezier(0.25,0.8,0.25,1) !important;
}

/* ── Nytt back3-kort: tonar in diskret ────────────────────────────────────── */
.hc-card--appearing {
  opacity: 0 !important;
  transform: rotate(-4deg) translate(-34px, -17px) !important;
  transition: none !important;
}

/* ── Stämplar ──────────────────────────────────────────────────────────────── */
.hc-stamp {
  position: absolute;
  top: 24px;
  border-radius: 10px;
  padding: 4px 16px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 10;
}
.hc-stamp--like {
  left: 24px;
  border: 3px solid #2ecc71;
  color: #2ecc71;
  transform: rotate(-10deg);
}
.hc-stamp--dislike {
  right: 24px;
  border: 3px solid #e74c3c;
  color: #e74c3c;
  transform: rotate(10deg);
}
.hc-card.hc-exiting-like    .hc-stamp--like    { opacity: 1; }
.hc-card.hc-exiting-dislike .hc-stamp--dislike { opacity: 1; }

/* ── Kortinnehåll ──────────────────────────────────────────────────────────── */
.hc-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(8,8,24,0.94) 0%,
    rgba(8,8,24,0.28) 58%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 2; /* ovanpå .hc-card-img (z-index:1) */
}

.hc-card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 18px 22px 22px;
  z-index: 5;
}

.hc-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.hc-cat-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 9px;
  border-radius: 9px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  flex-shrink: 0;
}

.hc-card-date {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
}

.hc-date-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.90);
  border-radius: 5px;
  padding: 1px 4px;
  vertical-align: middle;
  line-height: 1.5;
}

.hc-card-dist {
  font-size: 11px;
  color: rgba(255,255,255,0.40);
  white-space: nowrap;
}

.hc-card-title {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 5px;
  text-shadow: 0 2px 16px rgba(0,0,0,0.5);
  text-wrap: pretty;
}

.hc-card--front:hover .hc-card-title {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-color: rgba(255,255,255,0.85);
}

.hc-card-venue {
  font-size: 13px;
  color: rgba(255,255,255,0.60);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hc-card-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.60);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── UI-container (counter + actions) ──────────────────────────────────────── */
#hc-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

/* ── Åtgärdsknappar ────────────────────────────────────────────────────────── */
#hc-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  transition: opacity 0.3s;
}
#hc-actions::after {
  content: '';
  width: 46px;
  flex-shrink: 0;
}

.hc-action-btn {
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
}

.hc-action-btn--dislike {
  width: 62px;
  height: 62px;
  font-size: 20px;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.16);
  color: #e74c3c;
}
.hc-action-btn--dislike:hover {
  background: rgba(231,76,60,0.20);
  transform: scale(1.1);
}

.hc-action-btn--fav {
  width: 62px;
  height: 62px;
  font-size: 1.15rem;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.45);
  padding: 0;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
}
.hc-action-btn--fav svg {
  width: 1.1em;
  height: 1.1em;
  display: block;
}
.hc-action-btn--fav.active {
  color: #fff;
}
.hc-action-btn--fav:hover {
  transform: scale(1.1);
  background: rgba(255,255,255,0.14);
}

.hc-action-btn--undo {
  width: 46px;
  height: 46px;
  font-size: 1.2rem;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(245,193,39,0.55);
  color: #F5C127;
  filter: drop-shadow(0 1px 6px rgba(245,193,39,0.25));
}
.hc-action-btn--undo:hover:not(.disabled):not(:disabled) {
  background: rgba(245,193,39,0.15);
  border-color: rgba(245,193,39,0.80);
  transform: scale(1.12);
}
.hc-action-btn--undo.disabled,
.hc-action-btn--undo:disabled {
  color: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.07);
  filter: none;
  cursor: not-allowed;
}

/* ── Scroll-hint ───────────────────────────────────────────────────────────── */
#hc-scroll-hint {
  position: fixed;
  top: calc(80vh - 40px);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: rgba(255,255,255,0.70);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(0,0,0,0.75);
  user-select: none;
  z-index: 1;            /* bakom #main-content (60) – panel/list scrollar över */
  pointer-events: none;  /* dekorativ */
}
.hc-arrow {
  font-size: 1.2rem;
  margin-top: 4px;
  animation: imm-bounce 1.8s ease-in-out infinite;
}

/* ── My List pill badge ────────────────────────────────────────────────────── */
.hc-mylist-pill {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 5px;
  appearance: none;
  background: none;
  border: none;
}

.hc-mylist-badge {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -5px;
  right: -8px;
  background: #ffffff;
  color: #1a1a2e;
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0;
  line-height: 1;
}

/* ── Immersiv mode: dölj gamla hero-content, visa kort ────────────────────── */
body.immersive-mode #immersive-content { display: none !important; }
body.immersive-mode #immersive-scroll-hint { display: none !important; }

/* Bakom #main-content (z:60) – panel/list scrollar över korten */
body.immersive-mode #hc-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(80vh - 80px);
  z-index: 50;
  justify-content: flex-start;
  padding-top: 24px;
  pointer-events: none; /* bakgrunden fångar inte klick */
}

body.immersive-mode #hc-wrap > * {
  pointer-events: auto; /* knappar och deck är klickbara */
}

/* Counter + actions: flex-child i botten av wrappen – aldrig ovanpå korten */
body.immersive-mode #hc-ui {
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
  width: 100%;
  margin-top: auto; /* tar upp återstående flex-utrymme → knappar hamnar sist */
  pointer-events: auto;
  z-index: 0;
}

/*
 * Deck-höjd justeras så frontkortet (top: 38px) aldrig rinner förbi deck-kanten:
 * deck_h = card_h + 38 = (80vh − 268) + 38 = 80vh − 230
 * Balansen: padding-top(24) + deck-margin(32) + deck_h + auto-margin(8) + ui_h(86) = 80vh − 80 ✓
 */
body.immersive-mode #hc-deck {
  height: clamp(298px, calc(80vh - 230px), 748px);
}

/* Kortens höjd: 38 px mindre än decket → frontkortet slutar exakt vid deck-nederkant */
body.immersive-mode .hc-card {
  height: clamp(260px, calc(80vh - 268px), 710px);
}

/* ── Responsiv (mobil) ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body.immersive-mode #hc-wrap {
    height: calc(80vh - 80px);
  }

  #hc-deck {
    width: 360px;
    height: clamp(406px, calc(80vh - 190px), 655px);
    margin-top: 20px;
  }
  .hc-card {
    width: 322px;
    height: clamp(406px, calc(80vh - 190px), 655px);
  }
  .hc-card--front     { left: 38px; top: 29px; }
  .hc-card--next      { left: 19px; top: 14px; }
  .hc-card--promoting { left: 38px; top: 29px; }
  .hc-card-title { font-size: 20px; }
  #hc-actions { gap: 14px; }
  .hc-action-btn--dislike,
  .hc-action-btn--fav,
  .hc-action-btn--like { width: 55px; height: 55px; }

  #hc-scroll-hint {
    top: calc(80vh - 68px); /* = hc-wrap-botten (80vh-80px) + 12px, konsekvent med layout-viewport */
    bottom: auto;
  }
}

@media (max-height: 740px) {
  .hc-card--front     { top: 24px; }
  .hc-card--next      { top: 12px; }
  .hc-card--back2     { top:  6px; }
  .hc-card--promoting { top: 24px; }
}

/* ── Desktop landscape (≥ 900px) ─────────────────────────────────────────── */
@media (min-width: 900px) {
  /*
   * Balans (immersiv): padding(24) + margin(16) + deck_h + spacer(8) + ui(86) = 80vh−80
   * → deck_h = 80vh − 214
   */
  #hc-deck {
    width: min(calc(100vw - 120px), 1100px); /* kort + 62px stack-marginaler */
    height: clamp(380px, calc(80vh - 214px), 600px);
    margin-top: 16px;
  }

  .hc-card {
    width: min(calc(100vw - 182px), 1038px); /* deck - 62px */
    height: clamp(342px, calc(80vh - 252px), 562px); /* deck_h - 38px */
    border-radius: 18px;
    clip-path: inset(0 round 18px);
  }

  /* Bild: vänster 55 % av kortet, cover-beskuren (height: 100% krävs för att
     override:a img-elementets intrinsic ratio som annars begränsar höjden) */
  .hc-card-img {
    top: 0; bottom: 0;
    left: 0; right: auto;
    width: 55%;
    height: 100%;
    transform: none;
    object-fit: cover;
    object-position: center top;
  }

  /* Overlay: horisontell gradient justerad för 55 %-split */
  .hc-card-overlay {
    background: linear-gradient(
      to right,
      rgba(8,8,24,0)    32%,
      rgba(8,8,24,0.60) 48%,
      rgba(8,8,24,0.96) 58%,
      rgba(8,8,24,0.98) 100%
    );
  }

  /* Innehåll: höger panel (45 %), vertikalt centrerat */
  .hc-card-content {
    top: 0; bottom: 0;
    left: 55%; right: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 36px 32px 28px;
  }

  /* Typografi: generösare på stor skärm */
  .hc-card-meta     { margin-bottom: 16px; }
  .hc-cat-badge     { font-size: 10px; padding: 3px 10px; }
  .hc-card-date,
  .hc-card-dist     { font-size: 13px; }
  .hc-card-title    { font-size: 30px; margin-bottom: 12px; }
  .hc-card-venue    { font-size: 15px; margin-bottom: 10px; }
  .hc-card-desc     { font-size: 14px; -webkit-line-clamp: 6; }

  /* Stack-transforms: lättare rotation för landscape-kort */
  .hc-card--back3 { transform: rotate(-2deg)   translate(-15px, -8px) scale(0.90); }
  .hc-card--back2 { transform: rotate(-1deg)   translate(-8px,  -4px) scale(0.94); }
  .hc-card--next  { transform: rotate(-0.5deg) translate(-3px,  -1px) scale(0.97); }

  /* Exit-animationer: längre translateX för bredare kort */
  .hc-card--exiting.hc-exiting-like {
    transform: translateX(1100px) rotate(12deg) !important;
  }
  .hc-card--exiting.hc-exiting-dislike {
    transform: translateX(-1100px) rotate(-12deg) !important;
  }

  /* Immersiv läge: responsiva mått */
  body.immersive-mode #hc-deck {
    width: min(calc(100vw - 120px), 1100px);
    height: clamp(380px, calc(80vh - 214px), 600px);
  }
  body.immersive-mode .hc-card {
    width: min(calc(100vw - 182px), 1038px);
    height: clamp(342px, calc(80vh - 252px), 562px);
  }

  /* Stamps: överkant i landscape */
  .hc-stamp--like    { top: 22px; left: 26px; }
  .hc-stamp--dislike { top: 22px; right: 26px; }
}

/* Desktop + låg höjd (< 740px): anpassa stack-offset */
@media (min-width: 900px) and (max-height: 740px) {
  .hc-card--front     { top: 24px; }
  .hc-card--next      { top: 12px; }
  .hc-card--back2     { top:  6px; }
  .hc-card--promoting { top: 24px; }
}
