/* =========================================================================
   Blog: the listing (archive.php / home.php, template-parts/post-card.php)
   and single posts (single.php, template-parts/author-box.php).
   Loaded after page.css, which supplies the listing's hero. The cards
   borrow the practice cards' vocabulary — 1px rule, 1.5rem radius, black on hover —
   so the blog reads as part of the firm's site, not a bolted-on theme.
   ========================================================================= */

/* Shared by the listing and the related-articles band under a post. */

.blog__heading {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
  color: var(--color-black);
  font-size: clamp(1.375rem, 2.2vw, 1.75rem);
  font-weight: 700;

  /* A hairline running out to the container edge, the way the logo's
     "The Law Offices of ——" does. */
  &::after {
    content: "";
    height: 1px;
    background: var(--color-rule);
  }
}

.blog__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.25rem, 2.3vw, 1.9375rem);

  @media (min-width: 40rem) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  @media (min-width: 62rem) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.blog {
  /* The hero already closes the page head; the full section rhythm on top of
     it leaves the lead card floating. */
  padding-top: clamp(2.5rem, 5vw, 4.5rem);

  /* The heading's own top margin separates it from the lead card; the
     related-articles band starts with it and needs none. */
  .blog__heading {
    margin-top: clamp(2.5rem, 5vw, 4rem);
  }

  .blog__empty {
    display: grid;
    justify-items: center;
    gap: 1.25rem;
    color: var(--color-ink-soft);
    font-size: clamp(1.0625rem, 1.3vw, 1.1875rem);
    text-align: center;
  }

  .blog__disclaimer {
    max-width: 46rem;
    margin: clamp(2.5rem, 5vw, 3.5rem) auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-rule);
    color: var(--color-ink-soft);
    font-size: 0.9375rem;
    line-height: 1.6;
    text-align: center;

    a {
      color: var(--color-ink);
    }
  }
}

/* -- Pagination (the_posts_pagination) ----------------------------------- */

.blog__pagination {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);

  .nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding-inline: 0.9rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;

    &:hover {
      border-color: var(--color-black);
    }

    &.current {
      border-color: var(--color-black);
      background: var(--color-black);
      color: var(--color-white);
    }

    &.dots {
      border-color: transparent;
    }
  }

  .prev,
  .next {
    padding-inline: 1.25rem;
  }
}

/* -------------------------------------------------------------------------
   Post card
   ------------------------------------------------------------------------- */

.post-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  background: var(--color-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;

  .post-card__media {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--color-bg-soft);
  }

  .post-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
  }

  /* No featured image: the compass rose from the logo on the black of the
     nav and footer, lifted by a soft light from the top — a deliberate panel
     rather than an empty box. */
  .post-card__placeholder {
    --compass-light: #1d1e18;

    display: grid;
    place-items: center;
    height: 100%;
    background:
      radial-gradient(120% 90% at 50% 0%, rgb(255 255 255 / 0.12), transparent 60%),
      var(--color-black);
    color: rgb(255 255 255 / 0.55);
  }

  .post-card__placeholder-mark {
    width: clamp(4rem, 22%, 7.5rem);
    height: auto;
    transition: transform 0.5s ease;
  }

  .post-card__body {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    align-content: start;
    gap: 0.75rem;
    padding: clamp(1.25rem, 2.2vw, 1.75rem);
  }

  .post-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0;
    color: var(--color-ink-soft);
    font-size: 0.875rem;
    line-height: 1.4;

    > * {
      white-space: nowrap;
    }

    /* Separators only between date and reading time; the topic is an eyebrow
       on its own line, so a wrap never strands a dot at the start of a row. */
    > :not(.post-card__topic) + *::before {
      content: "·";
      margin-inline: 0.5rem;
      color: var(--color-mark);
    }
  }

  .post-card__topic {
    flex-basis: 100%;
    margin-bottom: 0.15rem;
    color: var(--color-heading);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .post-card__title {
    color: var(--color-black);
    font-size: clamp(1.1875rem, 1.7vw, 1.375rem);
    font-weight: 700;
    line-height: 1.3;
    /* balance (the global heading rule) squeezes a three-line title into a
       narrow block inside a card; pretty only fixes the orphan. */
    text-wrap: pretty;
  }

  /* The title's link covers the card, so the whole card is clickable while
     the markup keeps a single, well-named link. */
  .post-card__link {
    text-decoration: none;

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 1;
      border-radius: inherit;
    }

    &:focus-visible {
      outline: none;

      &::after {
        outline: 3px solid var(--color-accent);
        outline-offset: -3px;
      }
    }
  }

  .post-card__excerpt {
    /* Kept to its clamped height: stretched by the 1fr row, the box would
       show the lines the clamp cut off. */
    align-self: start;
    display: -webkit-box;
    overflow: hidden;
    color: var(--color-ink-soft);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  .post-card__byline {
    color: var(--color-ink);
    font-size: 0.9375rem;
    font-weight: 600;
  }

  .post-card__more {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
    color: var(--color-black);
    font-size: 0.9375rem;
    font-weight: 700;

    svg {
      width: 1.125rem;
      height: 1.125rem;
      transition: transform 0.2s ease;
    }
  }

  &:hover {
    border-color: var(--color-black);
    box-shadow: 0 0.75rem 1.75rem rgb(0 0 0 / 0.08);
    transform: translateY(-2px);

    .post-card__image,
    .post-card__placeholder-mark {
      transform: scale(1.03);
    }

    .post-card__title {
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 0.18em;
    }

    .post-card__more svg {
      transform: translateX(3px);
    }
  }
}

