/* ==========================================================================
   Stories: blog cards (used on home, stories and post pages), the Stories
   page filter, and the post reading layout. Owned by the about-stories builder.
   Card class names are a contract with css/home.css: story-grid, story-card.
   ========================================================================== */

/* ---------- card grid (home.css relies on 2 columns between 621 and 960px) ---------- */
.story-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2.4vw, 32px); }
@media (max-width: 960px) { .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .story-grid { grid-template-columns: 1fr; } }

/* ---------- card: a photo mounted on white card stock ---------- */
.story-card {
  --type: var(--rose-deep);
  background: var(--white); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 10px; gap: 0; min-width: 0;
}
.story-card[data-type="article"] { --type: var(--garden); }
.story-card[data-type="news"] { --type: var(--lilac-deep); }
.story-card[hidden] { display: none; }
.story-card__media {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden; flex: none;
  border-radius: calc(var(--r-lg) - 10px); background: var(--mint);
}
.story-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .9s var(--ease-out); }
.story-card:hover .story-card__media img { transform: scale(1.035); }

/* posts without a photo: a soft watercolour wash with the leaf */
.story-card__media--tile {
  display: grid; place-items: center; color: var(--white); font-size: clamp(4.2rem, 3rem + 3vw, 5.6rem);
  background:
    radial-gradient(55% 65% at 28% 30%, var(--blush) 0%, transparent 72%),
    radial-gradient(60% 70% at 78% 72%, var(--lilac) 0%, transparent 70%),
    var(--mint);
}
.story-card__wash {
  position: absolute; width: 46%; aspect-ratio: 1; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--sage) 70%, transparent), transparent);
  filter: blur(6px);
}
.story-card__media--tile .leaf { position: relative; filter: drop-shadow(0 6px 14px rgba(31, 74, 51, .16)); }
.story-card[data-type="news"] .story-card__media--tile {
  background:
    radial-gradient(55% 65% at 70% 28%, var(--lilac) 0%, transparent 72%),
    radial-gradient(60% 70% at 22% 76%, var(--mint) 0%, transparent 70%),
    var(--blush);
}

.story-card__body { display: flex; flex-direction: column; gap: .55rem; padding: 1.15rem .95rem .85rem; flex: 1; }
.story-card__note {
  margin: 0 0 .15rem; align-self: flex-start; padding: .35rem .75rem; border-radius: 10px;
  background: var(--blush); color: var(--rose-deep); font-size: .9rem; line-height: 1.4;
}
.story-card__note-k { font-weight: 700; }
.story-card__meta { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; font-size: .88rem; color: var(--ink-soft); }
.story-card__meta span + span::before { content: "·"; margin-right: .6rem; }
.story-card__type { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; color: var(--type); }
.story-card__title { margin: 0; font-size: clamp(1.32rem, 1.15rem + .5vw, 1.58rem); font-weight: 400; line-height: 1.16; }
.story-card__excerpt { margin: 0; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.55; }
.story-card .go { font-size: 1rem; padding-top: .7rem; }

/* the newest post, larger, on the Stories page only */
@media (min-width: 761px) {
  .story-card--feature { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: stretch; }
  .story-card--feature .story-card__media { aspect-ratio: auto; align-self: stretch; display: grid; place-items: center; }
  .story-card--feature .story-card__media img { height: auto; aspect-ratio: 900 / 506; }
  .story-card--feature .story-card__body { justify-content: center; gap: .8rem; padding: clamp(24px, 3.5vw, 56px); }
  .story-card--feature .story-card__title { font-size: clamp(1.9rem, 1.2rem + 1.8vw, 3rem); font-weight: 350; line-height: 1.06; letter-spacing: -.015em; }
  .story-card--feature .story-card__excerpt { font-size: 1.12rem; max-width: 30em; }
}

/* phones, Stories page: every post after the featured one becomes a compact list row
   (content note first, a small thumbnail beside the title) so the page is quick to scan */
@media (max-width: 620px) {
  .story-grid--all { gap: 12px; }
  .story-grid--all .story-card:not(.story-card--feature) {
    display: grid; grid-template-columns: minmax(0, 1fr) 84px; column-gap: 14px; row-gap: .4rem; align-items: start;
    grid-template-areas: "note note" "meta media" "title media" "excerpt excerpt" "go go";
    padding: 16px 16px 12px 18px; border-radius: var(--r);
  }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__body { display: contents; }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__media { grid-area: media; width: 84px; aspect-ratio: 1; border-radius: 16px; }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__media--tile { font-size: 2.4rem; }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__note { grid-area: note; margin-bottom: .2rem; }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__meta { grid-area: meta; align-self: end; }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__title { grid-area: title; font-size: 1.3rem; }
  .story-grid--all .story-card:not(.story-card--feature) .story-card__excerpt { grid-area: excerpt; font-size: .98rem; }
  .story-grid--all .story-card:not(.story-card--feature) .go { grid-area: go; padding-top: .2rem; }
}

