/* ====== card ====== */
.card-grid {
  display: grid;
  gap: 22px;
  max-width: 1100px;
  margin-inline: auto;
}

.card {
  height: 100%;
  box-shadow: var(--shadow);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
html[data-theme="dark"] .card {
  box-shadow: none; /* keep dark clean */
}

.card-pad {
  padding: 18px;
}
@media (max-width: 700px) {
  .card-pad {
    padding: 14px;
  }
}

.card-media {
  aspect-ratio: 16 / 9;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.card-media.is-missing::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.files-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  flex: 1;
}
.card-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap; /* nice on small screens */
}
.card-actions .btn:first-child {
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
}
.card-more {
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 10px;
}
.card-more:hover {
  background: var(--hover);
  text-decoration: none;
}
/* keep for learning. .card:not(.is-expanded) .card-preview { ... } */
.card.is-expanded .card-preview {
  color: var(--text);
  overflow: visible;
}
.card-title {
  line-height: 1.25;
  margin: 0 0 6px;
  font-weight: 700;
}
.card-link {
  align-self: flex-start;
}
.card.is-clickable {
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}
.card.is-clickable:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--border) 60%, var(--text));
  background: var(--hover);
}
.card.is-clickable:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text) 55%, transparent);
  outline-offset: 3px;
}

/* Home: 2 columns on large screens */
.card-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .card-grid--2 {
    grid-template-columns: 1fr;
  }
}

/* ====== media ====== */
.media-grid {
  display: grid;
  gap: 14px;

  /* fixed card columns */
  grid-template-columns: repeat(auto-fit, 260px);

  /* this is the key: center the whole row */
  justify-content: center;

  max-width: 1100px;
  margin-inline: auto;
}
.media-item {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.media-item img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.media-item.is-missing {
  position: relative;
  height: 180px; /* fixed height same as images */
}
.media-item.is-missing::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.gallery-item img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}
.media-caption {
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
}
