/* ==========================================================================
   B-Digital Mark blog -- article cards (listings and related posts).
   Shared by list and single views; depends on base.css tokens.

   Every card is the same rectangle: a 2:1 picture on top, shown at its own
   proportions so it stays sharp, and the text below. Cards in a row stretch
   to equal height. A post without a featured image gets a colour-orb picture.
   ========================================================================== */

.bdmb-bento {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 1.8vw, 1.6rem);
}

.bdmb-card {
  --a: #ff8c00;
  --b: #ff4d00;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--bdmb-glass-line);
  border-radius: var(--bdmb-radius);
  background: linear-gradient(160deg, rgba(20, 30, 62, 0.66), rgba(8, 13, 30, 0.8));
  -webkit-backdrop-filter: var(--bdmb-blur);
  backdrop-filter: var(--bdmb-blur);
  box-shadow: var(--bdmb-glass-hi), var(--bdmb-shadow);
  transition: transform 0.5s var(--bdmb-ease), box-shadow 0.5s ease, border-color 0.4s ease;
}
.bdmb-card:hover,
.bdmb-card:focus-within {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--a) 55%, rgba(255, 255, 255, 0.2));
  box-shadow:
    var(--bdmb-glass-hi),
    0 2px 4px rgba(2, 5, 14, 0.4),
    0 28px 60px -20px color-mix(in srgb, var(--a) 30%, transparent),
    0 40px 90px -30px rgba(2, 5, 14, 0.7);
}

/* Cursor spotlight over the whole card (position set by cards.js). */
.bdmb-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(520px circle at var(--mx, 70%) var(--my, 30%), rgba(255, 255, 255, 0.07), transparent 55%);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.bdmb-card:hover::before { opacity: 1; }

/* ---- Picture: always 2:1, never cropped by a taller card ---- */
.bdmb-card__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 2 / 1;
  background: #070b18;
}
.bdmb-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--bdmb-ease);
}
.bdmb-card:hover .bdmb-card__img { transform: scale(1.03); }

/* Fallback picture for posts without a featured image. */
.bdmb-card__media--orb {
  background:
    radial-gradient(circle at 28% 42%, var(--a), var(--b) 46%, transparent 74%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--b) 60%, transparent), transparent 55%),
    #070b18;
}
.bdmb-card__num {
  position: absolute;
  left: 1.4rem;
  bottom: 0.9rem;
  font-family: var(--bdmb-font-display);
  font-size: clamp(3.6rem, 6vw, 5.2rem);
  line-height: 0.8;
  letter-spacing: 0.03em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(240, 237, 232, 0.55);
}

.bdmb-card__tag {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 3;
  padding: 0.42rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(6, 10, 24, 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--bdmb-glass-hi);
  color: var(--bdmb-text);
  font-family: var(--bdmb-font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.bdmb-card__tag:hover {
  background: var(--bdmb-orange);
  border-color: var(--bdmb-orange);
  color: #080808;
}

/* ---- Text ---- */
.bdmb-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.7rem;
  padding: clamp(1.1rem, 1.8vw, 1.6rem);
}
.bdmb-card__meta {
  font-family: var(--bdmb-font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(240, 237, 232, 0.55);
}
.bdmb-card__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: clamp(1.15rem, 1.5vw, 1.35rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
/* Stretched link: the whole card is one target. */
.bdmb-card__title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
}
.bdmb-card__excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: 0.94rem;
  line-height: 1.6;
  color: rgba(240, 237, 232, 0.7);
}
.bdmb-card__more {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.4rem;
  font-family: var(--bdmb-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.bdmb-card__more::after {
  content: '\2192';
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
  letter-spacing: 0;
  transition: transform 0.35s var(--bdmb-ease), background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.bdmb-card:hover .bdmb-card__more::after,
.bdmb-card:focus-within .bdmb-card__more::after {
  transform: translateX(6px);
  background: var(--bdmb-orange);
  border-color: var(--bdmb-orange);
  color: #080808;
}

@media (max-width: 1000px) {
  .bdmb-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .bdmb-bento { grid-template-columns: minmax(0, 1fr); }
}

/* Scroll reveal: hidden only after cards.js has run (see cards.js). */
.bdmb-reveal .bdmb-card {
  opacity: 0;
  transform: translateY(34px) scale(0.985);
  transition: opacity 0.8s ease, transform 0.9s var(--bdmb-ease), box-shadow 0.5s ease, border-color 0.4s ease;
}
.bdmb-reveal .bdmb-card.is-in {
  opacity: 1;
  transform: none;
}
.bdmb-reveal .bdmb-card.is-in:hover,
.bdmb-reveal .bdmb-card.is-in:focus-within { transform: translateY(-4px); }

/* Without backdrop-filter, fall back to a more opaque panel. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bdmb-card { background: linear-gradient(160deg, #141e3e, #0a0f20); }
}

@media (prefers-reduced-motion: reduce) {
  .bdmb-card,
  .bdmb-card:hover,
  .bdmb-card:focus-within,
  .bdmb-card:hover .bdmb-card__img,
  .bdmb-card:hover .bdmb-card__more::after { transform: none; }
}