/* ---------- Stories page ---------- */
.pg-stories .sec--stories { padding-bottom: clamp(48px, 6vw, 88px); }
.pg-stories .stories__bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem;
  margin-bottom: clamp(24px, 3vw, 40px); padding-bottom: 1.3rem; border-bottom: 1px solid var(--line);
}
.pg-stories .stories__title { margin: 0; font-size: clamp(1.55rem, 1.25rem + 1vw, 2.1rem); }
.story-filter { display: flex; flex-wrap: wrap; gap: .5rem; }
html:not(.js) .story-filter { display: none; }
.story-filter__btn {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 46px; padding: .5rem 1.1rem;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--white); color: var(--forest);
  font-weight: 700; font-size: 1rem; line-height: 1; cursor: pointer;
  transition: background .25s, border-color .25s, color .25s;
}
.story-filter__btn:hover { border-color: var(--sage); background: var(--mint); }
.story-filter__btn[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); color: var(--white); }
.story-filter__n { font-weight: 400; font-size: .9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.story-filter__n:empty { display: none; }
.story-filter__btn[aria-pressed="true"] .story-filter__n { color: var(--mint); }
html.js:not(.static) .story-grid--all.is-filtering .story-card:not([hidden]) { animation: story-in .5s var(--ease-out) both; }
@keyframes story-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.pg-stories .stories__share { margin: clamp(40px, 5vw, 64px) auto 0; max-width: 40rem; text-align: center; color: var(--ink-soft); font-size: 1.02rem; }
.pg-stories .stories__share a { font-weight: 700; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .story-filter { gap: .4rem; }
  .story-filter__btn { padding: .5rem .95rem; }
}
/* 360px phones: four chips on one row (the 560px rule above sets the padding, so this must come after it) */
@media (max-width: 400px) { .story-filter__btn { padding-inline: .85rem; } }

@media (max-width: 420px) { .story-filter__n { display: none; } }

/* ==========================================================================
   Post pages: a calm reading layout (.wrap--reading, 680px)
   ========================================================================== */
.post__hero { position: relative; isolation: isolate; overflow: hidden; padding: calc(var(--header-h) + clamp(28px, 5vw, 72px)) 0 clamp(28px, 3.5vw, 48px); }
.post__hero::before {
  content: ""; position: absolute; z-index: -1; inset: -35% -12% auto auto; width: min(80vw, 860px); aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--post-wash, var(--blush)) 0%, color-mix(in srgb, var(--post-wash, var(--blush)) 55%, transparent) 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 35%, transparent 72%); mask-image: linear-gradient(to bottom, black 35%, transparent 72%);
}
.post--article { --post-wash: var(--mint); }
.post--news { --post-wash: var(--lilac); }
.post__back { display: flex; width: fit-content; margin: 0 0 1.1rem; font-size: 1rem; }
.post__back .ico { width: 18px; height: 18px; transition: transform .35s var(--ease-out); }
.post__back:hover .ico { transform: translateX(-4px); }
.post__title { font-size: clamp(2.4rem, 1.5rem + 3.3vw, 4.3rem); line-height: 1.02; margin-bottom: .4em; }
.post__meta { display: flex; flex-wrap: wrap; gap: .25rem 0; margin: 0; color: var(--ink-soft); font-size: 1rem; }
.post__meta span + span::before { content: "·"; margin: 0 .65rem; }
.post__main { padding-bottom: clamp(56px, 7vw, 104px); }
/* phones: a compact hero, so the note's first button sits clear of the fixed "Leave this site" button */
@media (max-width: 560px) {
  .post__hero { padding: calc(var(--header-h) + 16px) 0 22px; }
  .post__back { margin-bottom: .3rem; }
  .post--noted .post__back { display: none; }   /* the note below has "Back to stories" */
  .post__hero .eyebrow { margin-bottom: .7rem; }
  .post__title { font-size: clamp(2.05rem, 1.4rem + 3vw, 2.4rem); line-height: 1.05; }
  .post__meta { font-size: .95rem; }
  .post__meta .post__by { flex-basis: 100%; }
  .post__meta .post__by + span::before { content: none; }
}
@media (max-width: 380px) { .post__title { font-size: 1.95rem; line-height: 1.02; } .post__hero { padding-bottom: 14px; } .post__hero .eyebrow { margin-bottom: .5rem; } }

