/* ==========================================================================
   story-blocks.css — Story content blocks
   Part of The Edited Wild theme.
   Mobile-first; all colours and type via design tokens only.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Blocks wrapper
   -------------------------------------------------------------------------- */
.story__blocks {
  padding-block: clamp(1.5rem, 3vw, 2.5rem);
}

.story-block {
  margin-block: clamp(2rem, 4.5vw, 3.5rem);
}

/* --------------------------------------------------------------------------
   2. Two-column block
   -------------------------------------------------------------------------- */

/*
 * Layout strategy: .story-block__media-col wraps [image + secondary + caption]
 * as a single flex column, making them one grid cell. The grid only has two
 * direct children: media-col and text. media-right swaps them with order.
 */
.story-block--two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.5rem, 4vw, 2.5rem);
}

/* The image column: stacks image, secondary image, caption vertically */
.story-block__media-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media (min-width: 48rem) {
  .story-block--two-col {
    grid-template-columns: 1fr 1.1fr;
    align-items: start;
    gap: clamp(2.5rem, 5vw, 4rem);
  }

  /* media-right: swap the two columns */
  .story-block--media-right .story-block__media-col {
    order: 2;
  }

  .story-block--media-right .story-block__text {
    order: 1;
  }

  .story-block__media-secondary {
    margin-top: 1rem;
    max-width: 65%;
  }
}

.story-block__media {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  aspect-ratio: 4 / 5;
}

.story-block__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  will-change: transform;
}

.story-block__embed {
  width: 100%;
  height: 100%;
}

.story-block__embed iframe {
  width: 100%;
  height: 100%;
}

.story-block__text {
  font-size: 1.05rem;
  line-height: 1.78;
  color: var(--tew-ink);
}

.story-block__text p {
  font-size: 1.05rem;
  line-height: 1.82;
  color: var(--tew-ink);
  margin-block: 0 1.4em;
  max-width: none; /* override global p max-width — container handles this */
}

/* Pull-quote inside story block text column */
.story-block__text blockquote {
  font-family: var(--tew-serif);
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.55;
  color: var(--tew-muted);
  border: none;
  border-left: 2px solid var(--tew-rule);
  padding: 0 0 0 1.25rem;
  margin-block: 1.5em;
  margin-inline: 0;
}

.story-block__text blockquote p {
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  max-width: none;
}

/* Section headings inside story blocks — small, intimate, not page-level */
.story-block__text h2 {
  font-family: var(--tew-serif);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.25;
  color: var(--tew-ink);
  margin-top: 0;
  margin-bottom: .85rem;
  letter-spacing: 0;
  max-width: none;
}

.story-block__text h3 {
  font-family: var(--tew-sans);
  font-size: var(--tew-eyebrow);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--tew-muted);
  margin-top: 0;
  margin-bottom: .75rem;
}

.story-block__media-secondary {
  margin-top: 1.5rem;
  max-width: 70%;
  border-radius: 4px;
  overflow: hidden;
}

.story-block__media-secondary img {
  width: 100%;
  height: auto;
  display: block;
}

.story-block__media-col .story-block__caption {
  text-align: left;
  max-width: none;
  padding-inline: 0;
  margin-top: .6rem;
  margin-inline: 0;
}

/* --------------------------------------------------------------------------
   3. Full-bleed block
   -------------------------------------------------------------------------- */
.story-block--full-bleed {
  margin-block: clamp(2.5rem, 6vw, 4.5rem);
  /* Prevent the full-bleed technique from creating horizontal scrollbar */
  overflow-x: clip;
}

.story-block__media-full {
  width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
  position: relative;
  /* Mobile: use aspect-ratio for predictable height */
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: 60dvh;
}

.story-block__media-full .story-block__img,
.story-block__media-full .story-block__embed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-block__caption {
  font-family: var(--tew-sans);
  font-size: .8rem;
  letter-spacing: .04em;
  color: var(--tew-muted);
  margin-top: .75rem;
  text-align: center;
  max-width: var(--tew-read);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

/* --------------------------------------------------------------------------
   4. Pull-quote block
   -------------------------------------------------------------------------- */
.story-block--quote {
  max-width: 40rem;
  margin-inline: auto;
  text-align: center;
  padding-block: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--tew-rule);
  border-bottom: 1px solid var(--tew-rule);
  position: relative;
}

.story-block__quote-text {
  font-family: var(--tew-serif);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.3;
  color: var(--tew-ink);
  font-style: normal;
  text-wrap: balance;
  margin: 0;
}

.story-block__cite {
  display: block;
  margin-top: 1.25rem;
  font-family: var(--tew-sans);
  font-size: var(--tew-eyebrow);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--tew-muted);
  font-style: normal;
}

.story-block__cite::before {
  content: "— ";
}

/* --------------------------------------------------------------------------
   5. Video block
   -------------------------------------------------------------------------- */
.story-block--video .story-block__embed {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
}

.story-block--video .story-block__embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------------------------
   6. Parallax hook — static attribute only, no JS/motion
   -------------------------------------------------------------------------- */
