/* Purchase page — /purchase-team
 *
 * Layers on top of teams-home.css and reuses its tokens, `.button`, `.eyebrow`
 * and `.price-lockup` so the checkout looks like the page that sold it rather
 * than a generic payment form. Nothing here redefines a colour; every value is
 * a var() from the Teams palette.
 */

.purchase-body {
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */

.purchase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1.1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}

.purchase-back,
.purchase-terms-link {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  transition: color 180ms ease;
}

.purchase-back:hover,
.purchase-terms-link:hover {
  color: var(--brown);
}

.purchase-terms-link {
  color: var(--ink-soft);
  font-weight: 500;
}

.purchase-header-right {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

/* ---- Account chip ----
 *
 * The header's right-hand side is the answer to "am I about to pay from the
 * right account?", so it is deliberately the only interactive thing up here
 * besides Terms. It is a `position: relative` anchor for the menu beneath it.
 */

.account-chip {
  position: relative;
}

.account-chip-button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.34rem 0.7rem 0.34rem 0.34rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.account-chip-button:hover {
  border-color: var(--brown);
}

.account-chip-button:active {
  transform: scale(0.97);
}

.account-chip-button:focus-visible {
  outline: 2px solid var(--brown);
  outline-offset: 2px;
}

.account-avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--espresso);
  color: var(--cream);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.account-avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 1.05rem;
}

.account-chip-name {
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  width: 10px;
  height: 7px;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

/* ---- Account menu ---- */

.account-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 20;
  width: min(19rem, calc(100vw - 2rem));
  padding: 1rem 1.1rem 1.1rem;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 44px rgba(32, 23, 17, 0.16);
  text-align: left;
}

.account-menu[hidden] {
  display: none;
}

.account-menu-label {
  margin: 0 0 0.3rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.account-menu-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

.account-menu-email {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.account-menu-note {
  margin: 0.8rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.account-menu-action {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.account-menu-action:hover {
  border-color: var(--brown);
  color: var(--brown);
}

.account-menu-action:active {
  transform: scale(0.98);
}

.account-signin-link {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown);
  text-decoration: none;
}

.account-signin-link:hover {
  text-decoration: underline;
}

/* The chip and the "Sign in" link are two views of the same slot — exactly one
   of them is ever shown, decided by the page's auth state. */
body:not([data-auth-state="signed-in"]) .account-chip,
body[data-auth-state="signed-in"] .account-signin-link,
body[data-auth-state="checking"] .account-signin-link {
  display: none;
}

/* ---- Layout ---- */

.purchase-shell {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.1rem, 4vw, 3rem);
}

.purchase-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: start;
}

@media (min-width: 900px) {
  .purchase-grid {
    grid-template-columns: 1fr 0.9fr;
  }

  /* The form outranks the pitch on a wide screen — it's why they're here. */
  .purchase-panel {
    position: sticky;
    top: 2rem;
  }
}

/* ---- Left column ---- */

.purchase-summary h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.85rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0.6rem 0 0.9rem;
}

.purchase-lead {
  max-width: 44ch;
  color: var(--ink-soft);
  margin: 0 0 2rem;
}

/* ---- "What you're setting up" ---- */

.purchase-steps {
  list-style: none;
  margin: 0 0 2.4rem;
  padding: 0;
  max-width: 460px;
  display: grid;
  gap: 1.4rem;
}

.purchase-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.95rem;
}

.step-num {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--espresso);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 0.1rem;
}

.purchase-steps h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
}

.purchase-steps p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--ink-soft);
}

/* ---- Owner dashboard preview ---- */

.purchase-preview {
  margin: 0 0 2.4rem;
  max-width: 460px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.6rem 1.5rem 1.4rem;
  text-align: center;
}

.purchase-preview img {
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 0 auto 1.2rem;
  /* The source PNG already carries a device frame, so no extra chrome —
     just enough shadow to lift it off the recessed panel. */
  filter: drop-shadow(0 16px 30px rgba(32, 23, 17, 0.22));
}

.purchase-preview figcaption {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
  text-align: left;
}

.purchase-preview figcaption strong {
  display: block;
  font-family: var(--font-display);
  color: var(--ink);
  margin-bottom: 0.25rem;
}

/* ---- Trial reassurance above the form ---- */

.purchase-trial-flag {
  background: var(--paper-deep);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 1.3rem;
}

