/* ==========================================================================
   doddo.bio blog: the post list (/blog) and a single post (/blog/<slug>).
   Same ground and ink as the landing page. Long-form text sits on a white
   sheet, because paragraph after paragraph of deep green on mint is tiring
   to read, and white is already in the system (the claim field).
   ========================================================================== */

:root {
  --t-page: clamp(1.75rem, 4vw, 2.75rem); /* page and post titles, 44px at 1100 */
  --t-read: clamp(1.0625rem, 1.2vw, 1.125rem); /* body copy, 17 to 18px */
  --measure: 680px; /* about 70 characters of Poppins at 18px */
  --r-lg: 24px;
  --ink-10: rgba(3, 89, 77, 0.1);
}

/* ==========================================================================
   Page head, shared by the list and the post
   ========================================================================== */

.page-head {
  padding-top: clamp(var(--sp-16), 2.4vw, var(--sp-32));
  text-align: center;
}

.page-head__title {
  max-width: 24ch;
  margin-inline: auto;
  font-size: var(--t-page);
  line-height: 1.1;
  text-wrap: balance;
}

/* Lighter than the 700 around it, the same move as the landing page's
   rotating word: it reads as an aside, not a second headline. */
.page-head__aside {
  font-weight: 500;
}

.page-head__sub {
  max-width: 36em;
  margin: var(--sp-16) auto 0;
  font-size: var(--t-sub);
  font-weight: 500;
  line-height: 1.4;
  color: var(--on-grad-75);
  text-wrap: balance;
}

/* ==========================================================================
   Post list (/blog)
   ========================================================================== */

.posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--sp-24);
  margin-block: clamp(var(--sp-32), 4vw, var(--sp-48)) var(--sp-96);
}

/* The whole card is the target: the title link stretches over it with
   ::after, so there is one link per post for keyboard and screen readers. */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--white);
  color: var(--ink);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px -12px rgba(3, 89, 77, 0.35);
}

.card:has(.card__link:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* height: auto, or the img's height attribute wins over aspect-ratio */
.card__img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid var(--ink-10);
}

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

.card__meta {
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--on-grad-75);
}

.card__title {
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.018em;
}

.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card__link:focus-visible {
  outline: none;
}

.card__excerpt {
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--on-grad-75);
}

.card__more {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  margin-top: auto;
  padding-top: var(--sp-8);
  font-size: var(--t-sm);
  font-weight: 600;
}

.card__more svg {
  width: 16px;
  height: 16px;
  transition: transform 0.18s ease;
}

.card:hover .card__more svg {
  transform: translateX(3px);
}

/* The newest post gets the full row, image beside the text once there is
   room for both. The <li> is the grid item, so that is what spans. */
.posts > li:has(> .card--featured) {
  grid-column: 1 / -1;
}

@media (min-width: 860px) {
  .card--featured {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    align-items: center;
  }

  /* The text sets the row height, so the image crops; pinning it left keeps
     the profile side of a screenshot, which is where bio pages start. */
  .card--featured .card__img {
    height: 100%;
    object-position: left center;
    border-bottom: 0;
    border-right: 1px solid var(--ink-10);
  }

  .card--featured .card__body {
    padding: clamp(var(--sp-32), 3.6vw, var(--sp-48));
  }

  .card--featured .card__title {
    font-size: clamp(1.5rem, 2.2vw, 1.875rem);
    line-height: 1.2;
  }
}

/* ==========================================================================
   A single post (/blog/<slug>)
   ========================================================================== */

.back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  min-height: var(--hit);
  margin-bottom: var(--sp-8);
  padding-inline: var(--sp-8);
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--on-grad-75);
  transition: color 0.18s ease;
}

.back:hover {
  color: var(--green);
}

.back svg {
  width: 16px;
  height: 16px;
}

.post-meta {
  margin-top: var(--sp-16);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--on-grad-75);
}

/* Phones: a full-bleed sheet with rounded top corners that runs to the end
   of the page, so the text column keeps every pixel of the width. */
.sheet {
  width: min(100%, 880px);
  margin: clamp(var(--sp-24), 4vw, var(--sp-48)) auto 0;
  padding: var(--sp-24) var(--gutter) var(--sp-48);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--white);
  color: var(--ink);
}

@media (min-width: 640px) {
  .sheet {
    width: min(100% - 2 * var(--gutter), 880px);
    margin-bottom: var(--sp-96);
    padding: clamp(var(--sp-40), 6vw, var(--sp-64));
    border-radius: var(--r-lg);
  }
}

/* Text keeps to the measure; figures use the sheet's full width, so the
   screenshots stay as large as they can. */
.prose {
  font-size: var(--t-read);
  line-height: 1.7;
}

.prose > * {
  max-width: var(--measure);
  margin-inline: auto;
}

.prose > figure {
  max-width: none;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose h2 {
  margin-top: 2.2em;
  font-size: clamp(1.375rem, 2.2vw, 1.625rem);
  line-height: 1.25;
  letter-spacing: -0.018em;
}

.prose > figure,
.prose > figure + * {
  margin-top: 1.6em;
}

/* After the figure rules, so a heading pulls its own figure in close */
.prose h2 + * {
  margin-top: 0.8em;
}

.prose > :first-child {
  margin-top: 0;
}

.prose strong {
  font-weight: 700;
}

.prose a {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-25);
  transition: text-decoration-color 0.18s ease;
}

.prose a:hover {
  text-decoration-color: currentColor;
}

.prose img {
  width: 100%;
  height: auto;
  border-radius: var(--r-md);
  /* A hairline so the light screenshots do not bleed into the white sheet */
  box-shadow: 0 0 0 1px var(--ink-10);
}

.prose figcaption {
  margin-top: var(--sp-12);
  font-size: var(--t-sm);
  font-weight: 500;
  text-align: center;
  color: var(--on-grad-75);
}

/* --- Closing call to action: the claim, on the landing page's own ground -- */
.cta {
  margin-top: clamp(var(--sp-48), 6vw, var(--sp-64));
  padding: clamp(var(--sp-32), 5vw, var(--sp-48)) var(--sp-24);
  border-radius: var(--r-lg);
  background: var(--hero-bg);
  color: var(--on-grad);
  text-align: center;
}

.cta__title {
  font-size: clamp(1.375rem, 2.6vw, 1.875rem);
  line-height: 1.15;
}

.cta__sub {
  margin: var(--sp-8) 0 var(--sp-24);
  font-size: var(--t-body);
  font-weight: 500;
  color: var(--on-grad-75);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card__more svg {
    transition: none;
  }

  .card:hover,
  .card:hover .card__more svg {
    transform: none;
  }
}
