/* ============================================================================
   Playbooks v3: lime glass field panel + auto-rotating carousel.
   Exactly 5 fully visible cards (1 expanded stage at slot 2 + 4 compact),
   no edge peeks; one uniform milky-white crystal glass material for every
   card; the lime image provides all the color.
   Scope: #night-chapter .pb-zone-playbooks.claude-plays
   ========================================================================== */

#night-chapter .pb-zone-playbooks.claude-plays {
  --plays-ink: #171a09;
  --plays-ink-mid: rgba(23, 26, 9, .78);
  --plays-hairline: rgba(255, 255, 255, .78);
  --plays-ease: cubic-bezier(.22, 1, .36, 1);
  --plays-gap: 12px;
  /* exact fit: expanded 32cqw + 4 x (17cqw - gap) + 4 gaps = 100cqw */
  --plays-pwe: 32cqw;
  --plays-pw: calc(17cqw - var(--plays-gap));
  --plays-rot: 620ms;

  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(36px, 6vh, 64px);
  min-height: clamp(600px, 82vh, 780px);
  padding: clamp(52px, 8vh, 84px) clamp(18px, 3.4vw, 48px) clamp(20px, 3vh, 34px);
  /* pale lime placeholder: the panel never flashes white while the image lazy-loads */
  background: #e6ec5f;
}

/* retire the old zone's ambient glow layer */
#night-chapter .pb-zone-playbooks.claude-plays::before {
  content: none;
}

/* ---------- background image (used as-is, edge to edge) ---------- */

.claude-plays-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.claude-plays-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* ---------- head: kept copy, dark ink over the image's empty center ---------- */

#night-chapter .claude-plays .pb-zone-head {
  padding: 0;
  text-align: center;
}

#night-chapter .claude-plays .pb-head-copy .pb-title {
  max-width: 22ch;
  margin-inline: auto;
  color: var(--plays-ink);
  font-size: clamp(30px, 3.8vw, 48px);
  text-wrap: balance;
}

#night-chapter .claude-plays .pb-head-copy .pb-sub {
  max-width: 52ch;
  margin-inline: auto;
  color: var(--plays-ink-mid);
}

/* ---------- carousel row: aligned with the panel's content width ---------- */

.claude-plays-deck {
  width: min(1240px, 100%);
  margin-inline: auto;
  /* clip the row's ends (no peeking cards) while letting the category light
     spill below the cards; clip + visible is a legal overflow pair */
  overflow-x: clip;
  overflow-y: visible;
  container-type: inline-size;
}

.claude-plays-track {
  display: flex;
  align-items: stretch;
  gap: var(--plays-gap);
  min-height: clamp(280px, 36vh, 336px);
  /* rest: children 0-4 fill the deck exactly; the rest sit beyond the edge */
  will-change: transform;
}

.claude-plays-track.is-anim {
  transition: transform var(--plays-rot) var(--plays-ease);
}

/* ---------- category light: one refined accent per category ----------
   The color NEVER paints the card. It lives in a soft radial bloom that sits
   behind the frosted face, so the face's backdrop-filter samples it and the
   hue reads as light shining up through the frost. */

.claude-play[data-cat="acct"] { --cat: 123, 92, 214;  --cat-ink: #4a3a99; }  /* violet */
.claude-play[data-cat="ab"]   { --cat: 210, 112, 60;  --cat-ink: #7d3f14; }  /* ember */
.claude-play[data-cat="pers"] { --cat: 31, 158, 143;  --cat-ink: #0e5c52; }  /* teal */
.claude-play[data-cat="aeo"]  { --cat: 63, 111, 216;  --cat-ink: #2b4c94; }  /* azure */

/* the card shell carries no material of its own: it positions the bloom
   (behind) and the glass face (in front), and must not clip the bloom */
.claude-play {
  position: relative;
  flex: none;
  box-sizing: border-box;
  width: var(--plays-pw);
}

/* pre-blurred by construction: a radial gradient, no filter, nothing animated.
   Strongest under the card's lower half, spilling past the bottom edge. */
.claude-play-glow {
  position: absolute;
  left: -7%;
  right: -7%;
  top: 26%;
  bottom: -24px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 62% at 50% 76%, rgba(var(--cat), .95), rgba(var(--cat), .42) 44%, rgba(var(--cat), 0) 74%);
  /* past the card's edge the light has no frost over it, so the raw tail is
     faded out: what escapes reads as under-glow, not as a painted halo */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), rgba(0, 0, 0, .3) calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), rgba(0, 0, 0, .3) calc(100% - 16px), transparent 100%);
}

