/* ═══════════════════════════════════════════════════════════════
   HangarAI buy: the page's own layout

   One view at a time (buy.js): the list of products, the way to the
   checkout, the thanks, a pack without a license, an error. The
   inline script in <head> sets data-buy when the address names a
   product, so the page opens on the view it is about to show.
   ═══════════════════════════════════════════════════════════════ */

.buy {
  display: grid;
  justify-items: center;
  gap: 24px;
  min-height: calc(100vh - var(--bar-h) - 180px);
  padding-block: clamp(40px, 7vw, 96px) clamp(64px, 8vw, 112px);
}

.buy .mock {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--state-waiting) 40%, var(--border));
  border-radius: var(--r-lg);
}

html[data-buy] #v-choose {
  display: none;
}

html[data-buy="going"] #v-going,
html[data-buy="done"] #v-done {
  display: grid;
}

.buy__view {
  width: 100%;
}

.buy__view--choose {
  max-width: 640px;
  text-align: center;
}

.buy__view--choose .eyebrow {
  justify-content: center;
}

.buy__card {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(480px, 100%);
  padding: clamp(28px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--chrome);
  box-shadow: 0 30px 80px -50px var(--shadow);
  text-align: center;
}

.buy__card[hidden],
.buy__view[hidden] {
  display: none;
}

.buy__title {
  font-size: clamp(26px, 3.4vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.buy__title:focus {
  outline: none;
}

.buy__what {
  color: var(--fg-hi);
  font-size: 15.5px;
  font-weight: 560;
}

.buy__what:empty {
  display: none;
}

.buy__text {
  color: var(--fg-secondary);
  font-size: 15.5px;
}

.buy__fine {
  margin-top: 4px;
  color: var(--fg-muted);
  font-size: 13.5px;
}

.buy__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.buy__url code {
  display: inline-block;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: var(--r);
  background: var(--bg-sunken);
  font-size: 12.5px;
}

.buy__spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
}

/* the marks over a card: a tick for thanks, a ring for an error */
.buy__check,
.buy__warn {
  position: relative;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
}

.buy__check {
  background: color-mix(in srgb, var(--state-working) 16%, transparent);
}

.buy__check::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 18px;
  width: 10px;
  height: 18px;
  border: solid var(--state-working);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.buy__warn {
  background: color-mix(in srgb, var(--state-waiting) 16%, transparent);
}

.buy__warn::before,
.buy__warn::after {
  content: "";
  position: absolute;
  left: 22.75px;
  width: 2.5px;
  border-radius: 2px;
  background: var(--state-waiting);
}

.buy__warn::before {
  top: 12px;
  height: 15px;
}

.buy__warn::after {
  top: 31px;
  height: 3px;
}

.steps {
  display: grid;
  gap: 10px;
  margin: 6px 0 0;
  padding: 0;
  color: var(--fg-secondary);
  font-size: 15px;
  list-style: none;
  counter-reset: step;
  text-align: left;
}

.steps li {
  position: relative;
  padding-left: 34px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-hi);
  font-size: 12.5px;
  font-weight: 640;
}

/* the list of products */
.choose {
  display: grid;
  gap: 10px;
  margin-top: 28px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.choose__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--chrome);
  color: var(--fg);
  text-decoration: none;
  transition: border-color 140ms var(--ease);
}

.choose__item:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.choose__item--accent {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent), 0 24px 60px -44px var(--accent);
}

.choose__name .period__save {
  margin-left: 6px;
  vertical-align: 1px;
}

.choose__name {
  color: var(--fg-hi);
  font-size: 15.5px;
  font-weight: 600;
}

.choose__price {
  grid-row: span 2;
  align-self: center;
  color: var(--fg-hi);
  font-size: 15.5px;
  font-weight: 620;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.choose__what {
  color: var(--fg-muted);
  font-size: 13.5px;
}

.buy__view--choose .buy__fine {
  margin-top: 24px;
}

@media (prefers-reduced-motion: no-preference) {
  .buy__view.enter {
    animation: buy-rise 480ms var(--ease) both;
  }
}

@keyframes buy-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (max-width: 479px) {
  .choose__item {
    grid-template-columns: minmax(0, 1fr);
  }

  .choose__price {
    grid-row: auto;
  }
}