[data-tew-parallax] {
  overflow: hidden;
  will-change: transform;
}

/* ==========================================================================
   8. Gutenberg (block editor) blocks inside .story__body.tew-prose
   Styles map core blocks to the same editorial look as the old story-blocks.
   ========================================================================== */

/* ── 8a. Columns block — two-column editorial layout ───────────────────── */
.story__body .wp-block-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  margin-block: clamp(2rem, 4.5vw, 3.5rem);
  /* Override WP default flex */
  flex-wrap: unset;
  align-items: start;
}

@media (min-width: 48rem) {
  .story__body .wp-block-columns {
    grid-template-columns: 1fr 1.1fr;
    gap: clamp(2.5rem, 5vw, 4rem);
  }
}

.story__body .wp-block-column {
  min-width: 0; /* prevent grid blowout */
}

/* Image column: a clipping frame holding an oversized image so it can
   drift on scroll (real parallax) without exposing edges. */
.story__body .wp-block-column .wp-block-image {
  margin-block: 0;
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: 4px;
}

.story__body .wp-block-column .wp-block-image img {
  position: absolute;
  top: -20%;
  left: 0;
  width: 100%;
  height: 140%; /* 40% vertical overflow = room to drift on scroll */
  object-fit: cover;
  display: block;
  will-change: transform;
}

/* Portrait images (id-bearing blocks with taller ratio) */
.story__body .wp-block-column .wp-block-image.is-style-tall img,
.story__body .wp-block-column:first-child .wp-block-image img {
  aspect-ratio: 4 / 5;
}

/* ── 8b. Image block + figcaption ─────────────────────────────────────── */
.story__body .wp-block-image {
  margin-block: clamp(2rem, 4vw, 3rem);
  margin-inline: 0;
}

.story__body .wp-block-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.story__body .wp-block-image figcaption,
.story__body .wp-element-caption {
  font-family: var(--tew-sans);
  font-size: .8rem;
  letter-spacing: .04em;
  color: var(--tew-muted);
  margin-top: .6rem;
  text-align: left;
  max-width: none;
  padding-inline: 0;
  line-height: 1.5;
}

/* ── 8c. Heading blocks ───────────────────────────────────────────────── */
.story__body .wp-block-heading,
.story__body h2.wp-block-heading {
  font-family: var(--tew-serif);
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.25;
  color: var(--tew-ink);
  margin-top: clamp(2rem, 4vw, 3rem);
  margin-bottom: .85rem;
  letter-spacing: 0;
  max-width: none;
}

.story__body h3.wp-block-heading {
  font-family: var(--tew-sans);
  font-size: var(--tew-eyebrow);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--tew-muted);
  font-style: normal;
  margin-top: 1.75rem;
  margin-bottom: .75rem;
}

/* ── 8d. Quote / Pullquote block ──────────────────────────────────────── */
.story__body .wp-block-quote {
  border: none;
  border-top: 1px solid var(--tew-rule);
  border-bottom: 1px solid var(--tew-rule);
  padding-block: clamp(2rem, 4vw, 3rem);
  padding-inline: 0;
  margin-block: clamp(2.5rem, 5vw, 3.75rem);
  margin-inline: 0;
  text-align: center;
}

.story__body .wp-block-quote p {
  font-family: var(--tew-serif);
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  line-height: 1.32;
  color: var(--tew-accent);
  font-style: normal;
  max-width: 36rem;
  margin-inline: auto;
  margin-bottom: 0;
  text-wrap: balance;
}

.story__body .wp-block-quote cite,
.story__body .wp-block-quote .wp-block-quote__citation {
  display: block;
  margin-top: 1rem;
  font-family: var(--tew-sans);
  font-size: var(--tew-eyebrow);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--tew-muted);
  font-style: normal;
}

.story__body .wp-block-pullquote {
  border: none;
  border-top: 1px solid var(--tew-rule);
  border-bottom: 1px solid var(--tew-rule);
  padding-block: clamp(2rem, 4vw, 3rem);
  margin-block: clamp(2.5rem, 5vw, 3.75rem);
  text-align: center;
}

.story__body .wp-block-pullquote blockquote {
  border: none;
  padding: 0;
  margin: 0;
}

.story__body .wp-block-pullquote p {
  font-family: var(--tew-serif);
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  line-height: 1.32;
  color: var(--tew-accent);
  font-style: normal;
  margin: 0;
  text-wrap: balance;
}

/* ── 8e. Paragraph block — prose reading styles ───────────────────────── */
.story__body .wp-block-paragraph {
  font-size: 1.125rem;
  line-height: 1.78;
  color: var(--tew-ink);
  margin-bottom: 1.6em;
  max-width: none;
}

/* Drop-cap on the very first paragraph in the body */
.story__body > .wp-block-paragraph:first-of-type::first-letter,
.story__body > .entry-content > .wp-block-paragraph:first-of-type::first-letter {
  font-family: var(--tew-serif);
  font-size: 4.2em;
  font-weight: 400;
  line-height: .82;
  float: left;
  margin-right: .08em;
  margin-top: .06em;
  color: var(--tew-ink);
}