/* ---------- one uniform crystal-glass material for every card ---------- */

.claude-play-face {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg, 22px);
  border: 1px solid var(--plays-hairline);
  background: linear-gradient(180deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .66));
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .85),
    inset 0 -1px 0 rgba(255, 255, 255, .25),
    /* the drop shadow carries a matching tint of the same light */
    0 22px 44px -20px rgba(var(--cat), .5),
    0 10px 24px -14px rgba(72, 82, 12, .5),
    0 6px 16px -8px rgba(72, 82, 12, .22);
}

.claude-plays-track.is-anim .claude-play {
  transition:
    width var(--plays-rot) var(--plays-ease),
    opacity calc(var(--plays-rot) - 140ms) ease;
}

/* edge choreography: entering cards fade in, exiting cards fade out */
.claude-play.is-enter,
.claude-play.is-exit {
  opacity: 0;
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .claude-play-face {
    background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .86));
  }
}

@media (prefers-reduced-transparency: reduce) {
  .claude-play-face {
    background: rgba(255, 255, 255, .95);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /* no frost to shine through: the light survives only as the tinted shadow */
  .claude-play-glow {
    opacity: .35;
  }
}

.claude-play.is-open {
  width: var(--plays-pwe);
}

/* compact cards lift slightly on hover; no hover-expansion anywhere */
@media (hover: hover) and (pointer: fine) {
  .claude-play:not(.is-open) {
    transition: transform 200ms var(--plays-ease);
  }

  .claude-play:not(.is-open):hover {
    transform: translateY(-3px);
  }
}

/* ---------- card content ---------- */

.claude-play-h {
  margin: 0;
  display: contents;
}

.claude-play-btn {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  /* The 12px top is the gap this button used to hold between the chip and the
     title; the chip left the button when it left the heading, and took the
     card's top padding with it. */
  padding: 12px clamp(16px, 1.6vw, 20px) 0;
}

.claude-play:not(.is-open) .claude-play-btn {
  padding-bottom: clamp(16px, 1.6vw, 20px);
}

.claude-play.is-open .claude-play-btn {
  cursor: default;
  /* the stage card stacks from the top: tag, title, then the copy below */
  flex: 0 0 auto;
}

/* whole card is the hit area (the face is the positioned ancestor) */
.claude-play-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

/* ---------- ghost wireframe: what the play actually does ---------- */

.claude-play-wf {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;                    /* behind the card's own text, above the face fill */
  width: 74%;
  height: auto;
  transform: translate(-50%, -50%);
  color: var(--plays-ink);
  opacity: .13;
  pointer-events: none;
}

/* on the stage card it joins the flex flow after the copy: pinned to the
   lower right by auto margins, so however long the body runs, the wireframe
   always sits below it instead of behind it */
.claude-play.is-open .claude-play-wf {
  position: static;
  order: 10;
  width: 44%;
  min-height: 0;
  margin: auto 5% 6% auto;
  align-self: flex-end;
  transform: none;
  opacity: .2;
}

/* the single highlight stroke may carry the category light */
.claude-play-wf .wf-a {
  stroke: rgb(var(--cat));
}

.claude-play-btn:focus-visible {
  outline: none;
}

.claude-play-btn:focus-visible::after {
  outline: 2px solid var(--plays-ink);
  outline-offset: -6px;
  border-radius: calc(var(--r-lg, 22px) - 4px);
}

/* tag: glass chip outlined in the category color, label in the same hue */
.claude-play-tag {
  display: inline-flex;
  align-items: center;
  /* A flex child of the card face now, not of the button: it holds its own top
     and side padding and refuses the column's default stretch. */
  align-self: flex-start;
  flex: 0 0 auto;
  margin: clamp(16px, 1.6vw, 20px) clamp(16px, 1.6vw, 20px) 0;
  padding: 5px 9px;
  border-radius: var(--r-sm, 8px);
  border: 1px solid rgba(var(--cat), .7);
  background: transparent;
  color: var(--cat-ink);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  white-space: nowrap;
}

/* compact: title pinned to the bottom of the card */
.claude-play-title {
  display: block;
  margin-top: auto;
  color: var(--plays-ink);
  font-weight: 500;
  font-size: clamp(15px, 1.3vw, 17px);
  line-height: 1.28;
  letter-spacing: -.01em;
  text-wrap: balance;
}

/* expanded: title high, larger, slightly bolder */
.claude-play.is-open .claude-play-title {
  margin-top: clamp(14px, 2.4vh, 26px);
  font-weight: 600;
  font-size: clamp(22px, 1.9vw, 26px);
  letter-spacing: -.015em;
  animation: claude-play-title-in var(--plays-rot) both;
}

@keyframes claude-play-title-in {
  0%, 45% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: none; }
}