.purchase-trial-flag strong {
  color: var(--ink);
}

/* ---- Price lockup on a light page ----
 *
 * `.eyebrow` and `.price-lockup` were written for the dark pricing section on
 * the marketing page, so their text and rules are white. On this cream page
 * that reads as invisible. Repaint them in the ink palette, and drop the
 * left rule + indent that only made sense inside the two-column pricing grid.
 */

.purchase-summary .eyebrow {
  color: var(--brown);
}

.purchase-lockup {
  max-width: 460px;
  padding: 0;
  border-left: 0;
  border-top: 0;
}

.purchase-lockup .plan-name {
  color: var(--brown);
}

.purchase-lockup .price {
  color: var(--ink);
}

.purchase-lockup .price small {
  color: var(--ink-soft);
}

.purchase-lockup .price-rule {
  background: var(--line);
}

.purchase-lockup li {
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.purchase-lockup .price-fineprint {
  color: var(--ink-soft);
}

.purchase-facts {
  display: grid;
  gap: 0.9rem;
  margin: 2rem 0 0;
  max-width: 460px;
}

.purchase-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.purchase-facts > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.purchase-facts dt {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
}

.purchase-facts dd {
  margin: 0;
  color: var(--ink-soft);
  text-align: right;
}

/* ---- Right column ---- */

.purchase-card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(1.4rem, 3vw, 2rem);
  box-shadow: 0 18px 46px rgba(32, 23, 17, 0.07);
}

.purchase-card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}

.purchase-card-lead {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.6rem;
}

.demo-flag {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-size: 0.87rem;
  color: var(--ink-soft);
  margin: 0 0 1.4rem;
}

.demo-flag strong {
  color: var(--ink);
}

/* ---- Panel states ----
 *
 * All three states ship in the HTML and the body's data-auth-state picks one.
 * Doing it in CSS rather than JS means the card never renders the wrong state
 * for a frame while the module boots, and "checking" is the default so nobody
 * is asked to sign in before Firebase has looked.
 */

.purchase-state {
  display: none;
}

body[data-auth-state="checking"] [data-panel="checking"],
body[data-auth-state="signed-out"] [data-panel="signed-out"],
body[data-auth-state="signed-in"] [data-panel="signed-in"] {
  display: block;
}

.purchase-spinner {
  width: 26px;
  height: 26px;
  margin: 0.6rem auto 1rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  border-top-color: var(--brown);
  animation: purchase-spin 780ms linear infinite;
}

@keyframes purchase-spin {
  to { transform: rotate(360deg); }
}

.purchase-checking-copy {
  margin: 0;
  text-align: center;
  font-size: 0.93rem;
  color: var(--ink-soft);
}

.purchase-signin-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}

.purchase-signin-help {
  margin-top: 1rem;
}

/* ---- "Buying as" ----
 *
 * The header chip is easy to miss on a phone, where it sits a scroll away from
 * the button that charges the card. This repeats the same identity right where
 * the money decision is made, with the same escape hatch.
 */

.buying-as {
  background: var(--paper-deep);
  border-radius: 14px;
  padding: 0.95rem 1rem 0.85rem;
  margin: 0 0 1.5rem;
}

