/* Closing: arrivals. One tinted panel, the owner's baggage-carousel mascot, one headline,
   a tiny try-it (pick a bag tag, read the boarding-pass stub) and the launch email button.
   The choice is driven by :has(), so it works without scripts. */
.s-closing {
  --panel-pad: 24px;
  --scene-size: 180px;
  --icon-size: 24px;
  --chip-ring: 2px;
  --tag-hole: 8px;
  --stub-width: 76px;
  --notch: 16px;
  --tear: #c5d2ff;
  --val-height: 32px;
  --macro-dot: 28px;
  --rise: 8px;
  --swap-out: 0.12s;
  --scene-delay: 0.12s;
  padding-block: calc(var(--section-gap) / 2);
}

.s-closing .closing-inner {
  display: grid;
  justify-items: center;
  gap: var(--space-lg);
  padding: var(--panel-pad) var(--space-xl);
  background: var(--jet-tint);
  border-radius: var(--radius-card-large);
  text-align: center;
}

.s-closing .closing-copy {
  display: grid;
  justify-items: center;
  gap: var(--space-xl);
  width: 100%;
  min-width: 0;
}

/* The mascot leads on narrow screens and sits beside the copy on wide ones. */
.s-closing .closing-scene {
  order: -1;
  width: var(--scene-size);
  height: auto;
  max-width: 100%;
}

.s-closing .display {
  color: var(--jet-ink);
}

.s-closing .moments {
  display: grid;
  justify-items: center;
  gap: var(--space-md);
  width: 100%;
  max-width: 420px;
}

.s-closing .moment-set {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.s-closing .moment-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.s-closing .moment {
  position: relative;
  display: grid;
}

.s-closing .moment-icon {
  flex: none;
  width: var(--icon-size);
  height: var(--icon-size);
}

/* Each choice is a bag tag: a white pill with a punched hole. */
.s-closing .moment-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 48px;
  padding-inline: var(--space-md);
  background: var(--surface);
  color: var(--jet-ink);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: var(--radius-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--duration-snappy) var(--ease-snappy);
}

.s-closing .moment-chip::after {
  content: "";
  order: -1;
  flex: none;
  width: var(--tag-hole);
  height: var(--tag-hole);
  background: var(--jet-tint);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--tear);
}

/* The chosen tag gets a brand-blue ring. */
.s-closing .moment-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--chip-ring) var(--jet);
  opacity: 0;
  transition: opacity var(--duration-snappy) var(--ease-snappy);
}

.s-closing .moment-input:checked + .moment-chip::before {
  opacity: 1;
}

.s-closing .moment-chip:active {
  transform: scale(0.97);
}

.s-closing .moment-input:focus-visible + .moment-chip {
  outline: 2px solid var(--jet);
  outline-offset: 3px;
}

/* The result: a boarding-pass stub. The outcome on the left, a dashed tear line with
   two notches, and the Example marker on the stub. */
.s-closing .moment-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--stub-width);
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  text-align: left;
}

.s-closing .moment-stage::before,
.s-closing .moment-stage::after {
  content: "";
  position: absolute;
  right: calc(var(--stub-width) - var(--notch) / 2 - 1px);
  width: var(--notch);
  height: var(--notch);
  background: var(--jet-tint);
  border-radius: 50%;
}

.s-closing .moment-stage::before { top: calc(var(--notch) / -2); }
.s-closing .moment-stage::after { bottom: calc(var(--notch) / -2); }

.s-closing .moment-main {
  display: grid;
  gap: var(--space-md);
  align-items: center;
  min-width: 0;
  padding: 14px var(--space-lg);
}

.s-closing .moment-stub {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--space-xs);
  border-left: 2px dashed var(--tear);
}

.s-closing .moment-stub-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  background: url("/assets/icons/icon-boarding-pass.svg") center / contain no-repeat;
}

.s-closing .moment-stub-text {
  color: var(--jet);
  font-size: 10px;
  font-weight: 700;
}

