/*
 * Triton Blog Feed — the default design: the tbf-* classes in the default templates
 * (Services/Settings/FeedSettings.cs). No build step: save and hard-refresh.
 *
 * Loaded only when a feed's templates use tbf-* classes (Controls/FeedView.cs). A feed with its own
 * templates (every feed upgraded from 02.x) is styled by the skin alone, as before.
 *
 * Every selector is wrapped in :where(), so every rule here has ZERO specificity: any rule in the
 * skin's CSS (core.min.css) that matches the same element wins, whatever order the files load in.
 * Restyle the cards from the skin with plain selectors — .tbf-card { … } is enough.
 *
 * Colours and fonts come from the site's tokens, with the Triton skin's defaults as fallbacks:
 *   --font-headline (titles), --font-body, --color-primary (accent), --color-dark-shade (text),
 *   --color-light-shade (borders).
 * Per-feed overrides: --triton-blog-feed-accent, -gap, -radius, -surface, -border, -shadow,
 * -max-width, -title-size, -ratio (the image box's shape, default 3 / 2).
 *
 * Column classes on the wrapper: tbf--c1 … tbf--c4. The grid drops to 2 columns below 900px of feed
 * width and 1 below 560px (container queries). Use CSS escapes, not literal characters, in content:.
 */

:where(.tbf) {
  --tbf-accent: var(--triton-blog-feed-accent, var(--color-primary, #9e2065));
  --tbf-ink: var(--color-dark-shade, #222);
  --tbf-line: var(--triton-blog-feed-border, var(--color-light-shade, #e6e6e6));
  --tbf-surface: var(--triton-blog-feed-surface, #fff);
  --tbf-gap: var(--triton-blog-feed-gap, 24px);
  --tbf-radius: var(--triton-blog-feed-radius, 12px);
  --tbf-shadow: var(--triton-blog-feed-shadow, 0 1px 2px rgba(20, 20, 20, 0.06), 0 6px 20px -12px rgba(20, 20, 20, 0.25));

  container-type: inline-size;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--triton-blog-feed-max-width, 1248px);
  margin-inline: auto;
}

:where(.tbf *, .tbf *::before, .tbf *::after) {
  box-sizing: border-box;
}

/* --- Editor-only: the Feed settings button and notices ---------------------------- */

:where(.tbf-toolbar) {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

:where(.tbf-settings-button) {
  font: inherit;
  font-size: 0.875rem;
  padding: 6px 14px;
  border: 1px solid #0f3a57;
  border-radius: 999px;
  background: #fff;
  color: #0f3a57;
  cursor: pointer;
}

:where(.tbf-settings-button:hover, .tbf-settings-button:focus-visible) {
  background: #0f3a57;
  color: #fff;
}

:where(.tbf-notice) {
  align-self: stretch;
  margin: 0;
  padding: 10px 14px;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 0.9375rem;
}

/* --- Grid ---------------------------------------------------------------------------- */

:where(.tbf-grid) {
  display: grid;
  grid-template-columns: repeat(var(--tbf-cols, 3), minmax(0, 1fr));
  gap: var(--tbf-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

:where(.tbf--c1 .tbf-grid) { --tbf-cols: 1; }
:where(.tbf--c2 .tbf-grid) { --tbf-cols: 2; }
:where(.tbf--c3 .tbf-grid) { --tbf-cols: 3; }
:where(.tbf--c4 .tbf-grid) { --tbf-cols: 4; }

@container (max-width: 899px) {
  :where(.tbf--c3 .tbf-grid, .tbf--c4 .tbf-grid) {
    --tbf-cols: 2;
  }
}

@container (max-width: 559px) {
  :where(.tbf .tbf-grid) {
    --tbf-cols: 1;
  }
}

:where(.tbf-item) {
  display: flex;
  margin: 0;
  padding: 0;
}

/* --- Card ------------------------------------------------------------------------------- */

:where(.tbf-card) {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--tbf-line);
  border-radius: var(--tbf-radius);
  background: var(--tbf-surface);
  box-shadow: var(--tbf-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

:where(.tbf-card:hover) {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(20, 20, 20, 0.06), 0 16px 32px -16px rgba(20, 20, 20, 0.35);
}

:where(.tbf-card:focus-within) {
  outline: 3px solid var(--tbf-accent);
  outline-offset: 2px;
}

/* The box is reserved before the photo arrives: no layout shift. A post without an image has an empty box, hidden. */
:where(.tbf-media) {
  position: relative;
  aspect-ratio: var(--triton-blog-feed-ratio, 3 / 2);
  overflow: hidden;
  background: color-mix(in srgb, var(--tbf-ink) 8%, transparent);
}

:where(.tbf-media:empty) {
  display: none;
}

:where(.tbf-media picture) {
  display: contents;
}

:where(.tbf-media .tbf-img) {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

:where(.tbf-card:hover .tbf-img) {
  transform: scale(1.04);
}

:where(.tbf-body) {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: clamp(16px, 2vw, 22px);
}

:where(.tbf-meta) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 0;
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--tbf-ink) 70%, transparent);
}

:where(.tbf-category) {
  font-family: var(--font-headline, inherit);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tbf-accent);
}

:where(.tbf-category + .tbf-date)::before {
  content: '\00b7';
  margin-right: 10px;
  color: var(--tbf-line);
}

/* The one exception to zero specificity: skins give h2–h4 a top margin with selectors this can't
   outrank otherwise, and the card's gap already does the spacing. */
.tbf-card-title {
  margin-top: 0 !important;
}

:where(.tbf-card-title) {
  margin-bottom: 0;
  font-family: var(--font-headline, inherit);
  font-size: var(--triton-blog-feed-title-size, 1.25rem);
  line-height: 1.25;
}

:where(.tbf-link) {
  color: var(--tbf-ink);
  text-decoration: none;
}

:where(.tbf-link:hover) {
  color: var(--tbf-accent);
}

/* The card's single link, stretched over the whole card: the whole card is clickable. */
:where(.tbf-link)::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

:where(.tbf-link:focus-visible) {
  outline: none;
}

:where(.tbf-summary) {
  margin: 0;
  color: color-mix(in srgb, var(--tbf-ink) 82%, transparent);
  line-height: 1.55;
}

:where(.tbf-more) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--font-headline, inherit);
  font-weight: 700;
  color: var(--tbf-accent);
}

:where(.tbf-more)::after {
  content: '\2192';
  transition: transform 0.2s ease;
}

:where(.tbf-card:hover .tbf-more)::after {
  transform: translateX(4px);
}

@media (prefers-reduced-motion: reduce) {
  :where(.tbf-card, .tbf-media .tbf-img) {
    transition: none;
  }

  /* A pseudo-element cannot go inside :where(), so this one sits after it. */
  :where(.tbf-more)::after {
    transition: none;
  }

  :where(.tbf-card:hover, .tbf-card:hover .tbf-img) {
    transform: none;
  }
}
