/* ============================================================
   05 · FEATURES — bento grid
   All selectors scoped under .features
   Raw px appears only inside illustration internals (SVG geometry,
   hairlines, keyframe offsets) as allowed by the brief.
   ============================================================ */

/* ---------- Grid ---------- */
.features__grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: 1fr;
  margin-top: clamp(var(--s-10), 4vw, var(--s-16));
}

/* Tablet: 2 columns, large tiles run full width */
@media (min-width: 40rem) {
  .features__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(var(--s-40), auto);
    gap: var(--s-5);
  }
  .features__tile--lg { grid-column: 1 / -1; }
}

/* Desktop: 6-column track, composed 4/2 · 2/4 · 3/3 rhythm */
@media (min-width: 64rem) {
  .features__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--s-5);
  }
  .features__tile { grid-column: span 3; }          /* tiles 5 and 6 */
  .features__tile:nth-child(1) { grid-column: span 4; }
  .features__tile:nth-child(2) { grid-column: span 2; }
  .features__tile:nth-child(3) { grid-column: span 2; }
  .features__tile:nth-child(4) { grid-column: span 4; }
}

/* ---------- Tile (composes .card .card--hover) ---------- */
.features .features__tile {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: clamp(var(--s-4), 1.4vw, var(--s-6));
  padding: clamp(var(--s-5), 1.6vw, var(--s-8));
  overflow: hidden;
}

/* Large tiles get a different *composition*, not just a bigger box:
   illustration and copy sit side by side on one optical centre line. */
@media (min-width: 52rem) {
  .features .features__tile--lg {
    grid-template-rows: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 30ch);
    align-items: center;
    gap: clamp(var(--s-6), 2.2vw, var(--s-10));
  }
  .features__tile--lg .features__body p { max-width: none; }
}

/* soft brand wash — opacity only, never resizes the tile */
.features .features__tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(115% 82% at 50% 0%, var(--accent-soft) 0%, transparent 64%);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}

/* One state gate for the whole section: pointer hover, or .is-active
   which the inline observer toggles on no-hover (touch) devices.
   The lift is 05's own idea; the hairline/shadow comes from .card--hover
   so the gesture reads the same as every other card on the page. */
.features .features__tile:is(:hover, .is-active) {
  transform: translateY(calc(var(--s-1) * -1));
}
/* .card--hover only fires on :hover — mirror it for the touch fallback. */
.features .features__tile.is-active {
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--sh-lg);
}
.features .features__tile:is(:hover, .is-active)::before { opacity: 1; }

/* ---------- Tile contents ---------- */
/* One height rule for all six illustrations: the art block is capped in
   width, so SVG and CSS-authored art scale by the same law and land in
   the same height band instead of one letterboxing while the other grows. */
.features__art {
  display: grid;
  align-content: center;
  gap: var(--s-4);
  min-height: var(--s-32);
  max-width: calc(var(--s-40) * 2.8);
  min-width: 0;
}
.features__svg { width: 100%; }

.features__body h3 {
  font-size: var(--fs-h4);
  letter-spacing: var(--tracking-normal);
}
.features__body p {
  margin-top: var(--s-2);
  max-width: var(--maxw-prose);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--text-muted);
}

/* ============================================================
   Shared illustration primitives
   ============================================================ */
.features .features__svg * { transform-box: view-box; }

.features .features__svg [class*="fx-"] {
  transition:
    transform var(--dur-slow) var(--ease-expo),
    opacity var(--dur-slow) var(--ease-out);
  transition-delay: var(--d, 0ms);
}

.features .fx-subject { fill: var(--ink-400); }
.features .fx-blob { fill: var(--ink-300); }

/* Sequenced crossfade: the outgoing element always clears before the
   incoming one arrives, in both directions. --swap-hold buys time for a
   swap that has its own animation to finish first (see tile 6). */
.features .features__swap {
  display: grid;
  align-items: center;
  justify-items: end;
}
.features .features__swap > * {
  grid-area: 1 / 1;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-slow) var(--ease-expo);
}
.features .features__swap-out { transition-delay: var(--dur-fast); }
.features .features__swap-in { opacity: 0; transition-delay: 0ms; }
.features .features__tile:is(:hover, .is-active) .features__swap-out {
  opacity: 0;
  transition-delay: var(--swap-hold, 0ms);
}
.features .features__tile:is(:hover, .is-active) .features__swap-in {
  opacity: 1;
  transition-delay: calc(var(--swap-hold, 0ms) + var(--dur-fast));
}