.s-closing .moment-answer {
  display: grid;
  gap: 6px;
  justify-items: start;
  min-width: 0;
  color: var(--jet-ink);
}

.s-closing .moment-label {
  color: var(--ink-secondary);
  font-weight: 700;
}

.s-closing .moment-result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  min-height: var(--val-height);
}

.s-closing .moment-val {
  display: inline-flex;
  align-items: center;
  min-height: var(--val-height);
  padding-inline: 10px;
  background: var(--jet-tint);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: var(--radius-pill);
}

.s-closing .moment-val-new {
  background: var(--jet);
  color: var(--surface);
}

.s-closing .moment-arrow {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--jet);
}

.s-closing .moment-macros {
  gap: 10px;
}

.s-closing .macro {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.s-closing .macro-dot {
  display: grid;
  place-items: center;
  width: var(--macro-dot);
  height: var(--macro-dot);
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
}

.s-closing .macro-protein .macro-dot { background: var(--protein); }
.s-closing .macro-carbs .macro-dot { background: var(--carbs); }
.s-closing .macro-fat .macro-dot { background: var(--fat); }

.s-closing .macro-move {
  flex: none;
  width: 14px;
  height: 14px;
}

.s-closing .moment-bubble {
  display: inline-flex;
  align-items: center;
  min-height: var(--val-height);
  padding: var(--space-xs) var(--space-md);
  background: var(--jet-tint);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--radius-control) var(--radius-control) var(--radius-control) var(--space-xs);
}

/* One answer at a time. All four share one spot, so the panel never changes height.
   The outgoing answer fades first; the incoming one then rises and its new value pops. */
