/*
 * learn.css — Learn / "The Data" page (PLAN Step 13, sub-step 2). Consumes
 * tokens.css only; zero literals outside the sanctioned @media breakpoints (each
 * commented with its --bp-* token name). Enqueued only on the `learn` page slug
 * (see functions.php).
 *
 * The card grid borrows the shop grid idiom (surface panel, hairline edge,
 * 1-up → 2-up → 3-up) re-expressed for article cards (ref-05 blog/article grid):
 * media over meta/title/excerpt, the whole card a single link. The empty state
 * reuses the dashed-hairline .reviews-empty treatment. Reuses .media-placeholder
 * + .build-note from components.css.
 */

/* — Section rhythm — mirrors .shop-section / .home-section cadence. — */
.learn-section {
  padding-block: var(--space-80);
}

/* ============================================================
 * Intro — eyebrow + title + lead (the sitewide section-head pattern).
 * ============================================================ */
.learn-intro__head {
  max-width: var(--container-narrow);
  margin-block-end: var(--space-48);
}

.learn-intro__eyebrow {
  display: inline-block;
  margin-block-end: var(--space-16);
  font-size: var(--type-caption);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.learn-intro__title {
  margin-block-end: var(--space-24);
  letter-spacing: var(--tracking-tight);
}

.learn-intro__lead {
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

/* ============================================================
 * Search (Phase 5, A2) — the Learn search capsule. Mirrors the .capture
 * field/pill pair (components.css) but with its own classes so capture.js
 * never binds to it: a pill surface holding an icon, the field and a nested
 * solid-brand submit. Lives inside the intro head (narrow measure).
 * ============================================================ */
.learn-search {
  margin-block-start: var(--space-32);
}

.learn-search__row {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-4);
  padding-inline-start: var(--space-20);
  background-color: var(--color-surface-2);
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-pill);
  transition: border-color var(--duration-fast);
}

.learn-search__row:focus-within {
  border-color: var(--color-brand);
}

.learn-search__icon {
  flex: 0 0 auto;
  width: var(--space-20);
  height: var(--space-20);
  color: var(--color-text-muted);
}

.learn-search__field {
  flex: 1 1 auto;
  min-width: 0;
  padding-block: var(--space-8);
  background: transparent;
  border: 0;
  border-radius: var(--radius-none);
  color: var(--color-text);
  font-size: var(--type-body);
  letter-spacing: var(--tracking-normal);
  -webkit-appearance: none;
  appearance: none;
}

.learn-search__field::placeholder {
  color: var(--color-text-muted);
}

.learn-search__field:focus {
  outline: none;
}

.learn-search__field::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.learn-search__submit {
  flex: 0 0 auto;
  padding: var(--space-8) var(--space-20);
  background-color: var(--color-brand);
  border: var(--border-hairline) solid var(--color-brand);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: var(--type-body);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  cursor: pointer;
  transition: background-color var(--duration-fast), border-color var(--duration-fast);
}

.learn-search__submit:hover,
.learn-search__submit:focus-visible {
  background-color: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}

/* Empty-state action (search.php) — a ghost pill back to the full list. */
.learn-empty__action {
  margin-block-start: var(--space-16);
}

/* Pagination (search.php) — WP's .nav-links row, tokenized: caption-size
   uppercase links, the current page in brand red. */
.learn-pagination {
  margin-block-start: var(--space-48);
}

.learn-pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-16);
  font-size: var(--type-caption);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.learn-pagination .page-numbers {
  color: var(--color-text-muted);
}

.learn-pagination a.page-numbers:hover,
.learn-pagination a.page-numbers:focus-visible {
  color: var(--color-text);
}

.learn-pagination .page-numbers.current {
  color: var(--color-brand);
}

/* ============================================================
 * Grid — article cards. 1-up → 2-up at --bp-md → 3-up at --bp-lg
 * (mirrors the shop grid cadence).
 * ============================================================ */