.buying-as-label {
  margin: 0 0 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.buying-as-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.buying-as-identity {
  min-width: 0;
}

.buying-as-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buying-as-email {
  margin: 0.1rem 0 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buying-as-switch {
  margin-top: 0.8rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brown);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.buying-as-switch:hover {
  color: var(--ink);
}

/* ---- Form ---- */

.purchase-form .field {
  margin-bottom: 1.1rem;
}

.purchase-form label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.purchase-form input {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.purchase-form input:focus {
  outline: none;
  border-color: var(--brown);
  box-shadow: 0 0 0 3px rgba(139, 75, 45, 0.14);
}

.purchase-form input[aria-invalid="true"] {
  border-color: #a8322a;
}

.field-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0.4rem 0 0;
}

.field-error {
  font-size: 0.82rem;
  color: #a8322a;
  margin: 0.4rem 0 0;
}

/* Honeypot — off-screen, never shown, never announced. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.purchase-submit {
  width: 100%;
  margin-top: 0.6rem;
}

.purchase-submit[disabled] {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.purchase-status {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.purchase-status[data-tone="error"] {
  color: #a8322a;
}

.purchase-legal {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 1.2rem 0 0;
}

.purchase-legal a {
  color: var(--brown);
}

.purchase-help {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 1.3rem 0 0;
}

.purchase-help a {
  color: var(--brown);
  font-weight: 600;
}

/* ---- Footer ---- */

.purchase-footer {
  border-top: 1px solid var(--line);
  padding: 1.6rem clamp(1.1rem, 4vw, 3rem);
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.purchase-footer p {
  margin: 0;
}

/* ---- Success page ---- */

.purchase-success {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

/* ---- Success page gate ----
 *
 * Every block on /purchase-success is hidden until the page has confirmed the
 * payment with Stripe and set data-purchase-state. `display: none` rather than
 * an opacity trick on purpose: the congratulation must not be in the layout,
 * screen-reader tree, or a screenshot of a page nobody paid for.
 *
 * The default below covers the state attribute being missing entirely — a
 * broken script leaves a spinner, which is the safe direction to fail in. */
.purchase-gate {
  display: none;
}

.purchase-body[data-purchase-state="unreachable"] [data-gate="unreachable"],
.purchase-body[data-purchase-state="confirmed"] [data-gate="confirmed"] {
  display: block;
}

.purchase-body[data-purchase-state="checking"] [data-gate="checking"] {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 3rem 0;
}

.purchase-business {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.8rem;
}

.purchase-success .success-mark {
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background: var(--espresso);
  color: var(--cream);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  margin: 0 auto 1.4rem;
}

.purchase-success h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.8rem;
}

.purchase-success p {
  color: var(--ink-soft);
  margin: 0 0 1.4rem;
}

.purchase-next {
  text-align: left;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.3rem 1.5rem;
  margin: 2rem 0;
}

.purchase-next h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.7rem;
}

.purchase-next ol {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-soft);
}

.purchase-next li {
  margin-bottom: 0.5rem;
}

.purchase-success-actions {
  display: grid;
  gap: 0.9rem;
  justify-items: center;
  margin: 0 0 1.4rem;
}

.button-quiet {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown);
  text-decoration: none;
}

.button-quiet:hover {
  text-decoration: underline;
}

/* Desktop: the deep link is stated, not offered. */
.button-inert {
  pointer-events: none;
  opacity: 0.55;
}

/* ---- Toast ----
 *
 * For the things that happen off this page and are only reported back through
 * the URL: a cancelled Stripe checkout, a payment we couldn't confirm. The
 * inline status line under the button can't carry those — it's attached to the
 * form, and this news arrives before anyone has touched the form.
 *
 * Flat colours, no gradient, matching the rest of the site. */
.purchase-toast {
  position: fixed;
  left: 50%;
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  width: min(30rem, calc(100vw - 2rem));
  padding: 0.95rem 1rem 0.95rem 1.15rem;
  border-radius: 14px;
  background: var(--espresso);
  color: var(--cream);
  box-shadow: 0 12px 32px rgba(28, 25, 23, 0.24);
  font-size: 0.92rem;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

.purchase-toast[data-open="true"] {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s;
}

/* The stripe down the left is the only thing that changes by tone — the panel
   itself stays dark, so a cancelled checkout doesn't shout in red. */
.purchase-toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55rem;
  bottom: 0.55rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--cream);
  opacity: 0.5;
}

.purchase-toast[data-tone="error"]::before {
  background: #e0705f;
  opacity: 1;
}

.purchase-toast-text {
  margin: 0;
  flex: 1;
}

.purchase-toast-close {
  flex-shrink: 0;
  background: none;
  border: 0;
  color: inherit;
  opacity: 0.7;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.15rem 0.2rem;
  cursor: pointer;
  border-radius: 6px;
}

.purchase-toast-close:hover {
  opacity: 1;
}

.purchase-toast-close:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .purchase-back,
  .purchase-terms-link,
  .purchase-form input,
  .account-chip-button,
  .account-menu-action,
  .button {
    transition: none;
  }

  .account-chip-button:active,
  .account-menu-action:active {
    transform: none;
  }

  /* Still reads as "working" without the rotation. */
  .purchase-spinner {
    animation: none;
    border-top-color: var(--line);
    opacity: 0.6;
  }

  /* Appears rather than slides. It still needs to appear — this is the only
     place a cancelled or unconfirmed payment is explained. */
  .purchase-toast,
  .purchase-toast[data-open="true"] {
    transform: translate(-50%, 0);
    transition: opacity 0.01s linear;
  }
}
