/* ============================================================
   Media Library — Editorial card variant
   Opt-in via `.cw-card.cw-card--editorial`. Unprefixed cw-card
   styles elsewhere in the app are untouched.
   ============================================================ */

/* Grid override when ANY child is editorial — bigger rectangles for visual weight */
.cw-grid:has(.cw-card--editorial) {
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 18px;
}
/* Admin tiles carry more chrome (4 action buttons + caption + tags +
   access avatars), so they need more room. Wider also means fewer cards
   per row → fewer DOM nodes on initial paint → faster first scroll. */
.cw-grid:has(.cw-card--editorial.cw-card--admin) {
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 20px;
}

.cw-card.cw-card--editorial {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: clamp(12px, 1.5vw, 16px);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cw-card.cw-card--editorial:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent, #e4f91b) 35%, transparent);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

/* Body wrapper — replaces the old cw-card__header + meta */
.cw-card--editorial .cw-card__body {
  padding: 12px 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.cw-card--editorial .cw-card__title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.32;
  color: #fff;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cw-card--editorial .cw-card__caption {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cw-card--editorial .cw-card__meta-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  flex-wrap: wrap;
}

/* Category badges — semantic, NOT theme-tinted */
.cw-card__cat {
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.cw-card__cat--drill    { background: rgba(228, 249, 27, 0.18); color: #e4f91b; }
.cw-card__cat--common   { background: rgba(99, 179, 237, 0.18); color: #63b3ed; }
.cw-card__cat--shared   { background: rgba(255, 200, 80, 0.18); color: #ffc850; }
.cw-card__cat--for-user { background: rgba(255, 128, 180, 0.18); color: #ff80b4; }

/* Tag chips — neutral white-tinted */
.cw-card--editorial .cw-card__tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 1px;
}
.cw-card__tag {
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.62);
  font-size: 10px;
}

/* Avatar stack (admin only — shown when access_users non-empty) */
.cw-card--editorial .cw-card__access {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 2px;
}
.cw-card__avatars { display: flex; }
.cw-card__avatars span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(0, 0, 0, 0.4);
  margin-left: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
}
.cw-card__avatars span:first-child { margin-left: 0; }

/* Hover-reveal actions on editorial cards. Forced visible on touch / mobile. */
.cw-card--editorial .cw-card__actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.cw-card.cw-card--editorial:hover .cw-card__actions { opacity: 1; }
@media (hover: none) {
  .cw-card--editorial .cw-card__actions { opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────
   Responsive tiers
   ────────────────────────────────────────────────────────────── */

/* Tablet portrait (~iPad ≤ 1024 wide). Admin's 480px min would collapse
   to 1 column on an 800px viewport; drop it to a smaller min so we keep
   2 cols where possible. User side keeps 400 (already comfortable). */
@media (max-width: 1024px) {
  .cw-grid:has(.cw-card--editorial.cw-card--admin) {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
  }
}

/* Phone portrait — single column, tighter chrome, smaller type. */
@media (max-width: 600px) {
  .cw-grid:has(.cw-card--editorial) {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .cw-card--editorial .cw-card__body {
    padding: 10px 12px 4px;
    gap: 6px;
  }
  .cw-card--editorial .cw-card__title { font-size: 15px; }
  .cw-card--editorial .cw-card__caption { font-size: 12.5px; }
  .cw-card--editorial .cw-card__actions {
    padding: 8px 12px 10px;
    flex-wrap: wrap;
    opacity: 1;
  }
  .cw-card--editorial .cw-card__access { font-size: 10.5px; }
  .cw-card__cat { font-size: 9.5px; padding: 2px 7px; }
  .cw-card__tag { font-size: 9.5px; }
}

/* Phone landscape — header was eating viewport on iPhone 14 landscape
   (~430×390 visible after CF iframe etc); compress card padding further
   so the visual area dominates. Pattern matches the report-template
   landscape rule added in PR #124. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .cw-card--editorial .cw-card__body { padding: 8px 12px 4px; gap: 5px; }
  .cw-card--editorial .cw-card__title { font-size: 14px; }
  .cw-card--editorial .cw-card__caption {
    -webkit-line-clamp: 1;
    font-size: 12px;
  }
  .cw-card--editorial .cw-card__actions { padding: 6px 12px 8px; }
}

/* Admin mobile shell — cards render into #mMediaList (NOT cw-grid),
   so the cw-grid rules above don't apply. Give the list a flex column
   with gap, and ensure actions are visible (no hover on touch). */
body.shell-mobile-on .m-media-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 12px 96px; /* extra bottom for tab bar */
}
body.shell-mobile-on .m-media-list .cw-card--editorial .cw-card__actions {
  opacity: 1;
  padding: 8px 12px 10px;
  flex-wrap: wrap;
}
body.shell-mobile-on .m-media-list .cw-card--editorial .cw-card__body {
  padding: 10px 12px 4px;
}
