/* Wren, in two places: its teaser page (/wren/) and its chapter on the home page.
   Mobile first; every rule works on paper and on the void because colours come from
   the section's shade tokens. The effects themselves (character field, decoding
   headings, the demo, the board, the glass mark) style themselves in fx.css; this
   file only lays out the page around them, and it is the finished page without them. */

/* ------------------------------------------------------------ shared pieces */
/* The status line: an outline dot (not out yet) and words a light passes over. */
.wren-status {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.015em; color: var(--muted);
}
.wren-status .dot { width: 7px; height: 7px; margin: 0; }

.wren .eyebrow,
.wren-chapter .eyebrow { color: var(--muted); }

/* The mark is a fixed square, so the glass reveal never shifts the copy under it. */
.wren-mark,
.wren-chapter-mark { aspect-ratio: 1; }
.wren-mark img,
.wren-chapter-mark img { width: 100%; height: 100%; object-fit: contain; }

/* =========================================================== /wren/ page */
.wren-hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: calc(100svh - 72px);
  display: flex; align-items: center;
  padding-block: 56px 72px;
}
.wren-hero-in {
  position: relative; z-index: 1; width: 100%;
  display: grid; justify-items: center; text-align: center;
}
.wren-mark { width: 200px; margin-bottom: 30px; }
.wren-hero .eyebrow { margin-bottom: 18px; }
.wren-hero h1 {
  font-size: clamp(38px, 10.4vw, 76px); font-weight: 560;
  line-height: 1.04; letter-spacing: -0.045em; text-wrap: balance;
}
.wren-hero h1 em { letter-spacing: -0.02em; }
.wren-intro {
  max-width: 54ch; margin-top: 24px;
  font-size: 15.5px; line-height: 1.75; color: var(--muted);
}
.wren-hero .wren-status { margin-top: 26px; }
.wren-links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 28px; margin-top: 22px;
}

/* Wren at work, over the marble. The plate is the backdrop the demo's glass bends;
   its top and bottom fade into the void so the scene has no hard edge. */
.wren-scene {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: flex-end;
  padding-block: 68vw 64px;
}
.wren-scene-plate {
  position: absolute; inset: 0 0 auto 0; height: 92vw; z-index: -1;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 64%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 64%, transparent);
}
.wren-scene-plate picture,
.wren-scene-plate img { width: 100%; height: 100%; }
.wren-scene-plate img {
  object-fit: cover; object-position: 4% 30%;
  filter: grayscale(1) contrast(1.04);
}
.wren-scene-in { width: 100%; }
.wren-scene .wd { width: 100%; max-width: 520px; margin-inline: auto; }

/* Four things it does, on hairlines: no card chrome. */
.wren-features .sec-head { margin-bottom: 36px; }
.wren-features h2,
.wren-board h2 {
  font-size: clamp(36px, 9.6vw, 60px); font-weight: 500;
  line-height: 1.06; letter-spacing: -0.035em;
}
.wren-feature-grid {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 1px; background: var(--hair);
  border-block: 1px solid var(--hair);
}
.wren-feature { background: var(--bg); padding: 26px 0 30px; }
.wren-feature h3 { font-size: 21px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.3; }
.wren-feature p { margin-top: 12px; max-width: 44ch; font-size: 15px; line-height: 1.75; color: var(--muted); }

/* Where it stands: the words, then the board. */
.wren-board { padding-top: 0; }
.wren-board-in { display: grid; gap: 40px; }
.wren-board-copy p { margin-top: 22px; max-width: 46ch; font-size: 15.5px; line-height: 1.8; color: var(--muted); }
.wren-board-list { margin: 0; border-top: 1px solid var(--hair-strong); }
.wren-board-list > div {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px;
  padding-block: 18px; border-bottom: 1px solid var(--hair);
}
.wren-board-list dt { font-size: 12px; font-weight: 500; color: var(--muted); }
.wren-board-list dd {
  margin: 0; min-width: 0;
  font-size: clamp(15px, 4.6vw, 24px); font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; overflow-wrap: anywhere;
}

/* ======================================================= home: Wren chapter */
/* scroll-expand owns the frame: its clip, the media's zoom and the copy's fade while
   the section is pinned (fx.css). This lays out what is inside it.
   Resting (the open frame, and the whole chapter wherever the pin does not run): on
   phones and tablets the mark sits at the top, under the header, and the copy keeps
   clear of it by padding, so the two can never meet however long a translation runs;
   on desktops the copy is on the left and the mark to its right. */
/* The mark grows with the screen's height faster than the copy does, so short
   phones (where the header may wrap to two rows: --head-h, from site.js) still fit
   both. */