/* ---------- 1 · Auto-reframe ---------- */
/* Rest: the vertical source frame only. Active: the other three crops
   widen in, each one paired with its ratio chip on the same delay. */
.features .fx-frame {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  transform-origin: 130px 74px;
}
.features .fx-frame--alt {
  stroke-width: 1.5;
  opacity: 0;
  transform: scaleX(0.62);
}
.features .features__tile:is(:hover, .is-active) .fx-frame--alt {
  opacity: 0.7;
  transform: none;
}
.features .fx-track {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 1.5;
  stroke-dasharray: 4 3.5;
  transform-origin: 130px 56px;
}
.features .features__tile:is(:hover, .is-active) .fx-track { transform: scale(1.1); }

.features__ratios {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: var(--s-2);
}
/* Composes .chip. Rest state is 07's quiet chip variant, verbatim;
   only the fill and text colour change, never the box. */
.features__ratio {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
  transition:
    color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
  transition-delay: 0ms;
}
.features .features__ratio.is-src,
.features .features__tile:is(:hover, .is-active) .features__ratio {
  background: var(--accent-soft);
  color: var(--accent);
}
.features .features__tile:is(:hover, .is-active) .features__ratio {
  transition-delay: var(--d, 0ms);
}

/* ---------- 2 · Watermark removal ---------- */
.features .fx-badge-bg { fill: var(--ink-700); }
.features .fx-badge-dot { fill: var(--ink-400); }
.features .fx-badge-bar { fill: var(--ink-300); }
.features .fx-badge { transform-origin: 186px 94px; }
.features .features__tile:is(:hover, .is-active) .fx-badge {
  opacity: 0;
  transform: scale(0.84);
}

.features .fx-dust circle { fill: var(--ink-400); opacity: 0; }
.features .features__tile:is(:hover, .is-active) .fx-dust circle {
  animation: features-burst var(--dur-slower) var(--ease-out) var(--d, 0ms) both;
}
@keyframes features-burst {
  0%   { opacity: 0; transform: none; }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.4); }
}

.features .fx-clean {
  opacity: 0;
  transform: scale(0.72);
  transform-origin: 186px 94px;
}
.features .fx-clean circle { fill: var(--mint-100); }
.features .fx-clean path {
  fill: none;
  stroke: var(--mint-500);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.features .features__tile:is(:hover, .is-active) .fx-clean {
  opacity: 1;
  transform: scale(1);
  transition-delay: var(--dur-fast);
}

/* ---------- 3 · Captions ---------- */
.features .fx-line {
  fill: var(--ink-300);
  transform-origin: 30px var(--oy);
}
.features .features__tile:is(:hover, .is-active) .fx-line { transform: scaleX(var(--sx, 1)); }

.features .fx-tag {
  fill: var(--violet-100);
  stroke: var(--violet-400);
  stroke-width: 1;
}
.features .fx-tag--new { opacity: 0; transform: translateY(4px); }
.features .features__tile:is(:hover, .is-active) .fx-tag--new {
  opacity: 1;
  transform: none;
  transition-delay: var(--dur);
}

.features__meter {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.features__meter-track {
  flex: 1;
  height: var(--s-2);
  border-radius: var(--r-pill);
  background: var(--ink-200);
  overflow: hidden;
}
/* Rest: 268 chars against a 150-char destination limit — over, in coral.
   Active: rewritten to 138, inside the limit, in brand violet. */
.features__meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transform: scaleX(1);
  transform-origin: left center;
  transition:
    transform var(--dur-slow) var(--ease-expo),
    background-color var(--dur-slow) var(--ease-out);
}
.features .features__tile:is(:hover, .is-active) .features__meter-fill {
  background: var(--accent);
  transform: scaleX(0.92);
}
.features__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- 4 · Smart queue ---------- */
.features__week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--s-2);
  align-items: center;
}
.features__day {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: clip;
}
.features__slot {
  aspect-ratio: 2 / 1;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition:
    transform var(--dur-slow) var(--ease-expo),
    opacity var(--dur-slow) var(--ease-out);
  transition-delay: var(--d, 0ms);
}
/* Already booked reads as a pale wash; only what Ripple just placed is
   fully saturated, so the end state still tells the story. */
.features__slot.is-booked {
  background: color-mix(in srgb, var(--accent) 30%, var(--surface-2));
  box-shadow: none;
}
.features__slot.is-new {
  background: var(--accent);
  box-shadow: none;
  opacity: 0;
  transform: scale(0.72);
}
.features .features__tile:is(:hover, .is-active) .features__slot.is-new {
  opacity: 1;
  transform: none;
}