/* the card leaving the stage: a quick dip masks its internal reflow */
.claude-play.is-closing .claude-play-title {
  animation: claude-play-title-swap var(--plays-rot) both;
}

@keyframes claude-play-title-swap {
  0% { opacity: 0; }
  55% { opacity: 0; }
  100% { opacity: 1; }
}

/* detail copy: fixed measure (container units) so it never rewraps mid-slide */
.claude-play-body {
  flex: none;
  padding: 0 clamp(16px, 1.6vw, 20px);
  overflow: hidden;
  height: 0;
  opacity: 0;
}

.claude-play.is-open .claude-play-body {
  height: auto;
  padding-bottom: clamp(18px, 2vh, 24px);
  opacity: 1;
  animation: claude-play-body-in calc(var(--plays-rot) + 160ms) both;
}

@keyframes claude-play-body-in {
  0%, 55% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: none; }
}

.claude-play-line {
  margin: 10px 0 0;
  width: min(46ch, calc(var(--plays-pwe) - 44px));
  max-width: none;
  color: var(--plays-ink-mid);
  font-size: 15px;
  line-height: 1.55;
}

/* narrow row (1024-1279): smaller chips so compact cards keep the longest tag */
@media (min-width: 1024px) and (max-width: 1279px) {
  .claude-play-tag {
    padding: 4px 7px;
    font-size: 9.5px;
    letter-spacing: .05em;
  }
}

/* ---------- rotation loader: dark-ink hairline along the stage card's bottom ---------- */

.claude-play.is-open::after {
  content: "";
  position: absolute;
  z-index: 2;              /* above the glass face */
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  border-radius: 1px;
  background: rgba(23, 26, 9, .6);
  transform: scaleX(0);
  transform-origin: left;
  /* delay ~= rotation length: the count starts once the card has settled */
  animation: claude-plays-load 5000ms linear var(--plays-rot) both;
}

.claude-plays.is-paused .claude-play.is-open::after {
  animation-play-state: paused;
}

@keyframes claude-plays-load {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- prev / next glass buttons, bottom-right ---------- */

.claude-plays-navrow {
  width: min(1240px, 100%);
  margin-inline: auto;
  padding: 0;
}

.claude-plays-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: clamp(12px, 1.6vh, 18px);
}

.claude-plays-arrow {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm, 8px);
  border: 1px solid var(--plays-hairline);
  background: linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, .55));
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 8px 18px -10px rgba(72, 82, 12, .4);
  color: var(--plays-ink);
  cursor: pointer;
  transition: transform 180ms var(--plays-ease);
}

.claude-plays-arrow svg {
  width: 15px;
  height: 15px;
  display: block;
}

@media (hover: hover) and (pointer: fine) {
  .claude-plays-arrow:hover {
    transform: translateY(-2px);
  }
}

.claude-plays-arrow:active {
  transform: scale(.96);
}

.claude-plays-arrow:focus-visible {
  outline: 2px solid var(--plays-ink);
  outline-offset: 2px;
}

