/*
 * Modern toplist row. Paired with components/CasinoCardModern.tsx and loaded
 * only when CASINO_CARD=modern — see lib/flags.ts for the rollback.
 *
 * Namespaced `ccm__` on purpose: the theme's `.casino` styles stay untouched,
 * so switching back to the classic card needs nothing undone here.
 *
 * Colours are the site's own, darkened where they had to be to pass WCAG AA:
 *   text      #222 on white      15.9:1
 *   muted     #555 on white       7.5:1
 *   CTA       #222 on #f6cd46    10.4:1
 *   link      #0f6f7a on white    5.9:1   (brand teal #4da8b3 is 2.8:1 and fails)
 *   rank      #8a5a00 on #fff8e6  5.6:1
 */

.casino-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ccm {
  position: relative;
  background: #fff;
  border: 1px solid #e3e6e8;
  border-radius: 14px;
  padding: 18px 20px;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.ccm:hover {
  border-color: var(--color-primary, #4da8b3);
  box-shadow: 0 8px 24px rgba(15, 111, 122, 0.12);
  transform: translateY(-1px);
}

/* The first row is the recommendation, so it is allowed to look like one. */
.ccm--featured {
  border-color: var(--color-primary, #4da8b3);
  border-width: 2px;
  box-shadow: 0 6px 18px rgba(15, 111, 122, 0.1);
}

.ccm__ribbon {
  position: absolute;
  top: -11px;
  left: 20px;
  margin: 0;
  padding: 2px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #222;
  background: #f6cd46;
  border-radius: 999px;
}

/* 4 columns on desktop: brand, name, selling points, actions. */
.ccm__grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1.1fr) minmax(0, 1.2fr) 210px;
  align-items: center;
  gap: 20px;
}

.ccm__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ccm__rank {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #8a5a00;
  background: #fff8e6;
  border-radius: 50%;
}

.ccm__logo {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 68px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f2f4f5;
  overflow: hidden;
}

/*
 * Explicit pixel caps, not `max-height: 100%`: the percentage resolves against
 * an auto containing block and is ignored, so a square 250x250 logo rendered
 * at 170px inside a 60px tile and was cropped to a dome. The margin reset is
 * for the site's `.entry-content img { margin-bottom: 15px }`.
 */
.ccm .ccm__logo img {
  display: block;
  max-width: 100%;
  max-height: 52px;
  width: auto;
  height: auto;
  margin: 0;
  object-fit: contain;
}

.ccm__name {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
  color: #222;
}

/* The number is in the heading for screen readers and narrow screens, but the
   badge already shows it on desktop, so it is hidden there. */
.ccm__name-rank {
  display: none;
}

.ccm__excerpt {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: #555;
}

/*
 * The list sits inside `.entry-content`, whose own `ul li::before` is a
 * rotated triangle defined in the site's Additional CSS. That selector is
 * three classes deep, so these have to match it to win — specificity, not
 * order, decides this one.
 */
.ccm .ccm__points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ccm .ccm__points li {
  position: relative;
  padding-left: 22px;
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  color: #222;
}

/* A check mark drawn in CSS: no icon font, no extra request. */
.ccm .ccm__points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.34em;
  width: 11px;
  height: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 2px solid var(--color-primary, #4da8b3);
  border-bottom: 2px solid var(--color-primary, #4da8b3);
  border-radius: 0;
  transform: rotate(-45deg);
}

.ccm__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.ccm__cta {
  display: block;
  padding: 13px 16px;
  border-radius: 10px;
  background: #f6cd46;
  color: #222;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.18s ease;
}

.ccm__cta:hover,
.ccm__cta:focus-visible {
  background: #eebe2a;
  color: #222;
  text-decoration: none;
  transform: translateY(-1px);
}

.ccm__review {
  font-size: 13px;
  text-align: center;
  color: #0f6f7a;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ccm__review:hover {
  color: #0a5f69;
}

/* Keyboard focus has to be visible on both the card's links. */
.ccm a:focus-visible {
  outline: 3px solid #0f6f7a;
  outline-offset: 2px;
}

/* Visually hidden, still read aloud — the CTAs would otherwise be 12
   identical "Spela Nu" links to a screen-reader user. */
.ccm__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------- tablet */
@media (max-width: 991px) {
  .ccm__grid {
    grid-template-columns: 150px minmax(0, 1fr) 190px;
    grid-template-areas:
      "brand body actions"
      "brand points actions";
    align-items: start;
    row-gap: 10px;
  }
  .ccm__brand { grid-area: brand; align-self: center; }
  .ccm__body { grid-area: body; }
  .ccm__points { grid-area: points; }
  .ccm__actions { grid-area: actions; align-self: center; }
}

/* ---------------------------------------------------------- mobile */
@media (max-width: 767px) {
  .ccm {
    padding: 16px;
  }

  .ccm__grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "body"
      "points"
      "actions";
    gap: 12px;
  }

  .ccm__brand {
    justify-content: center;
  }

  /* Narrower and taller than desktop: the logos are a mix of wide wordmarks
     and square badges, and a wide short tile leaves the square ones adrift. */
  .ccm__logo {
    flex: 0 1 170px;
    height: 76px;
  }

  .ccm .ccm__logo img {
    max-height: 60px;
  }

  /* The badge is dropped on mobile and the number moves into the heading,
     which keeps the row's order obvious without spending a line on it. */
  .ccm__rank {
    display: none;
  }

  .ccm__name,
  .ccm__excerpt {
    text-align: center;
  }

  .ccm__name-rank {
    display: inline;
    color: #8a5a00;
  }

  .ccm__cta {
    padding: 15px 16px;
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ccm,
  .ccm__cta {
    transition: none;
  }
  .ccm:hover,
  .ccm__cta:hover {
    transform: none;
  }
}