/* -- The lead card: image beside the copy once there is room ------------- */

.post-card--featured {
  grid-template-rows: auto;

  .post-card__body {
    grid-template-rows: none;
    gap: 1rem;
  }

  .post-card__title {
    font-size: clamp(1.5rem, 2.9vw, 2.375rem);
    line-height: 1.2;
  }

  .post-card__excerpt {
    font-size: clamp(1.0625rem, 1.3vw, 1.1875rem);
    -webkit-line-clamp: 4;
    line-clamp: 4;
  }

  .post-card__placeholder-mark {
    width: clamp(5rem, 20%, 9rem);
  }

  @media (min-width: 62rem) {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);

    .post-card__media {
      aspect-ratio: auto;
      min-height: 24rem;
    }

    .post-card__body {
      align-content: center;
      padding: clamp(2rem, 3.5vw, 3.5rem);
    }
  }
}

/* =========================================================================
   Single post
   ========================================================================= */

/* -- Article header: the page hero's soft band, set as a masthead ------- */

.article-hero {
  padding-block: clamp(1.5rem, 4vw, 3rem) clamp(2.5rem, 6vw, 4.5rem);
  border-bottom: 1px solid var(--color-rule);
  background: var(--color-bg-soft);

  .article-hero__inner {
    display: grid;
    justify-items: center;
    gap: clamp(0.75rem, 1.6vw, 1.125rem);
    text-align: center;
  }

  .article-hero__back {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.75rem;
    margin-bottom: clamp(0.5rem, 2vw, 1.5rem);
    color: var(--color-ink-soft);
    font-size: 0.9375rem;
    text-decoration: none;

    svg {
      width: 1.125rem;
      height: 1.125rem;
      transition: transform 0.2s ease;
    }

    &:hover {
      color: var(--color-black);

      svg {
        transform: translateX(-3px);
      }
    }
  }

  .article-hero__topic {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--color-heading);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;

    &:hover {
      text-decoration: underline;
    }
  }

  .article-hero__title {
    max-width: 52rem;
    color: var(--color-heading);
    font-size: clamp(1.875rem, 4.2vw, 3.25rem);
    font-weight: 700;
    line-height: 1.15;
  }

  .article-hero__meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0;
    margin-top: 0.25rem;
    color: var(--color-ink-soft);
    font-size: 0.9375rem;

    > * {
      white-space: nowrap;
    }

    > * + *::before {
      content: "·";
      margin-inline: 0.6rem;
      color: var(--color-mark);
    }
  }

  .article-hero__author {
    color: var(--color-ink);
    font-weight: 600;
  }

  /* Too narrow for the three on one row: the byline takes its own line, so
     a wrap never strands a separator at the start of the next. */
  @media (max-width: 36rem) {
    .article-hero__author {
      flex-basis: 100%;
    }

    .article-hero__author + *::before {
      content: none;
    }
  }

  /* With a featured image the band runs on underneath it, so the picture
     straddles the band's lower edge. */
  &.article-hero--with-image {
    padding-bottom: clamp(7rem, 22vw, 14rem);
  }
}

/* -- Featured image ------------------------------------------------------ */

.article__figure-wrap {
  margin-top: calc(clamp(7rem, 22vw, 14rem) * -1 + clamp(1.5rem, 3vw, 2.5rem));
}

.article__figure {
  max-width: 64rem;
  margin-inline: auto;
}

.article__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-card);
  object-fit: cover;
  box-shadow: 0 1.25rem 3rem rgb(0 0 0 / 0.1);
}

.article__caption {
  margin-top: 0.75rem;
  color: var(--color-ink-soft);
  font-size: 0.875rem;
  text-align: center;
}

