@layer components {
/*
  Ownership: canonical opt-in editorial image-card system.
  This file owns editorial grid sizing, media-card composition, metadata and
  footer treatment. card-core.css retains the neutral card shell; badges.css
  retains access-display styling; editorial-card-variants.css owns approved
  pillar variants; page styles remain scoped to their own presentation.

  This is opt-in while legacy landing-card selectors are retired incrementally.
  Pillars inherit the shared TGK canvas and supply accent tokens only.
*/

/* Ownership: editorial grid sizing. */
.editorial-card-system .portal-grid {
  justify-content: center;
  gap: clamp(1rem, 2.6vw, 2rem);
  row-gap: clamp(1.25rem, 3vw, 2.5rem);
  margin: 0;
  padding-inline: 0;
}

.editorial-card-grid .portal-grid {
  justify-content: center;
  gap: clamp(1rem, 2.6vw, 2rem);
  row-gap: clamp(1.25rem, 3vw, 2.5rem);
  margin: 0;
  padding-inline: 0;
}

.editorial-card-grid--single .portal-grid > .gnostic-card {
  flex: 0 1 100%;
  max-width: 100%;
}

.editorial-card-grid--two-up .portal-grid > .gnostic-card {
  flex: 0 1 calc((100% - clamp(1rem, 2.6vw, 2rem)) / 2);
  max-width: calc((100% - clamp(1rem, 2.6vw, 2rem)) / 2);
}

.editorial-card-grid--three-up .portal-grid > .gnostic-card {
  flex: 0 1 calc((100% - (2 * clamp(1rem, 2.6vw, 2rem))) / 3);
  max-width: calc((100% - (2 * clamp(1rem, 2.6vw, 2rem))) / 3);
}

@media (min-width: 1025px) {
  .editorial-card-system .portal-grid:not(.dashboard-portal-grid):has(> .gnostic-card:nth-child(3)) > .gnostic-card,
  .editorial-card-grid .portal-grid:has(> .gnostic-card:nth-child(3)) > .gnostic-card {
    flex: 0 1 calc((100% - (2 * clamp(1rem, 2.6vw, 2rem))) / 3);
    max-width: calc((100% - (2 * clamp(1rem, 2.6vw, 2rem))) / 3);
  }
}

.editorial-card-grid--two-up .gnostic-card:has(.card-media) .card-body,
.editorial-card-grid--single .gnostic-card:has(.card-media) .card-body {
  min-height: 14.5rem;
}

/* Ownership: editorial media-card composition. */
.editorial-card-system .gnostic-card:has(.card-media) {
  --card-radius: 8px;
  --card-bdr: color-mix(in srgb, var(--section-border) 78%, var(--highlight) 22%);
  --card-bg: transparent;
  background: transparent;
  backdrop-filter: var(--card-soft-backdrop);
  -webkit-backdrop-filter: var(--card-soft-backdrop);
  box-shadow:
    0 18px 40px color-mix(in srgb, var(--bg-primary) 84%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--highlight) 20%, transparent);
}

.editorial-card-system .gnostic-card:has(.card-media) .card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editorial-card-system .gnostic-card:has(.card-media) .card-media {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid color-mix(in srgb, var(--section-border) 72%, transparent);
}

.editorial-card-system .gnostic-card:has(.card-media) .card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100% !important;
  min-height: 0;
  transform: scale(1.01);
  transform-origin: center;
  transition: transform 0.35s ease;
}

.editorial-card-system .gnostic-card:has(.card-media) .card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: clamp(1.35rem, 2.8vw, 2rem);
  text-align: left;
  border-top: 0;
}

.editorial-card-system .gnostic-card:has(.card-media) .card-eyebrow {
  display: block;
  margin: 0 0 0.45rem;
  color: var(--text-accent);
  font-size: var(--type-eyebrow-size-compact, 0.72rem);
  font-weight: var(--type-weight-bold, 700);
  letter-spacing: var(--type-tracking-eyebrow, 0.12em);
  line-height: var(--type-eyebrow-line-compact, 1.3);
  text-transform: uppercase;
}

