/* ==========================================================================
   Blog — listing grid + note-style article, sharing the site's tokens
   ========================================================================== */

/* --- Listing ------------------------------------------------------------- */
.blog {
  padding: clamp(2.4rem, 6vw, 4.25rem) 0 clamp(3rem, 7vw, 5rem);
}

.blog__head {
  max-width: 60ch;
  margin: 0 auto clamp(2rem, 4.5vw, 3rem);
  text-align: center;
}

.blog__title {
  font-family: var(--font-heading);
  font-size: clamp(2.1rem, 4.6vw, 3.1rem);
  line-height: 1.05;
  color: var(--colour-text);
}

.blog__intro {
  margin-top: 0.9rem;
  color: var(--colour-muted);
  font-size: 1.1rem;
}

/* Centred topic pills, replaced by a select only when they no longer fit. */
.blog__filter-carousel {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto clamp(1.6rem, 3.5vw, 2.4rem);
}

.blog__filter-viewport {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.blog__filter-carousel.has-overflow .blog__filter-viewport {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
}

.blog__filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.65rem;
  overflow-x: hidden;
  padding: 0.15rem 0 0.3rem;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.blog__filters::-webkit-scrollbar {
  display: none;
}

.blog__filter {
  flex: 0 0 auto;
  padding: 0.55rem 1rem;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  background-image: linear-gradient(180deg, #fff 0%, #ece6d8 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 3px 0 rgba(0, 0, 0, 0.24);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  scroll-snap-align: center;
  transition: transform 0.06s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.blog__filter:hover {
  filter: brightness(1.03);
}

.blog__filter:active {
  transform: translateY(3px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.blog__filter:focus-visible,
.blog__filter-select:focus-visible {
  outline: 3px solid rgba(30, 122, 84, 0.5);
  outline-offset: 2px;
}

.blog__filter.is-active {
  color: #fff;
  border-color: rgba(0, 0, 0, 0.45);
  background-image: linear-gradient(180deg, #2fa36e 0%, #136b45 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 3px 0 rgba(0, 0, 0, 0.32);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.blog__filter-select-wrap[hidden] {
  display: none;
}

.blog__filter-select-wrap {
  position: relative;
  width: min(100%, 330px);
}

.blog__filter-select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1.1rem;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.blog__filter-select {
  width: 100%;
  min-height: 46px;
  padding: 0.72rem 3rem 0.72rem 1rem;
  appearance: none;
  cursor: pointer;
  color: #1a1a1a;
  background-image: linear-gradient(180deg, #fff 0%, #ece6d8 100%);
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 3px 0 rgba(0, 0, 0, 0.3);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.blog__filter-select:hover {
  filter: brightness(1.03);
}

.blog__empty {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--colour-muted);
}

.blog__grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(1.6rem, 3vw, 2.4rem);
  padding-top: 0.5rem;
}

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

@media (max-width: 560px) {
  .blog__grid { grid-template-columns: 1fr; max-width: 420px; margin-inline: auto; }
}

.blog-card {
  display: flex;
}

.blog-card[hidden] {
  display: none;
}

/* Pinned post-it note — colour + tilt alternate down the grid */
.blog-card__note {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 2rem 1.5rem 1.5rem;
  color: #2a2620;
  background-image: linear-gradient(180deg, var(--note-hi) 0%, var(--note) 58%, var(--note-lo) 100%);
  border-radius: 3px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 14px 24px -16px rgba(20, 23, 38, 0.5);
  transform: rotate(var(--tilt, -1deg));
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.blog-card__note:hover {
  transform: rotate(0deg) translateY(-3px);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.14),
    0 24px 32px -18px rgba(20, 23, 38, 0.5);
}

/* Pushpin */
.blog-card__note::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg,
      color-mix(in srgb, var(--pin) 76%, #fff) 0%,
      var(--pin) 36%,
      color-mix(in srgb, var(--pin) 58%, #000) 82%,
      color-mix(in srgb, var(--pin) 42%, #000) 100%);
  box-shadow:
    0 5px 7px -2px rgba(0, 0, 0, 0.45),
    inset 0 2px 2px rgba(255, 255, 255, 0.35),
    inset 0 -3px 4px rgba(0, 0, 0, 0.3);
  z-index: 3;
}

/* Four post-it colours, each with a pin colour that pops against it.
   The 8-card cycle runs the colours forward on one row (of four) then
   reversed on the next, so the colour order mirrors row to row. */
.blog-card__note--yellow,
.blog-card:nth-child(8n+1) .blog-card__note,
.blog-card:nth-child(8n+8) .blog-card__note {
  --note-hi: var(--colour-postit-hi); --note: var(--colour-postit); --note-lo: var(--colour-postit-lo);
  --pin: #e5384d; --tilt: -1.6deg; /* red on yellow */
}
.blog-card:nth-child(8n+2) .blog-card__note,
.blog-card:nth-child(8n+7) .blog-card__note {
  --note-hi: var(--postit-blue-hi); --note: var(--postit-blue); --note-lo: var(--postit-blue-lo);
  --pin: #ff7a1a; --tilt: 1.4deg; /* orange on blue */
}
.blog-card:nth-child(8n+3) .blog-card__note,
.blog-card:nth-child(8n+6) .blog-card__note {
  --note-hi: var(--postit-pink-hi); --note: var(--postit-pink); --note-lo: var(--postit-pink-lo);
  --pin: #12a594; --tilt: -0.8deg; /* teal on pink */
}
.blog-card:nth-child(8n+4) .blog-card__note,
.blog-card:nth-child(8n+5) .blog-card__note {
  --note-hi: var(--postit-green-hi); --note: var(--postit-green); --note-lo: var(--postit-green-lo);
  --pin: #8b3ff0; --tilt: 1.6deg; /* violet on lime */
}

.blog-card__meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.blog-card__tag {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.72);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.blog-card__date {
  color: rgba(0, 0, 0, 0.55);
  font-size: 0.85rem;
}

.blog-card__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  line-height: 1.12;
  color: #2a2620;
}

.blog-card__excerpt {
  margin-top: 0.6rem;
  color: rgba(0, 0, 0, 0.7);
  font-size: 0.98rem;
  line-height: 1.55;
}

/* CTA button, pinned to the bottom of the note */
.blog-card__cta {
  align-self: flex-start;
  margin-top: auto;
  padding-top: 1.2rem; /* breathing room above the button */
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: #1c1a15;
  text-decoration: none;
}

.blog-card__cta > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: #1c1a15;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.2s ease, background 0.2s ease;
}

.blog-card__cta:hover,
.blog-card__cta:focus {
  text-decoration: none;
}

.blog-card__note:hover .blog-card__cta > span {
  transform: translateX(3px);
  background: var(--colour-accent);
}

/* Stretched link — the CTA makes the whole post-it clickable */
.blog-card__cta::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Keep the pin purely decorative */
.blog-card__note::before { pointer-events: none; }

/* --- Article ------------------------------------------------------------- */
.blog-post {
  padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3rem, 7vw, 5rem);
}

.blog-post__inner {
  max-width: 72ch;
  margin: 0 auto;
}

.blog-post__back {
  display: inline-block;
  margin-bottom: 1.4rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--colour-accent);
}

.blog-post__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
  color: var(--colour-muted);
  font-size: 0.9rem;
}

.blog-post__meta .blog-card__tag { margin: 0; }

.blog-post__title {
  font-family: var(--font-heading);
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  line-height: 1.04;
  color: var(--colour-text);
}

.blog-post__lead {
  margin-top: 1rem;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--colour-muted);
}

.blog-post__body {
  margin-top: clamp(1.6rem, 3.5vw, 2.4rem);
  color: var(--colour-text);
  font-size: 1.06rem;
  line-height: 1.7;
}

.blog-post__body > * + * { margin-top: 1.1rem; }

.blog-post__body h2 {
  margin-top: 2.1rem;
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw, 1.95rem);
  line-height: 1.15;
  color: var(--colour-text);
}

.blog-post__body h3 {
  margin-top: 1.6rem;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: var(--colour-text);
}

.blog-post__body ul,
.blog-post__body ol {
  padding-left: 1.5rem;
  color: var(--colour-text);
}

.blog-post__body ul { list-style: disc; }
.blog-post__body ol { list-style: decimal; }

.blog-post__body li { padding-left: 0.25rem; }
.blog-post__body li::marker { color: var(--colour-accent); }

.blog-post__body li + li { margin-top: 0.4rem; }

.blog-post__body a {
  color: var(--colour-accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.blog-post__body blockquote {
  margin: 1.6rem 0;
  padding: 0.6rem 1.25rem;
  border-left: 3px solid var(--colour-accent);
  background: rgba(30, 122, 84, 0.06);
  border-radius: 0 8px 8px 0;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  line-height: 1.35;
  color: var(--colour-text);
}

.blog-post__body blockquote p { margin: 0; }

.blog-post__body code {
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 0.9em;
}

.blog-post__body pre {
  overflow-x: auto;
  padding: 1rem 1.15rem;
  border-radius: 10px;
  background: #10382a;
  color: #eaf3ee;
}

.blog-post__body pre code {
  padding: 0;
  background: none;
  color: inherit;
}

.blog-post__body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.blog-post__body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* End-of-post CTA */
.blog-post__cta {
  margin-top: clamp(2.4rem, 5vw, 3.25rem);
  padding-top: clamp(1.5rem, 3vw, 2rem);
  border-top: 1px solid var(--border);
  text-align: center;
}

.blog-post__cta p {
  margin-bottom: 1rem;
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  color: var(--colour-text);
}

/* --- Note layout (each post retains a personal greeting and sign-off) ---- */
.letter {
  position: relative;
  margin-top: clamp(1.4rem, 3vw, 2rem);
  padding: clamp(1.6rem, 4vw, 2.75rem);
  background-color: var(--card);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(244, 239, 228, 0.6)),
    url("/img/hero-texture.svg");
  background-size: auto, 300px 300px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 22px 44px -34px rgba(20, 23, 38, 0.45);
}

.letter__greeting {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  color: var(--colour-text);
}

.letter__signoff {
  margin-top: 2rem;
}

.letter__signoff > * + * { margin-top: 0.1rem; }

.letter__valediction {
  color: var(--colour-muted);
}

.letter__signature {
  font-family: "Caveat", cursive;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1;
  color: var(--colour-accent);
}

.letter__role {
  color: var(--colour-muted);
  font-size: 0.9rem;
}