/* ---------- 5 · Cold backup ---------- */
.features .fx-frameplate {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1;
}
.features .fx-play { fill: var(--accent); }
.features .fx-stack > g {
  transform-origin: 55px 54px;
  transition:
    transform var(--dur-slow) var(--ease-expo),
    opacity var(--dur-slow) var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.features .features__tile:is(:hover, .is-active) .fx-stack > g {
  transform: translate(26px, -4px) scale(0.9);
  opacity: 0.3;
}

.features .fx-trail circle {
  fill: var(--ink-300);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-expo);
  transition-delay: var(--d, 0ms);
  transform: scale(0.6);
  transform-origin: center;
  transform-box: fill-box;
  opacity: 0.35;
}
.features .features__tile:is(:hover, .is-active) .fx-trail circle {
  opacity: 1;
  transform: none;
  fill: var(--accent);
}

.features .fx-vault-body { fill: var(--ink-800); }
.features .fx-vault-inner {
  fill: none;
  stroke: var(--ink-600);
  stroke-width: 1.5;
}
.features .fx-dial-ring {
  fill: var(--ink-900);
  stroke: var(--ink-400);
  stroke-width: 2;
}
.features .fx-dial-spoke {
  fill: none;
  stroke: var(--ink-400);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.features .fx-dial { transform-origin: 288px 60px; }
.features .features__tile:is(:hover, .is-active) .fx-dial { transform: rotate(45deg); }
.features .fx-vault-slot { fill: var(--ink-500); }

.features .fx-sealed {
  opacity: 0;
  transform: scale(0.6);
  transform-origin: 334px 100px;
}
.features .fx-sealed circle { fill: var(--mint-500); }
.features .fx-sealed path {
  fill: none;
  stroke: var(--surface);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.features .features__tile:is(:hover, .is-active) .fx-sealed {
  opacity: 1;
  transform: scale(1);
  transition-delay: var(--dur);
}

/* ---------- 6 · Delivery receipts ---------- */
/* The retry spinner has to complete its loop before the row resolves,
   so every swap in this tile waits one full rotation. */
.features__receipts {
  --swap-hold: var(--dur-slow);
  display: grid;
  gap: var(--s-4);
}
.features__receipt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-4);
}
.features__rstate {
  display: grid;
  width: var(--s-6);
  height: var(--s-6);
}
.features__rstate > svg { grid-area: 1 / 1; width: 100%; height: 100%; }

.features .features__tick circle { fill: var(--mint-100); }
.features .features__tick path {
  fill: none;
  stroke: var(--mint-500);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.features .features__spin-bg { fill: var(--amber-100); }
.features .features__spin-arc {
  fill: none;
  stroke: var(--amber-500);
  stroke-width: 2.2;
  stroke-linecap: round;
}
.features .features__spin-head { fill: var(--amber-500); }
/* Own transition so the rotation is not cut short by the swap fade. */
.features .features__spin {
  transform-origin: center;
  transition: transform var(--dur-slow) var(--ease-in-out), opacity var(--dur-fast) var(--ease-out);
  transition-delay: var(--dur-fast);
}
.features .features__tile:is(:hover, .is-active) .features__spin {
  transform: rotate(300deg);
  transition-delay: 0ms, var(--swap-hold);
}

.features__rlines {
  display: grid;
  gap: var(--s-2);
}
.features__rlines i {
  display: block;
  width: var(--w, 100%);
  height: var(--s-2);
  border-radius: var(--r-pill);
  background: var(--ink-300);
}
.features__rlines i.is-dim {
  height: calc(var(--s-2) * 0.75);
  background: var(--ink-200);
}

/* Composes .chip: one status-pill recipe, fill and text colour per state.
   min-width only so the three rows share one right edge. */
.features__rpill {
  min-width: var(--s-16);
  justify-content: center;
}
.features__rpill--ok {
  background: var(--mint-100);
  color: var(--ink-900);
  color: color-mix(in srgb, var(--mint-500) 52%, var(--ink-900));
}
.features__rpill--wait {
  background: var(--amber-100);
  color: var(--ink-900);
  color: color-mix(in srgb, var(--amber-500) 52%, var(--ink-900));
}

/* ---------- Reduced motion: kill the stagger too ---------- */
@media (prefers-reduced-motion: reduce) {
  .features *,
  .features *::before {
    transition-delay: 0ms !important;
    animation-delay: 0ms !important;
  }
}