.editorial-card-system .gnostic-card:has(.card-media) .card-title {
  color: var(--text-primary);
  font-family: var(--page-title);
  font-size: clamp(1.134rem, 2.106vw, 1.62rem);
  line-height: var(--type-heading-line, 1.08);
  letter-spacing: 0;
  text-transform: none;
  text-shadow: none;
}

.editorial-card-system .gnostic-card:has(.card-media) .card-desc {
  max-width: 62ch;
  margin: 0.7rem 0 0;
  color: var(--text-secondary);
  font-size: var(--type-card-desc-size-excerpt, 0.8em);
  line-height: var(--type-card-desc-line-editorial, 1.65);
}

/* Ownership: editorial footer and metadata.
   A real footer owns the divider and optional read metadata. This avoids the
   description-dependent pseudo-footer used by older card variants. */
.editorial-card-system .gnostic-card:has(.editorial-card__footer) .card-body {
  min-height: 16rem;
}

.editorial-card-system .gnostic-card:has(.editorial-card__footer) .card-body::after {
  content: none !important;
  display: none !important;
}

.editorial-card-system .gnostic-card:has(.editorial-card__footer) .badge-br {
  display: none !important;
}

/* Dashboard contribution cards use their existing metadata footer rather
   than the generic image-card pseudo-footer. */
.editorial-card-system .dashboard-keys-contribution-card .card-body::after {
  content: none !important;
  display: none !important;
}

.editorial-card-system .dashboard-bookmark-card .card-body::after {
  content: none !important;
  display: none !important;
}

.editorial-card-system .progress-history-card .card-body::after {
  content: none !important;
  display: none !important;
}

.editorial-card-system .dashboard-keys-timeline-card .card-body::after {
  content: none !important;
  display: none !important;
}

/* Ownership: dashboard card decoration. Dashboard pages use dedicated
   card footers and do not carry the editorial-card-system body class, so
   these scoped exceptions live here with the shared pseudo-element rules. */
:is(
  .dashboard-keys-timeline-card,
  .dashboard-keys-contribution-card,
  .dashboard-the-read-card,
  .dashboard-most-active-card,
  .dashboard-highest-engagement-card,
  .progress-history-card,
  .dashboard-keys-card,
  #dashboard-progress-card,
  #dashboard-continue-card
) .card-body::after {
  content: none !important;
  display: none !important;
}

#page-dashboard .gnostic-card::before,
#page-dashboard .gnostic-card::after,
#page-dashboard-keys .gnostic-card::before,
#page-dashboard-keys .gnostic-card::after,
#page-dashboard-progress .gnostic-card::before,
#page-dashboard-progress .gnostic-card::after,
#community-profile-root .gnostic-card::before,
#community-profile-root .gnostic-card::after {
  content: none !important;
  display: none !important;
}

body.requires-auth:not(.admin) #section-bookmarks .bookmark-grid > .gnostic-card:has(.dashboard-card__footer) .card-body::after {
  content: none !important;
  display: none !important;
}

.editorial-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: clamp(0.75rem, 1.4vw, 1rem);
  border-top: 1px solid color-mix(in srgb, var(--section-border) 72%, var(--highlight) 18%);
  color: var(--text-accent);
  font-size: var(--type-metadata-size-card, 0.72rem);
  font-weight: var(--type-weight-bold, 700);
  letter-spacing: var(--type-metadata-tracking-card, 0.12em);
  line-height: 1;
  text-transform: uppercase;
  opacity: 0.82;
}

.editorial-card__meta {
  margin-left: auto;
  white-space: nowrap;
}

.editorial-card__access {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  white-space: nowrap;
}

