/* =============================================================
   ADDON-UPSELL — V29 v0.8 E
   Single-screen pre-completion upsell. Fires when user has
   unchecked all add-ons in the enrollment modal AND chosen plan
   has the gap. Restraint over urgency: no countdowns, no guilt
   trips, easy skip path always visible.
   ============================================================= */

.ag-up-root { position: fixed; inset: 0; z-index: 11000; }
html.ag-up-open { overflow: hidden; }

.ag-up-veil {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 48, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: ag-up-fade 220ms cubic-bezier(.22,.61,.36,1) both;
}
@keyframes ag-up-fade { from { opacity: 0 } to { opacity: 1 } }

.ag-up-card-wrap {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--cream, #FFFFFF);
  border: 2px solid var(--ink, #0E2A3A);
  border-radius: 24px;
  padding: 28px 32px 24px;
  box-shadow: 4px 4px 0 var(--ink, #0E2A3A), 0 32px 64px rgba(20, 30, 48, 0.3);
  animation: ag-up-card-in 320ms cubic-bezier(.22,.61,.36,1) both;
}
@keyframes ag-up-card-in {
  from { opacity: 0; transform: translateY(20px) scale(.96) }
  to   { opacity: 1; transform: translateY(0) scale(1) }
}

/* ── Header ─────────────────────────────────────────────────── */
.ag-up-head {
  margin-bottom: 16px;
}
.ag-up-title {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--ink, #0E2A3A);
  margin: 0 0 10px;
}
.ag-up-lead {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--mute, #4A6678);
  margin: 0;
}

/* ── Bundle pill ────────────────────────────────────────────── */
.ag-up-bundle-pill {
  display: block;
  margin: 0 0 18px;
  padding: 10px 16px;
  background: rgba(255, 200, 87, 0.18);
  border: 1px dashed var(--ink, #0E2A3A);
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  text-align: center;
  color: var(--ink, #0E2A3A);
  transition: background 240ms ease, border-style 240ms ease;
}
.ag-up-bundle-pill strong {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 16px;
}
.ag-up-bundle-pill.is-active {
  background: var(--lemon, #FFC857);
  border-style: solid;
  box-shadow: 2px 2px 0 var(--ink, #0E2A3A);
}

/* ── Grid of 3 addon cards ─────────────────────────────────── */
.ag-up-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.ag-up-card {
  display: block;
  cursor: pointer;
  position: relative;
}
.ag-up-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ag-up-card-inner {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "icon label price"
    "icon sub sub";
  gap: 4px 14px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid var(--rule, #DDE9EE);
  border-radius: 12px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.ag-up-card:hover .ag-up-card-inner {
  border-color: var(--ink, #0E2A3A);
}
.ag-up-card input:focus-visible + .ag-up-card-inner {
  outline: 2px solid var(--lemon, #FFC857);
  outline-offset: 2px;
}
.ag-up-card input:checked + .ag-up-card-inner {
  background: rgba(255, 200, 87, 0.12);
  border-color: var(--ink, #0E2A3A);
  box-shadow: 2px 2px 0 var(--ink, #0E2A3A);
}
.ag-up-icon {
  grid-area: icon;
  font-size: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream, #FFFFFF);
  border: 1.5px solid var(--ink, #0E2A3A);
  border-radius: 50%;
}
.ag-up-label {
  grid-area: label;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  font-size: 15.5px;
  color: var(--ink, #0E2A3A);
  align-self: end;
}
.ag-up-sub {
  grid-area: sub;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--mute, #4A6678);
  align-self: start;
}
.ag-up-price {
  grid-area: price;
  align-self: center;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 19px;
  color: var(--ink, #0E2A3A);
  font-variant-numeric: tabular-nums;
}
.ag-up-price small {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--mute, #4A6678);
  margin-left: 1px;
}

/* ── Trust line ─────────────────────────────────────────────── */
.ag-up-trust {
  margin: 0 0 16px;
  text-align: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12.5px;
  color: var(--mute, #4A6678);
}

/* ── Actions ────────────────────────────────────────────────── */
.ag-up-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.ag-up-btn {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}
.ag-up-btn--primary {
  background: var(--lemon, #FFC857);
  color: var(--ink, #0E2A3A);
  border: 1.5px solid var(--ink, #0E2A3A);
  box-shadow: 3px 3px 0 var(--ink, #0E2A3A);
}
.ag-up-btn--primary:hover:not(.is-disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink, #0E2A3A);
}
.ag-up-btn--primary:active:not(.is-disabled) {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink, #0E2A3A);
}
.ag-up-btn--primary.is-disabled,
.ag-up-btn--primary[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.ag-up-btn--primary [data-ag-up-total] {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.ag-up-btn--ghost {
  background: transparent;
  color: var(--mute, #4A6678);
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
}
.ag-up-btn--ghost:hover {
  color: var(--ink, #0E2A3A);
}

/* ── Footer / social proof ─────────────────────────────────── */
.ag-up-foot {
  text-align: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .03em;
  color: var(--mute, #4A6678);
  margin: 0;
  line-height: 1.5;
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ag-up-veil { padding: 0; }
  .ag-up-card-wrap {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    border-width: 0;
    box-shadow: none;
    padding: 24px 22px 20px;
  }
  .ag-up-title { font-size: 24px; }
}

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ag-up-veil, .ag-up-card-wrap { animation: none; }
  .ag-up-veil { backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
}

/* ── Forced colors ─────────────────────────────────────────── */
@media (forced-colors: active) {
  .ag-up-card-wrap, .ag-up-card-inner { border-color: CanvasText !important; }
}

/* =============================================================
   V31 Task 3.3 — Inline takeover mode (desktop ≥768)
   When AddonUpsell.show is invoked with mountMode='inline', the
   upsell root mounts inside .nx-main-host--enroll (NOT body) and
   --inline modifier classes drop fixed positioning + veil so the
   upsell lives inside the main column alongside the chat sidebar.
   ============================================================= */
@media (min-width: 768px) {
  /* Root wrapper of an inline-mounted upsell — no fixed positioning. */
  .ag-up-root[data-ag-up-mount="inline"],
  .ag-up-root--inline {
    position: relative;
    inset: auto;
    z-index: auto;
    width: 100%;
    height: auto;
  }
  /* Hide the veil entirely in inline mode — no backdrop dimming. */
  .ag-up-root[data-ag-up-mount="inline"] .ag-up-veil,
  .ag-up-root--inline .ag-up-veil {
    position: relative;
    inset: auto;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 24px;
    animation: none;
  }
  /* The inner card retains its visual identity but drops the modal
     chrome (shadow/border) and caps width so it reads comfortably
     inside the main pane. */
  .ag-up-modal--inline,
  .ag-up-root--inline .ag-up-card-wrap {
    position: relative;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 24px;
    inset: auto;
    max-height: none;
    overflow: visible;
  }
}

/* Mobile (<768) — inline mode shouldn't typically activate here, but if a
   caller forces it, fall back gracefully to overlay layout so the upsell
   remains usable on small viewports. */
@media (max-width: 767px) {
  .ag-up-root[data-ag-up-mount="inline"],
  .ag-up-root--inline {
    position: fixed;
    inset: 0;
  }
  .ag-up-root[data-ag-up-mount="inline"] .ag-up-veil,
  .ag-up-root--inline .ag-up-veil {
    position: fixed;
    inset: 0;
  }
}