/* before you read */
.post__note {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem 1.3rem;
  margin: 0 0 clamp(40px, 5vw, 64px); padding: clamp(22px, 3vw, 36px);
  border-radius: var(--r-lg); background: var(--blush);
}
.post__note-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--white); color: var(--rose-deep); font-size: 1.3rem; }
.post__note h2 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem); margin: .35rem 0 .35em; }
.post__note p { color: var(--ink); }
.post__note strong { color: var(--rose-deep); }
.post__note .actions { margin-top: 1.3rem; gap: .6rem; }
@media (max-width: 560px) {
  .post__note { grid-template-columns: 1fr; padding: 18px 18px 20px; border-radius: var(--r); }
  .post__note-mark { display: none; }
  .post__note h2 { margin: 0 0 .3em; font-size: 1.5rem; }
  .post__note p { font-size: 1.02rem; line-height: 1.55; }
  .post__note .actions { margin-top: 1rem; }
  .post__note .btn--primary, .post__note .btn--soft { flex: 1 1 100%; }
}

/* cover (un-noted posts only) */
.post__cover { margin: 0 0 clamp(36px, 5vw, 64px); aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden; background: var(--mint); }
.post__cover img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 1000px) { .post__cover { margin-inline: -90px; } }

/* body */
.post__body { color: var(--ink); line-height: 1.75; }
.post__body > :first-child { margin-top: 0; }
.post__body p { margin: 0 0 1.25em; }
.post__body h2 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.15rem); margin: 1.7em 0 .55em; }
.post__body a { font-weight: 700; overflow-wrap: anywhere; }
.post__body ul, .post__body ol { list-style: none; display: grid; gap: .55em; margin: 0 0 1.4em; }
.post__body ul > li { position: relative; padding-left: 1.6em; }
.post__body ul > li::before {
  content: ""; position: absolute; left: .1em; top: .45em; width: .62em; height: .82em; background: var(--garden);
  -webkit-mask: url(../assets/leaf.svg) center / contain no-repeat; mask: url(../assets/leaf.svg) center / contain no-repeat;
}
.post__body ol { counter-reset: n; }
.post__body ol > li { counter-increment: n; position: relative; padding-left: 2.1em; }
.post__body ol > li::before { content: counter(n); position: absolute; left: 0; top: -.08em; font-family: var(--serif); font-size: 1.45em; line-height: 1.2; color: var(--rose-deep); }
.post__figure { margin: 2.2em 0; border-radius: var(--r); overflow: hidden; background: var(--mint); }
.post__figure img { width: 100%; }
.post__figure--tall { width: min(100%, 400px); margin-inline: auto; }
@media (min-width: 1000px) { .post__figure:not(.post__figure--tall):not(.post__figure--small) { margin-inline: -60px; } }
.post__sign { font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 1.6rem; color: var(--rose-deep); margin-top: 1.4em; }
/* a small leaf marks the end of the piece */
.post__body::after {
  content: ""; display: block; width: 14px; height: 19px; margin: 2.2rem 0 0; background: var(--rose);
  -webkit-mask: url(../assets/leaf.svg) center / contain no-repeat; mask: url(../assets/leaf.svg) center / contain no-repeat;
}

/* the poem "He": set as verse */
.post__body--poem { padding-left: clamp(18px, 3vw, 34px); border-left: 2px solid var(--rose); }
.post__body--poem p { font-family: var(--serif); font-weight: 350; font-size: clamp(1.3rem, 1.15rem + .5vw, 1.5rem); line-height: 1.6; color: var(--forest); margin-bottom: 1.15em; max-width: 30em; }

/* newsletter extras */
.post__pdf { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: 0 0 2rem; padding: 1.1rem 1.2rem; border-radius: var(--r); background: var(--lilac); }
.post__pages { margin-top: 2.4rem; }
.post__pages > .acc-body { max-width: none; }
.post__page-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.post__page-grid figure { margin: 0; }
.post__page-grid img { width: 100%; border-radius: 10px; box-shadow: var(--shadow-sm); background: var(--white); }
.post__page-grid figcaption { margin-top: .5rem; text-align: center; font-size: .92rem; color: var(--ink-soft); }
@media (max-width: 560px) { .post__page-grid { grid-template-columns: 1fr; } }

.post__share { margin: clamp(40px, 5vw, 64px) 0 0; padding-top: 1.4rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 1rem; }
.post__share a { font-weight: 700; overflow-wrap: anywhere; }
.post__help { margin-top: clamp(32px, 4vw, 48px); }

/* more to read */
.post-more__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem 2rem; margin-bottom: clamp(24px, 3vw, 40px); }
.post-more__head h2 { margin: 0; }
/* posts with no note and no cover: a hairline between the meta and the first words */
.post__main > .post__body:first-child { padding-top: clamp(24px, 3vw, 36px); border-top: 1px solid var(--line); }