.editorial-card-system .gnostic-card:has(.card-media) .card-body::after {
  content: attr(data-card-enter-label) !important;
  display: flex;
  width: 100%;
  align-self: stretch;
  align-items: center;
  margin-top: auto;
  padding-top: clamp(0.75rem, 1.4vw, 1rem);
  padding-right: clamp(8rem, 26vw, 14rem);
  border-top: 1px solid color-mix(in srgb, var(--section-border) 72%, var(--highlight) 18%);
  color: var(--text-accent);
  font-size: 0.72rem;
  font-weight: var(--type-weight-bold, 700);
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
  opacity: 0.82;
}

/* Card metadata: one access pill, then an unwrapped editorial footer row. */
.editorial-card-system .gnostic-card:has(.card-media) .badge-tl {
  display: none !important;
}

.editorial-card-system .gnostic-card:has(.card-media) .badge-tr {
  top: clamp(0.75rem, 1.4vw, 1rem);
  right: clamp(0.75rem, 1.4vw, 1rem);
}

.editorial-card-system .gnostic-card:has(.card-media) .badge-tr .tier-badge {
  min-height: 1.45rem;
  padding: 0.28rem 0.62rem;
  border: 1px solid color-mix(in srgb, var(--section-border) 54%, var(--highlight) 46%);
  border-radius: 4px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--highlight) 13%, transparent), transparent 68%),
    color-mix(in srgb, var(--bg-primary) 72%, transparent);
  box-shadow:
    0 8px 18px color-mix(in srgb, var(--bg-primary) 55%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--highlight) 22%, transparent);
  color: color-mix(in srgb, var(--text-accent) 88%, var(--text-primary) 12%) !important;
  font-family: var(--font-ui);
  font-size: var(--type-badge-size-tier, 0.68rem);
  font-weight: var(--type-weight-bold, 700);
  letter-spacing: var(--type-badge-tracking-tier, 0.09em);
  line-height: var(--type-badge-line, 1);
  text-transform: uppercase;
  backdrop-filter: blur(6px);
}

.editorial-card-system .gnostic-card:has(.card-media) :is(.badge-bl, .badge-br) {
  right: clamp(1.35rem, 2.8vw, 2rem);
  bottom: clamp(1.35rem, 2.8vw, 2rem);
  left: auto;
  margin: 0;
}

.editorial-card-system .gnostic-card:has(.card-media) :is(.badge-bl, .badge-br) .tier-badge {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  color: var(--text-accent) !important;
  font-family: inherit;
  font-size: var(--type-badge-size-corner, 0.72rem);
  font-weight: var(--type-weight-bold, 700);
  letter-spacing: var(--type-badge-tracking-corner, 0.12em);
  line-height: var(--type-badge-line, 1);
  text-transform: uppercase;
  text-shadow: 0 1px 10px color-mix(in srgb, var(--bg-primary) 84%, transparent);
}

.editorial-card-system .gnostic-card:has(.card-media) .state-badge {
  opacity: 0.82;
}

.editorial-card-system .gnostic-card:has(.card-media):is(:hover, :focus-within) .card-media img {
  transform: scale(1.045);
}

/* Ownership: editorial mobile density. */
@media (max-width: 767px) {
  .editorial-card-grid .portal-grid > .gnostic-card {
    flex: 0 1 100%;
    max-width: 100%;
  }

  .editorial-card-grid--two-up .gnostic-card:has(.card-media) .card-body,
  .editorial-card-grid--single .gnostic-card:has(.card-media) .card-body {
    min-height: 0;
  }

  .editorial-card-system .gnostic-card:has(.card-media) .card-body::after {
    padding-right: 0;
  }

  .editorial-card-system .gnostic-card:has(.editorial-card__footer) .card-body {
    min-height: 0;
  }

  .editorial-card__footer {
    margin-top: 0.75rem;
  }

  .editorial-card-system .gnostic-card:has(.card-media) :is(.badge-bl, .badge-br) {
    right: clamp(1.25rem, 6vw, 1.5rem);
    bottom: clamp(1.25rem, 6vw, 1.5rem);
  }
}
}