.learn-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-24);
}

.learn-card {
  /* Clip the flush-edge cover image to the card's rounded corners (the media
     has no radius of its own, so without this its top corners poke past the
     card's --radius-none curve). */
  overflow: hidden;
  background-color: var(--color-surface);
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-none);
  /* Tactile hover cue (Step 14) — matches shop/cross-sell cards: border + surface
     shift, flat/clinical, no shadow. The transition lives HERE (the border is on
     the card, not the inner link), so the cue eases in. Reduced-motion drops it. */
  transition: border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

/* The whole card is one link: media + body stacked. */
.learn-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

/* The card clips its overflow (rounded media corners), which would also clip the
   global outset focus ring — draw it inset on the link and round it to match. */
.learn-card__link:focus-visible {
  outline-offset: calc(-1 * var(--space-2));
  border-radius: var(--radius-none);
}

/* Hover/focus-within: edge brightens + surface lifts one step (surface →
   surface-2), consistent with the shop + cross-sell cards. */
.learn-card:hover,
.learn-card:focus-within {
  border-color: var(--color-text-muted);
  background-color: var(--color-surface-2);
}

/* Media sits flush to the card edges (the card padding lives on the body). */
.learn-card__media {
  border: 0;
}

.learn-card__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.learn-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-24);
}

.learn-card__meta {
  font-size: var(--type-caption);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.learn-card__title {
  font-family: var(--font-display);
  font-size: var(--type-subheading);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--color-text);
}

.learn-card__excerpt {
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

/* "Read" cue pinned to the card foot; brand-red so it reads as the action. */
.learn-card__cue {
  margin-block-start: auto;
  padding-block-start: var(--space-16);
  font-size: var(--type-caption);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-brand);
}

/* ============================================================
 * Empty state — until the first article publishes (dashed-hairline surface,
 * mirrors .reviews-empty). The grid replaces this automatically once posts exist.
 * ============================================================ */
.learn-empty {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-64) var(--space-24);
  text-align: center;
  background-color: var(--color-surface);
  border: var(--border-hairline) dashed var(--color-border);
  border-radius: var(--radius-none);
}

.learn-empty__title {
  font-family: var(--font-display);
  font-size: var(--type-subheading);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.learn-empty__copy {
  max-width: var(--container-narrow);
  margin-inline: auto;
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

.learn-empty .build-note {
  margin-block-start: var(--space-16);
}

/* Reveal stagger (Step 14) — cards rise in sequence, cycling every 3 (the max
   grid width) so a long article list never accumulates a large delay. */
@media (prefers-reduced-motion: no-preference) {
  /* The card is both [data-reveal] and hover-interactive. Restate the full
     transition list (beats the components.css reveal rule on source order) so the
     reveal (opacity/transform) AND the hover border/surface cue both ease.
     Property order is fixed so the stagger delays below target only the reveal
     props. */
  .has-reveal .learn-card {
    transition: opacity var(--duration-slow) var(--ease-out),
                transform var(--duration-slow) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                background-color var(--duration-fast) var(--ease-out);
  }

  /* Delay list maps 1:1 to the four properties — stagger the reveal props only;
     hover props stay 0s so the hover cue is never delayed. */
  .has-reveal .learn-grid > [data-reveal]:nth-child(3n + 2) {
    transition-delay: var(--duration-fast), var(--duration-fast), 0s, 0s;
  }

  .has-reveal .learn-grid > [data-reveal]:nth-child(3n + 3) {
    transition-delay: calc(var(--duration-fast) * 2), calc(var(--duration-fast) * 2), 0s, 0s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .learn-card,
  .learn-search__row,
  .learn-search__submit {
    transition: none;
  }
}

@media (min-width: 768px) /* --bp-md */ {
  .learn-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-32);
  }
}

@media (min-width: 1024px) /* --bp-lg */ {
  .learn-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
