/*
 * Webdev blog — the only stylesheet written for this site.
 *
 * Everything else in assets/css is a copy of the main site's design system and
 * must not be edited here. This file adds the handful of components the blog
 * needs that the marketing site has no equivalent for: the post card, the
 * article measure, and the flow of a written article.
 *
 * Loads last, so it can lean on the tokens and primitives above it.
 */

/* ---------- chrome parity with the main site ----------
 * The design system has NO element-level resets: on my2 those come from
 * bootstrap.min.css (Reboot) and style.css, which this theme deliberately does
 * not load. The header and footer are also OUTSIDE .wd-page — that class is on
 * <main> — so webdev-base.css’s `.wd-page *` border-box reset never reaches them.
 * Without the few rules below the shared chrome drifts from my2:
 *
 *   box-sizing  .wd-shell became 1320px PLUS its 48px of padding (48px too wide),
 *               and every .wd-btn added its padding outside its width, which is
 *               why the Client Area pill came out larger.
 *   body margin the browser default 8px inset the sticky header and the footer,
 *               so their bands stopped short of the viewport edge.
 *   the rest    my2’s own body rule; the chrome was designed under it.
 *
 * NOT copied from style.css: `a { outline: none !important }` (removes focus
 * rings) and `text-decoration: none !important` (would kill article links).
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  background-color: #f6f6f6;
  letter-spacing: 0.3px;
  margin: 0;
}

/* Reboot again: keeps inline icons off the text baseline. */
img,
svg {
  vertical-align: middle;
}

/* ---------- page ground ---------- */

.wd-blog {
  background: var(--wd-page-bg, #f7f8f9);
}

/*
 * A narrow shell for prose. The marketing shell is sized for cards in a grid;
 * running body text that wide is hard to read, so articles get a measure of
 * roughly 70 characters instead.
 */
.wd-shell--narrow {
  max-width: 44rem;
}

/* ---------- footer social marks ----------
 * The shared footer markup used FontAwesome `<i>` glyphs. This theme does not
 * load FontAwesome — 8.5 MB of webfont for four icons — so they are inline SVG
 * brand marks instead.
 *
 * They are FILLED paths, so they must not take .wd-icon: that class is
 * stroke-based with `fill: none`, which would render each logo as an outline.
 */
.wd-social__icon {
  fill: currentColor;
  height: 1.125rem;
  width: 1.125rem;
}

/* ---------- headings ----------
 * The blog runs a smaller h2 than the marketing pages: webdev-base.css sets
 * `.wd-page h2` to clamp(1.875rem, 3.2vw, 2.25rem) — 30–36px, sized for section
 * headings above a grid of cards, not for headings inside running prose.
 *
 * Same selector and specificity as base, declared here because base is a copy of
 * the design system and must not be edited in this theme.
 */
.wd-page h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.18;
}

/* ---------- listing header ---------- */

/*
 * The blog artwork, set the same way every other sub-hero variant sets its own:
 * one custom property, and webdev-base.css supplies the scrim, sizing, position
 * and type treatment. Nothing else is overridden here — the earlier flat-colour
 * background also killed the art layer, and the padding and lead colour it
 * repeated already come from .wd-subhero__inner and .wd-subhero .wd-lead.
 *
 * Dark image: a flat near-black panel on the left, the subject lit on the right.
 * That is the direction the default scrim already fades in, so it needs no
 * --light-art variant and the default `right center` focal point keeps the
 * faces in frame when the band crops short.
 */
.wd-subhero--blog {
  --wd-subhero-art: url("../img/blogheader.jpg");

  /*
   * Height on the marketing pages comes only from .wd-subhero__inner padding,
   * which lands around 270px — too short to let this photograph read. A floor,
   * not a fixed height: the copy still sets the height on its own if a long
   * category title wraps, so nothing can be clipped.
   *
   * Grid rather than flex so .wd-shell keeps its own `margin: 0 auto` and
   * max-width: it stays the centred container it is everywhere else, and
   * align-content only moves it in the block direction. A no-op when the band is
   * at its natural height, so it is safe to leave on at every width.
   */
  align-content: center;
  display: grid;
  min-height: 400px;
}

/*
 * A 400px band is most of a phone screen, and at that width the scrim has
 * already rotated to 170deg and the copy sits OVER the photograph rather than
 * beside it, so the extra height buys nothing. Back to the natural height.
 */
@media (max-width: 767.98px) {
  .wd-subhero--blog {
    min-height: 0;
  }
}

/* ---------- post cards ---------- */