/* ── 8f. Separator ────────────────────────────────────────────────────── */
.story__body .wp-block-separator {
  border: none;
  border-top: 1px solid var(--tew-rule);
  margin-block: clamp(2rem, 4vw, 3rem);
}

/* ── 8g. Parallax on story body images ────────────────────────────────── */
.story__body .wp-block-column .wp-block-image[data-tew-parallax] img,
.story__body .wp-block-image[data-tew-parallax] img {
  will-change: transform;
}

/* ── 8h. Responsive adjustments ──────────────────────────────────────── */
@media (min-width: 64rem) {
  .story__body .wp-block-paragraph {
    font-size: 1.175rem;
    line-height: 1.82;
  }
}

/* ── 8i. Mobile: full-bleed on tablet+ restores cinematic height ─────── */
@media (min-width: 48rem) {
  .story-block__media-full {
    aspect-ratio: unset;
    height: clamp(280px, 60vw, 760px);
    max-height: none;
  }
}

/* ── 8j. Mobile story-block tweaks (< 48 rem) ───────────────────────── */
@media (max-width: 47.9375rem) {
  /* Two-col block: slightly tighter gap when stacked */
  .story-block--two-col {
    gap: clamp(1rem, 3vw, 2rem);
  }

  /* Secondary image: full width on mobile (no 65% constraint) */
  .story-block__media-secondary {
    max-width: 100%;
    margin-top: 1rem;
  }

  /* Pull-quote block: tighter on narrow screens */
  .story-block--quote {
    padding-block: clamp(1.5rem, 4vw, 2.5rem);
  }

  .story-block__quote-text {
    font-size: clamp(1.4rem, 5.5vw, 2.75rem);
  }

  /* Needtoknow panel: ensure inner padding is comfortable on phone */
  .story__needtoknow-inner {
    padding: clamp(1.25rem, 4vw, 2rem) clamp(1rem, 3vw, 2rem);
  }

  /* Needtoknow rows: ensure key/value stack cleanly (1fr grid already) */
  .story__needtoknow-row dt {
    font-size: .65rem;
  }
}

/* Columns inside the prose container must break out of the reading-column
   max-width (42rem / ~672px) and use the wider tew-container width.
   Strategy: the .story__body has max-width: var(--tew-read) ~672px and is
   centred inside .tew-container (max-width: 1200px with side padding).
   We use left:50% + transform to centre-align against the viewport, capped
   by --tew-maxw so it never exceeds the site container.
   The parent .story__blocks / .tew-container has overflow-x:hidden as
   safety net against the translate technique causing scroll-width blowout. */
.story__body .wp-block-columns {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  /* Subtract 2× side padding to keep flush with .tew-container edges */
  width: min(var(--tew-maxw), 100vw - 2 * clamp(1rem, 4vw, 2.5rem));
  max-width: none;
  box-sizing: border-box;
  overflow-x: hidden; /* guard against translate technique blowout */
}

/* --------------------------------------------------------------------------
   7. "The Practical" need-to-know panel
   -------------------------------------------------------------------------- */
.story__needtoknow {
  background-color: var(--tew-ink);
  border-radius: 4px;
  margin-block: clamp(2.5rem, 6vw, 4.5rem);
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

.story__needtoknow-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(2rem, 4vw, 3rem);
  padding: clamp(2rem, 5vw, 3rem) clamp(1.5rem, 4vw, 3rem);
}

@media (min-width: 64rem) {
  .story__needtoknow-inner {
    grid-template-columns: minmax(0, 38%) 1fr;
    gap: clamp(2.5rem, 5vw, 4rem);
    align-items: start;
  }
}

.story__needtoknow-eyebrow {
  font-family: var(--tew-sans);
  font-size: var(--tew-eyebrow);
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--tew-accent-ink);
  margin-bottom: 1rem;
}

.story__needtoknow-heading {
  font-family: var(--tew-serif);
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  font-weight: 400;
  line-height: 1.2;
  color: var(--tew-bg);
  margin-bottom: .75rem;
}

.story__needtoknow-location {
  font-family: var(--tew-sans);
  font-size: .95rem;
  color: rgba(250, 246, 240, .55);
  margin: 0;
}

.story__needtoknow-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.story__needtoknow-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: .2rem;
  padding-block: .9rem;
  border-bottom: 1px solid rgba(250, 246, 240, .12);
}

@media (min-width: 48rem) {
  .story__needtoknow-row {
    grid-template-columns: 10rem 1fr;
    gap: 1rem;
    align-items: baseline;
  }
}

.story__needtoknow-row:last-child {
  border-bottom: none;
}

.story__needtoknow-row dt {
  font-family: var(--tew-sans);
  font-size: var(--tew-eyebrow);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(250, 246, 240, .55);
}

.story__needtoknow-row dd {
  font-family: var(--tew-serif);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--tew-bg);
  margin: 0;
}