.wren-chapter {
  --mk: clamp(60px, calc(26svh - 106px), 144px);   /* the mark's size */
  --mk-top: calc(var(--head-h, 72px) + 2.5svh);    /* its top, below the sticky header */
}
.wren-field { position: absolute; inset: 0; }
.wren-chapter .wren-chapter-mark {
  position: absolute; z-index: 1;
  left: 50%; top: var(--mk-top);
  width: var(--mk); margin-left: calc(var(--mk) / -2);
}
.wren-chapter .sx-overlay {
  /* safe: a copy too long for the screen runs off the foot, never up into the mark. */
  justify-content: safe flex-end; text-align: left;
  padding-top: calc(var(--mk-top) + var(--mk) + 20px);
  padding-bottom: clamp(36px, 6svh, 96px);
}
.wren-chapter-in {
  align-self: stretch; width: 100%; padding-inline: 0;
  max-width: calc(var(--maxw) - 2 * var(--pad));
}
.wren-chapter-copy { max-width: 540px; }
.wren-chapter .eyebrow { margin-bottom: 18px; }
.wren-chapter h2 {
  font-size: clamp(30px, min(10vw, 5.4svh), 70px); font-weight: 500;
  line-height: 1.04; letter-spacing: -0.035em;
}
.wren-chapter h2 em { font-size: 1.07em; }
.wren-chapter-body { max-width: 46ch; margin-top: 18px; font-size: 14px; line-height: 1.75; color: var(--muted); }
.wren-chapter .studio-hero-link { margin-top: 18px; }
.wren-chapter .wren-status { display: flex; margin-top: 16px; }
@media (min-height: 760px) {
  .wren-chapter .eyebrow { margin-bottom: 20px; }
  .wren-chapter-body { margin-top: 22px; font-size: 15px; line-height: 1.8; }
  .wren-chapter .studio-hero-link { margin-top: 22px; }
  .wren-chapter .wren-status { margin-top: 20px; }
}

/* ================================================================ tablet up */
@media (min-width: 721px) {
  .wren-hero { min-height: calc(100svh - 82px); padding-block: clamp(80px, 11vh, 130px); }
  .wren-mark { width: clamp(200px, 15vw, 224px); margin-bottom: clamp(24px, 3.6vh, 40px); }
  .wren-intro { font-size: 17px; margin-top: 26px; }
  .wren-hero .wren-status { margin-top: 30px; }
  .wren-links { gap: 12px 36px; margin-top: 26px; }

  .wren-scene {
    min-height: min(94svh, 900px); align-items: center;
    padding-block: clamp(100px, 13vw, 170px);
  }
  .wren-scene-plate {
    inset: 0; height: auto;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 80%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 80%, transparent);
  }
  .wren-scene-plate img { object-position: 18% 38%; }
  /* Right of the head, across the shoulder: the pane has stone and smoke behind it. */
  .wren-scene .wd { margin-inline: 40% 0; max-width: 540px; }

  .wren-features .sec-head { margin-bottom: 56px; }
  .wren-feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wren-feature { padding: clamp(28px, 3.4vw, 44px) clamp(24px, 3.4vw, 44px) clamp(30px, 3.6vw, 48px) 0; }
  .wren-feature:nth-child(even) { padding-left: clamp(24px, 3.4vw, 44px); }
  .wren-feature h3 { font-size: clamp(20px, 2vw, 24px); }

  .wren-board-in { grid-template-columns: 1fr 1fr; gap: clamp(48px, 8vw, 110px); align-items: center; }
  .wren-board-copy p { font-size: 17px; }
  .wren-board-list > div { grid-template-columns: minmax(90px, 0.5fr) 1.5fr; align-items: center; gap: 24px; padding-block: 22px; }

  .wren-chapter { --mk: clamp(96px, calc(30svh - 130px), 184px); --mk-top: calc(var(--head-h, 82px) + 3svh); }
  .wren-chapter h2 { font-size: clamp(38px, min(10vw, 6.4svh), 70px); }
}
@media (min-width: 721px) and (min-height: 760px) {
  .wren-chapter-body { font-size: 16px; }
}

@media (min-width: 1001px) {
  /* Desktop: the copy on the left of the open frame, the mark to its right. */
  .wren-chapter { --mk: clamp(200px, 17vw, 250px); --mk-x: min(23vw, 340px); }
  .wren-chapter .wren-chapter-mark { top: 50%; margin-top: calc(var(--mk) / -2); left: calc(50% + var(--mk-x)); }
  .wren-chapter .sx-overlay { justify-content: center; padding-block: clamp(72px, 12vh, 140px); }
  .wren-chapter h2 { font-size: clamp(44px, 5vw, 70px); }
}

/* Pinned (scroll-expand running): the closed window shows only the middle of the
   frame, so the mark starts there and travels to its resting place as the frame opens.
   --sx-e is scroll-expand's eased 0 to 1; the frame is exactly one screen tall here. */
@media (prefers-reduced-motion: no-preference) and (min-height: 520px) {
  html:not(.lite) .wren-chapter.sx-on .wren-chapter-mark {
    transform: translate3d(0, calc((1 - var(--sx-e, 1)) * (50svh - var(--mk-top) - var(--mk) / 2)), 0);
  }
}
@media (prefers-reduced-motion: no-preference) and (min-height: 520px) and (min-width: 1001px) {
  html:not(.lite) .wren-chapter.sx-on .wren-chapter-mark {
    transform: translate3d(calc((var(--sx-e, 1) - 1) * var(--mk-x)), 0, 0);
  }
}

/* Reduced motion and html.lite: the page is already its static self. The field and
   the glass do not run there, so nothing here needs to change but the shimmer's
   colour, which fx.css settles. */
@media (prefers-reduced-motion: reduce) {
  .wren .studio-hero-link,
  .wren-chapter .studio-hero-link { transition: none; }
}