@media (prefers-reduced-transparency: reduce) {
  .claude-plays-arrow {
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ============================================================================
   < 1024px: horizontal scroll-snap carousel. The centered card is the
   expanded one; prev/next cards peek as the swipe affordance.
   ========================================================================== */

@media (max-width: 1023px) {
  #night-chapter .pb-zone-playbooks.claude-plays {
    --plays-mw: min(74vw, 330px);
    min-height: 0;
    gap: 30px;
    padding-block: clamp(44px, 7vh, 64px) clamp(18px, 3vh, 28px);
  }

  /* taller crop: keep the calm band behind the strip */
  .claude-plays-bg img {
    object-position: 50% 42%;
  }

  .claude-plays-deck {
    width: auto;
    margin-inline: calc(clamp(18px, 3.4vw, 48px) * -1);
    /* a horizontal scroller cannot keep overflow-y visible, so the glow's
       spill gets room from padding instead */
    padding-bottom: 30px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* center the snapped card, leaving symmetric peeks */
    padding-inline: calc((100vw - var(--plays-mw)) / 2 - var(--plays-gap));
  }

  .claude-plays-deck::-webkit-scrollbar {
    display: none;
  }

  .claude-plays-track {
    width: max-content;
    min-height: 0;
    transform: none;
    will-change: auto;
  }

  .claude-plays-track.is-anim {
    transition: none;
  }

  .claude-play,
  .claude-play.is-open {
    width: var(--plays-mw);
    min-height: 300px;
    scroll-snap-align: center;
    transition: none;
  }

  /* the horizontal scroller counts inline overflow, so the glow stays within
     the card's own width and spills only downward */
  .claude-play-glow {
    left: 0;
    right: 0;
    bottom: -22px;
  }

  /* one wireframe placement for every mobile card: lower right, clear of text */
  .claude-play .claude-play-wf {
    left: auto;
    top: auto;
    right: 5%;
    bottom: 6%;
    width: 46%;
    transform: none;
  }

  .claude-play.is-open .claude-play-wf {
    position: static;
    order: 10;
    width: 46%;
    min-height: 0;
    margin: auto 5% 6% auto;
    align-self: flex-end;
    opacity: .2;
  }

  .claude-play.is-enter,
  .claude-play.is-exit {
    opacity: 1;
  }

  .claude-play-btn {
    padding: 12px 18px 0;
  }

  .claude-play-tag {
    margin: 16px 18px 0;
  }

  /* uniform internal layout on mobile (no width morph): tag top, title high;
     only the detail copy toggles */
  .claude-play .claude-play-title {
    margin-top: 12px;
    font-size: 18px;
    font-weight: 500;
  }

  .claude-play.is-open .claude-play-title {
    font-size: 20px;
    font-weight: 600;
    animation: none;
  }

  .claude-play .claude-play-body {
    height: auto;
    padding-bottom: 18px;
    opacity: 0;
    transition: opacity 240ms ease;
  }

  .claude-play.is-open .claude-play-body {
    opacity: 1;
    animation: none;
  }

  .claude-play-line {
    width: auto;
    font-size: 14.5px;
  }

  .claude-play.is-open::after {
    animation-delay: 400ms;
  }

  /* swipe is the control surface */
  .claude-plays-nav {
    display: none;
  }
}

/* ---------- reduced motion: no auto-rotation, instant swaps ---------- */

@media (prefers-reduced-motion: reduce) {
  .claude-plays-track.is-anim,
  .claude-plays-track.is-anim .claude-play,
  .claude-play:not(.is-open),
  .claude-plays-arrow,
  .claude-play .claude-play-body {
    transition: none !important;
  }

  .claude-play.is-open .claude-play-title,
  .claude-play.is-closing .claude-play-title,
  .claude-play.is-open .claude-play-body {
    animation: none !important;
  }

  .claude-play.is-enter,
  .claude-play.is-exit {
    opacity: 1;
  }

  /* no cadence, no loader */
  .claude-play.is-open::after {
    content: none;
  }

  .claude-plays-track {
    will-change: auto;
  }

  .claude-plays-deck {
    scroll-behavior: auto;
  }
}
