/* Scene: close, on base.css's ink close. Hold: an ink close with all three requests ruled on
   the paper brief. Live (.is-live): one request at a time, 3 to 4 s per swap, pausable, held away. Home
   (.close--home, .is-shift): a chalk layer fades out from 60% to 35% of the viewport, the brief rises at 85%
   (.is-up), and the question, lead and action land on ink (.is-in) in reading order. */

/* ---------- Composition. DOM order is the phone order: question, lead, brief, action. ---------- */
.close__grid { display: grid; row-gap: var(--s-5); align-items: start; }
.close__title { max-width: 18ch; }
.close__lead { margin-top: calc(var(--s-4) + var(--s-1)); max-width: 44ch; }
.close__act { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4) var(--s-5); }
.close__email { margin-top: 0; line-height: var(--lh-small); }
@media (min-width: 768px) {
  .close__grid { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--grid-gap); row-gap: var(--s-6); }
  /* copy ends row 1 and the action starts row 2, so the pair centres on the brief */
  .close__copy { grid-column: 1 / span 6; grid-row: 1; align-self: end; }
  .close__act { grid-column: 1 / span 6; grid-row: 2; }
  .close__card { grid-column: 7 / span 6; grid-row: 1 / span 2; align-self: center; }
}
@media (min-width: 1024px) {
  .close__card { grid-column: 8 / span 5; }
}

/* ---------- The paper brief: the flagship brief's title and hairline-ruled lines ---------- */
.close__card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.close__label {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--t-paper-title);
  font-weight: var(--wght-h3);
  font-stretch: var(--wdth-h3);
  letter-spacing: var(--tr-h3);
  line-height: var(--lh-h3);
  text-wrap: balance;
}
.close__examples {
  grid-column: 1 / -1;
  display: grid;
  margin: var(--s-3) 0 0;
  padding: 0;
  list-style: none;
}
.close__example {
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: var(--t-body);
  line-height: var(--lh-lead);
  letter-spacing: var(--tr-lead);
}
.close__example:last-child { padding-bottom: 0; }
.close__example::before, .close__example::after { content: none; }
@media (min-width: 768px) {
  .close__example { font-size: var(--t-lead); }
}

/* Pause or play: the transport toggle's 44 px target with a 36 px face (concentric radius). */
.close__toggle { display: none; position: relative; isolation: isolate; }
.close__toggle::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 4px;
  border-radius: var(--r-xs);
  background: var(--sunken);
  transition: background-color var(--d-quick) var(--e-glide), transform var(--d-tap) var(--e-glide);
}
.close__toggle:active::before { transform: scale(.97); }
.close__toggle .glyph { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .close__toggle:hover { background: transparent; }
  .close__toggle:hover::before { background: var(--line); }
}
.close__card :focus-visible { outline-color: var(--focus); }
/* The timer: a hairline whose fill is a real element, so its transform is composited. */
.close__timer { display: none; grid-column: 1 / -1; position: relative; height: 1px; margin-right: var(--s-4); overflow: hidden; background: var(--line); }
.close__timer b { position: absolute; inset: 0; background: var(--ink-3); transform: scaleX(0); transform-origin: 0 50%; }

/* ---------- Live: one request at a time (set by close.js, screen only) ---------- */
@media screen {
  .close.is-live .close__card { padding: var(--s-2) var(--s-2) var(--s-5) var(--s-5); }
  .close.is-live .close__label { min-height: 44px; padding-block: var(--s-2); }
  .close.is-live .close__toggle { display: inline-grid; }
  .close.is-live .close__timer { display: block; }
  .close.is-live .close__examples { margin: var(--s-1) var(--s-4) 0 0; border-top: 1px solid var(--line); }
  .close.is-live .close__example { grid-area: 1 / 1; align-self: center; padding: var(--s-4) 0; border-top: 0; opacity: 0; }
  .close.is-live .close__example.is-current { opacity: 1; }
}

/* ---------- Home: chalk to ink. The brief rises on the way, the copy lands on ink ---------- */
.close__chalk { display: none; }
.close--home .close__grid { position: relative; } /* paints above the chalk layer */
.js[data-motion="full"] .close--home.is-shift .close__chalk {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--chalk);
  pointer-events: none;
  will-change: opacity;
}
/* Waiting: chalk text cannot sit on mid grey, so the copy waits for ink. Paper reads on all three, so the brief
   waits only until it rises. */
.js[data-motion="full"] .close--home.is-shift:not(.is-in) :is(.close__title, .close__lead, .close__act),
.js[data-motion="full"] .close--home.is-shift:not(.is-in) .close__card:not(.is-up) { opacity: 0; pointer-events: none; }
.close--home.is-in :is(.close__title, .close__lead, .close__act) {
  animation: winch-reveal var(--land-d, 560ms) var(--e-settle) calc(var(--land-wait, 0ms) + var(--land-at, 0ms)) backwards;
}
.close--home .close__title { --reveal-y: .45em; }
.close--home .close__lead { --reveal-y: .45em; --land-at: 80ms; }
.close--home .close__act { --reveal-y: 12px; --land-d: var(--d-move); --land-at: 160ms; }
/* the card's opacity settles early while its 24 px rise runs on, so it never reads grey. On home it rises in
   view, or with the lead (--up-at) if the close lands first. */
@keyframes close-card-in { from { opacity: 0; transform: translate3d(0, 24px, 0); } 40% { opacity: 1; } }
.close--home.is-shift:not(.is-now) .close__card.is-up { animation: close-card-in var(--d-enter) var(--e-settle) var(--up-at, 0ms) backwards; }
.js[data-motion="full"] .close__card.reveal-pending[data-reveal].is-in:not(.reveal-now) { animation-name: close-card-in; } /* focus reveals it at once */
.close--home.is-in .close__chalk { opacity: 0 !important; transition: opacity calc(2 * var(--land-wait, 0ms)) var(--e-glide); }
.close--home.is-now :is(.close__chalk, .close__title, .close__lead, .close__card, .close__act) { animation: none; transition: none; }
.motion-failsafe .close__chalk { display: none !important; }
.motion-failsafe .close--home :is(.close__title, .close__lead, .close__card, .close__act) { opacity: 1 !important; }
@media print {
  .close__grid { display: block; }
  .close__grid > * + * { margin-top: var(--s-5); }
  .close__chalk { display: none !important; }
  .close--home :is(.close__title, .close__lead, .close__card, .close__act) { opacity: 1 !important; animation: none !important; }
}