.wd-posts {
  display: grid;
  gap: clamp(1rem, 2vw, 1.5rem);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/*
 * The whole card is an anchor, so the padding moves to the body and the media
 * can run edge to edge — same construction as the route cards on /upgrades/.
 */
.wd-page .wd-post {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  text-decoration: none;
}

.wd-post__media {
  aspect-ratio: 16 / 9;
  background: var(--wd-grey-100);
  display: block;
  overflow: hidden;
}

/*
 * `height` is !important for the same reason it is on the main site: the legacy
 * custom.css there clamps `li img` to 42px, and WordPress wraps images in all
 * sorts of containers. Being explicit here means a themed listing cannot be
 * ambushed by an inherited rule.
 */
.wd-post__media img {
  display: block;
  height: 100% !important;
  object-fit: cover;
  transition: transform 500ms var(--wd-ease);
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .wd-post:hover .wd-post__media img {
    transform: scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wd-post__media img,
  .wd-post:hover .wd-post__media img {
    transform: none;
    transition: none;
  }
}

.wd-post__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.75rem;
  padding: clamp(1.25rem, 2.4vw, 1.625rem);
}

.wd-post__meta {
  align-items: center;
  color: var(--wd-grey-500);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  gap: 0.5rem 0.75rem;
  margin: 0;
}

.wd-post__cat {
  background: var(--wd-orange-050);
  border-radius: var(--wd-radius-pill);
  color: var(--wd-orange-700);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.3125rem 0.625rem;
  text-decoration: none;
  text-transform: uppercase;
}

.wd-post__title {
  color: var(--wd-charcoal-900);
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  line-height: 1.3;
  margin: 0;
}

.wd-post .wd-body {
  margin: 0;
}

/* Pinned to the bottom so cards in a row share a baseline for the call. */
.wd-post__go {
  align-items: center;
  color: var(--wd-orange-700);
  display: inline-flex;
  font-weight: 600;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

@media (hover: hover) and (pointer: fine) {
  .wd-post:hover .wd-post__go .wd-icon {
    transform: translateX(4px);
  }
}

.wd-post__go .wd-icon {
  transition: transform var(--wd-duration) var(--wd-ease);
}

/* ---------- article ---------- */

.wd-article__head {
  padding-block: clamp(2rem, 4vw, 3rem) clamp(1rem, 2vw, 1.5rem);
}

.wd-article__head h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  margin: 0.5rem 0 0;
}

.wd-article__meta {
  align-items: center;
  color: var(--wd-grey-500);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.875rem;
  gap: 0.5rem 0.75rem;
  margin: 0;
}

.wd-article__media {
  border-radius: var(--wd-card-radius);
  margin: 0 0 clamp(1.5rem, 3vw, 2.25rem);
  overflow: hidden;
}

.wd-article__media img {
  display: block;
  height: auto;
  width: 100%;
}

/*
 * Article flow. Editors write in the block editor, so these rules have to hold
 * for whatever markup it emits — hence element selectors rather than classes.
 */
.wd-article__body {
  color: var(--wd-grey-700);
  font-size: 1.0625rem;
  line-height: 1.7;
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

.wd-article__body > * + * {
  margin-top: 1.25em;
}

.wd-article__body h3,
.wd-article__body h4 {
  color: var(--wd-charcoal-900);
  line-height: 1.25;
  margin-top: 2em;
}

/* h2 keeps the colour and the space above it, but not the line-height — that
   comes from the .wd-page h2 rule above, along with its size. */
.wd-article__body h2 {
  color: var(--wd-charcoal-900);
  margin-top: 2em;
}

.wd-article__body h3 {
  font-size: clamp(1.125rem, 1.8vw, 1.3125rem);
}

.wd-article__body a {
  color: var(--wd-orange-700);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.wd-article__body img,
.wd-article__body figure img {
  border-radius: var(--wd-radius-md);
  height: auto;
  max-width: 100%;
}

.wd-article__body figcaption {
  color: var(--wd-grey-500);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.wd-article__body blockquote {
  border-left: 3px solid var(--wd-orange-500);
  margin-left: 0;
  padding-left: 1.25rem;
}

.wd-article__body ul,
.wd-article__body ol {
  padding-left: 1.25rem;
}

.wd-article__body li + li {
  margin-top: 0.5rem;
}

.wd-article__body pre {
  background: var(--wd-charcoal-950);
  border-radius: var(--wd-radius-md);
  color: var(--wd-white);
  overflow-x: auto;
  padding: 1rem 1.25rem;
}

.wd-article__body table {
  border-collapse: collapse;
  width: 100%;
}

.wd-article__body th,
.wd-article__body td {
  border-bottom: 1px solid var(--wd-grey-200);
  padding: 0.625rem 0.75rem;
  text-align: left;
}

.wd-article__tags a {
  color: var(--wd-grey-500);
  font-size: 0.875rem;
}

/* ---------- Elementor leftovers ----------
 * The imported posts still carry the bullet icons the old lists used: inline
 * <svg viewBox="0 0 512 512"> with no width, no height and no class. FontAwesome
 * sized those on the old site; this theme does not load it, so each one falls
 * back to the SVG default of roughly 300px and renders as a giant black disc
 * down the middle of the article.
 *
 * Hidden rather than resized: they are decorative duplicates of the list bullet,
 * and the article already has the design system’s own list styling. Removing
 * them from post_content is the real fix — this rule is what keeps any that
 * survive, or any an editor pastes later, from breaking the page.
 *
 * Scoped to bare SVGs: anything the theme itself renders carries a class.
 */
.wd-article__body svg:not([class]) {
  display: none;
}

/* ---------- pagination ---------- */

.wd-pagination {
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
}

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

.wd-pagination .page-numbers {
  align-items: center;
  border: 1px solid var(--wd-grey-200);
  border-radius: var(--wd-radius-sm);
  color: var(--wd-charcoal-900);
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.75rem;
  text-decoration: none;
}

.wd-pagination .page-numbers.current {
  background: var(--wd-orange-500);
  border-color: var(--wd-orange-500);
  color: var(--wd-white);
}

/* ---------- responsive ---------- */

@media (max-width: 991.98px) {
  .wd-posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .wd-posts {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- article hero ----------
 *
 * The post's own featured image, used as the band's background rather than as a
 * picture in the flow. Those uploads are 1536px wide: shown full width they
 * pushed the first paragraph most of a screen down the page and repeated what
 * the card on the index already showed.
 *
 * No --wd-subhero-art here on purpose. single.php sets it inline per post, and
 * a post without a featured image falls through to the shared artwork
 * .wd-subhero already carries, so the band never renders bare.
 */
.wd-subhero--article {
  align-content: center;
  display: grid;
  min-height: 400px;
}

/* Meta is grey-500 for a light page; on the photograph it has to lift. */
.wd-subhero--article .wd-article__meta {
  color: var(--wd-grey-200);
  margin-top: 0.875rem;
}

/*
 * The category link is the eyebrow itself, so it takes the eyebrow's colour.
 * text-decoration set explicitly: this theme does not load style.css, which is
 * where the blanket reset lives, so a bare link arrives underlined.
 */
.wd-subhero--article .wd-eyebrow a {
  color: inherit;
  text-decoration: none;
}

.wd-subhero--article .wd-eyebrow a:hover,
.wd-subhero--article .wd-eyebrow a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

@media (max-width: 767.98px) {
  .wd-subhero--article {
    min-height: 0;
  }
}

/* ---------- article + sidebar ----------
 *
 * Two fixed-ish columns rather than fractions: the reading column keeps the
 * measure the narrow shell used to give it, and the leftover width goes to the
 * gutter between them instead of stretching the prose to an unreadable line.
 */
.wd-artlayout {
  display: grid;
  gap: clamp(2rem, 4vw, 3.5rem);
  grid-template-columns: minmax(0, 44rem) minmax(0, 19rem);
  justify-content: space-between;
  padding-block: clamp(2rem, 4vw, 3rem);
}

/* Follows the reader down a long article. align-self so the card keeps its own
   height instead of stretching to the column. */
.wd-artside {
  align-self: start;
  position: sticky;
  top: 5.5rem;
}

.wd-artside__card {
  background: var(--wd-white);
  border: 1px solid var(--wd-grey-200);
  border-radius: var(--wd-card-radius);
  padding: clamp(1.25rem, 2vw, 1.5rem);
}

.wd-artside__group {
  color: var(--wd-charcoal-900);
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 1.25rem 0 0.375rem;
}

.wd-artside__group:first-of-type {
  margin-top: 1rem;
}

.wd-artside__list {
  display: grid;
  gap: 0.125rem;
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0;
}

/*
 * No colour change on hover: `.wd-page a:hover` forces `color: inherit`
 * site-wide, so the arrow moves and the label underlines instead.
 */
.wd-artside__list a {
  align-items: center;
  color: var(--wd-grey-700);
  display: flex;
  font-size: 0.9375rem;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.375rem 0;
  text-decoration: none;
}

.wd-artside__list a:hover,
.wd-artside__list a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.wd-artside__list .wd-icon {
  color: var(--wd-orange-500);
  flex: none;
  transition: transform var(--wd-duration, 0.2s) var(--wd-ease, ease);
}

.wd-artside__list a:hover .wd-icon {
  transform: translateX(3px);
}

.wd-artside .wd-btn {
  margin-top: 1.25rem;
}

/*
 * One column below this, and the sidebar stops being a sidebar: it follows the
 * article as a closing call to action, which is where it belongs on a phone.
 */
@media (max-width: 991.98px) {
  .wd-artlayout {
    grid-template-columns: minmax(0, 1fr);
  }

  .wd-artside {
    position: static;
  }
}

/* .wd-article__media is no longer emitted by single.php — the featured image is
   the hero background now. Kept for any post body that includes a figure. */