@supports selector(:has(*)) {
  .s-closing .moment-answer {
    grid-area: 1 / 1;
    opacity: 0;
    visibility: hidden;
    transform: translateY(var(--rise));
    transition:
      opacity var(--swap-out) linear,
      visibility 0s linear var(--swap-out),
      transform 0s linear var(--swap-out);
  }

  .s-closing .moment-val-new,
  .s-closing .macro-move,
  .s-closing .moment-bubble {
    transform: scale(0.7);
    transition: transform 0s linear var(--swap-out);
  }

  .s-closing .moment-bubble {
    transform-origin: 0 100%;
  }

  .s-closing:has(#moment-sleep:checked) [data-moment="sleep"],
  .s-closing:has(#moment-sets:checked) [data-moment="sets"],
  .s-closing:has(#moment-weight:checked) [data-moment="weight"],
  .s-closing:has(#moment-why:checked) [data-moment="why"] {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition:
      opacity var(--duration-snappy) var(--ease-snappy) var(--swap-out),
      visibility 0s,
      transform var(--duration-standard) var(--ease-standard) var(--swap-out);
  }

  .s-closing:has(#moment-sleep:checked) [data-moment="sleep"] .moment-val-new,
  .s-closing:has(#moment-sets:checked) [data-moment="sets"] .moment-val-new,
  .s-closing:has(#moment-weight:checked) [data-moment="weight"] .macro-move,
  .s-closing:has(#moment-why:checked) [data-moment="why"] .moment-bubble {
    transform: none;
    transition: transform var(--duration-standard) var(--ease-snappy) calc(var(--swap-out) + 0.12s);
  }
}

/* The one action is the blue button. "Coming soon" is a quiet line, not a button. */
.s-closing .cta {
  display: grid;
  justify-items: center;
  gap: var(--space-sm);
  width: 100%;
}

.s-closing .notify {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--button-height);
  padding-inline: var(--space-xxxl);
  background: var(--jet);
  color: var(--surface);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: transform var(--duration-snappy) var(--ease-snappy);
}

.s-closing .notify:active {
  transform: scale(0.97);
}

.s-closing .notify:focus-visible {
  outline: 2px solid var(--jet-ink);
  outline-offset: 3px;
}

.s-closing .cta-arrow {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform var(--duration-rest) var(--ease-standard);
}

.s-closing .soon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  color: var(--jet-ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.s-closing .soon-icon {
  flex: none;
  width: 20px;
  height: 20px;
  background: url("/assets/icons/icon-takeoff.svg") center / contain no-repeat;
}

@media (hover: hover) {
  .s-closing .notify:hover {
    transform: translateY(-2px);
  }

  .s-closing .notify:hover .cta-arrow {
    transform: translateX(3px);
  }

  .s-closing .moment-input:not(:checked) + .moment-chip:hover::before {
    opacity: 0.35;
  }
}

/* The mascot settles into place just after the panel arrives. */
@media (prefers-reduced-motion: no-preference) {
  .js .s-closing .closing-scene {
    opacity: 0;
    transform: translateY(var(--rise)) scale(0.94);
    transition:
      opacity var(--duration-gentle) var(--ease-gentle) var(--scene-delay),
      transform var(--duration-gentle) var(--ease-gentle) var(--scene-delay);
  }

  .js .s-closing .is-visible .closing-scene {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .s-closing *,
  .s-closing *::before {
    transition: none !important;
  }

  .s-closing .moment-chip:active,
  .s-closing .notify:active,
  .s-closing .notify:hover {
    transform: none;
  }
}

@media print {
  .js .s-closing .closing-scene {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 419px) {
  .s-closing .notify {
    width: 100%;
    padding-inline: var(--space-lg);
  }
}

@media (max-width: 359px) {
  .s-closing {
    --scene-size: 164px;
    --icon-size: 20px;
    --stub-width: 66px;
    --macro-dot: 24px;
  }

  .s-closing .closing-inner {
    padding-inline: var(--space-lg);
  }

  .s-closing .moment-chip {
    gap: 6px;
    padding-inline: var(--space-sm);
    font-size: 14px;
  }

  .s-closing .moment-chip::after {
    display: none;
  }

  .s-closing .moment-main {
    padding-inline: var(--space-md);
  }

  .s-closing .moment-result {
    gap: 6px;
  }

  .s-closing .moment-val {
    padding-inline: var(--space-sm);
    font-size: 14px;
  }

  .s-closing .moment-bubble {
    padding-inline: 10px;
    font-size: 14px;
  }

  .s-closing .moment-stub-text {
    font-size: 9px;
  }

  .s-closing .soon {
    font-size: 12px;
  }
}

@media (min-width: 640px) {
  .s-closing {
    --panel-pad: 40px;
    --scene-size: 260px;
    --stub-width: 96px;
  }

  .s-closing .closing-copy {
    gap: var(--space-xxl);
  }

  .s-closing .moments {
    max-width: 520px;
  }

  /* Four tags in one row, stretched so they share both edges with the stub below. */
  .s-closing .moment-row {
    grid-template-columns: repeat(4, auto);
  }

  .s-closing .moment-main {
    padding-inline: var(--space-xl);
  }
}

/* Wide: the copy on the left, the mascot on the right. The tags stay two by two
   until the copy column is wide enough for all four in a row. */
@media (min-width: 960px) {
  .s-closing {
    --panel-pad: 48px;
    --scene-size: 320px;
  }

  .s-closing .closing-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--space-section);
    padding-inline: var(--panel-pad);
    /* The full-width stage radius the feature sections use on wide screens. */
    border-radius: 40px;
    text-align: left;
  }

  .s-closing .closing-copy,
  .s-closing .moments,
  .s-closing .cta {
    justify-items: start;
  }

  .s-closing .closing-scene {
    order: 0;
  }

  .s-closing .moments {
    max-width: 420px;
  }

  .s-closing .moment-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* The button and the coming-soon line share one row when there is room. */
  .s-closing .cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: var(--space-xl);
    row-gap: var(--space-sm);
  }
}

@media (min-width: 1120px) {
  .s-closing {
    --scene-size: 380px;
  }

  .s-closing .closing-copy {
    gap: var(--space-xxxl);
  }

  .s-closing .moments {
    max-width: 520px;
  }

  .s-closing .moment-row {
    grid-template-columns: repeat(4, auto);
  }
}