/* -- Body copy ----------------------------------------------------------- */

.article__body {
  padding-top: clamp(2.5rem, 5vw, 4rem);
}

/* The reading column: a comfortable measure, left-aligned headings (an
   article is scanned by its headings, unlike the centred service pages). */
.prose.prose--article {
  max-width: 44rem;
  margin-inline: auto;
  color: var(--color-ink);

  /* The opening paragraph sets up the piece; a step up in size reads as the
     standfirst without anyone having to mark it. */
  > p:first-child {
    color: var(--color-heading);
    font-size: clamp(1.1875rem, 1.6vw, 1.375rem);
    line-height: 1.65;
  }

  /* Left-aligned, so balance (the global heading rule) would only break
     them early; pretty just keeps a word off the last line on its own. */
  h2,
  h3,
  h4 {
    text-wrap: pretty;
  }

  h2 {
    margin-top: clamp(2.5rem, 4vw, 3rem);
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    line-height: 1.25;
  }

  h3 {
    margin-top: 2rem;
  }

  h4 {
    clear: both;
    margin-top: 1.75rem;
    color: var(--color-black);
    font-family: var(--font-sans);
    font-size: 1.125rem;
    font-weight: 700;
  }

  h2 + *,
  h3 + *,
  h4 + * {
    margin-block-start: 0.75rem;
  }

  a {
    text-decoration-color: var(--color-mark);

    &:hover {
      text-decoration-color: currentColor;
    }
  }

  /* Editor images run the column's full width in an article. */
  figure,
  .wp-block-image {
    margin-block: 2rem;
  }

  figure img {
    width: 100%;
  }

  figcaption,
  .wp-element-caption {
    margin-top: 0.6rem;
    color: var(--color-ink-soft);
    font-size: 0.875rem;
    line-height: 1.5;
    text-align: center;
  }

  blockquote,
  .wp-block-quote {
    margin-block: 2rem;
    padding: 0.25rem 0 0.25rem clamp(1.25rem, 3vw, 2rem);
    border-left: 3px solid var(--color-heading);
    color: var(--color-heading);
    font-family: var(--font-serif);
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-style: italic;
    line-height: 1.5;

    cite {
      display: block;
      margin-top: 0.75rem;
      color: var(--color-ink-soft);
      font-family: var(--font-sans);
      font-size: 0.9375rem;
      font-style: normal;
    }
  }

  hr,
  .wp-block-separator {
    width: 4.5rem;
    height: 0.25rem;
    margin-block: 2.5rem;
    margin-inline: auto;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-mark);
  }

  /* Tables scroll inside their own box on phones instead of widening the
     page. */
  .wp-block-table {
    overflow-x: auto;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
  }

  th,
  td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-rule);
    text-align: left;
    vertical-align: top;
  }

  th {
    color: var(--color-black);
    font-weight: 700;
  }

  thead th {
    border-bottom: 2px solid var(--color-black);
  }

  .article__pages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-weight: 600;
  }
}

/* -- After the copy: topics, the note, the attorney ---------------------- */

.article__footer {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.25rem);
  max-width: 44rem;
  margin: clamp(2.5rem, 5vw, 3.5rem) auto 0;
  padding-top: clamp(1.5rem, 3vw, 2rem);
  border-top: 1px solid var(--color-rule);
}

.article__terms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;

  .article__terms-label {
    color: var(--color-ink-soft);
    font-size: 0.9375rem;
  }

  .article__terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .article__term {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding-inline: 1.1rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: border-color 0.2s ease;

    &:hover {
      border-color: var(--color-black);
    }
  }
}

.article__disclaimer {
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  background: var(--color-bg-soft);
  color: var(--color-ink-soft);
  font-size: 0.9375rem;
  line-height: 1.6;

  a {
    color: var(--color-ink);
  }
}

.author-box {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 1.25rem 1.75rem;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  text-align: center;

  @media (min-width: 36rem) {
    grid-template-columns: auto 1fr;
    align-items: start;
    justify-items: start;
    text-align: left;
  }

  .author-box__portrait {
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 15%;
  }

  .author-box__body {
    display: grid;
    gap: 0.5rem;
  }

  .author-box__eyebrow {
    color: var(--color-ink-soft);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .author-box__name {
    color: var(--color-black);
    font-size: clamp(1.375rem, 2.2vw, 1.75rem);
    font-weight: 700;
  }

  .author-box__bio {
    color: var(--color-ink-soft);
    font-size: 1rem;
    line-height: 1.65;
  }

  .author-box__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.5rem;

    @media (min-width: 36rem) {
      justify-content: flex-start;
    }
  }
}
