/* =============================================================
   ENROLLMENT-MODAL — V29 v0.6.1 Fix #6
   Lemon-themed inline modal styles. No external deps; matches
   the rest of the V27.1 component palette via lemon.css tokens.
   ============================================================= */

html.em-open, html.em-open body { overflow: hidden; }

.em-root { position: fixed; inset: 0; z-index: 2200; }

/* DAV-170 — Phase 6: BundledCard host inside enrollment modal */
.em-bundled-card-host { margin: 0 0 16px; }
.em-bundled-card-host:empty { display: none; }

.em-veil {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 24, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: em-fadein .14s ease-out;
}

@keyframes em-fadein { from { opacity: 0; } to { opacity: 1; } }

.em-modal {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--lemon-paper, #fdf8e8);
  color: var(--lemon-ink, #1a1a1a);
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0,0,0,.32), 0 4px 12px rgba(0,0,0,.18);
  padding: 32px 32px 24px;
  font-family: var(--lemon-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  animation: em-pop .18s cubic-bezier(.22,.61,.36,1);
}

@keyframes em-pop {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.em-close {
  position: absolute;
  top: 12px; right: 14px;
  background: transparent;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--lemon-ink, #1a1a1a);
  cursor: pointer;
}
.em-close:hover { background: rgba(0,0,0,.06); }

.em-title {
  font-family: var(--lemon-serif, "Fraunces", Georgia, serif);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.em-sub {
  font-size: 14px;
  line-height: 1.45;
  color: var(--lemon-mute, #4a4a4a);
  margin: 0 0 20px;
}

.em-form { display: flex; flex-direction: column; gap: 14px; }

.em-row { display: flex; flex-direction: column; gap: 4px; }
.em-row--triple { display: grid; grid-template-columns: 1.4fr .8fr .8fr; gap: 10px; }
.em-cell { display: flex; flex-direction: column; gap: 4px; }
.em-cell--wide { grid-column: span 1; }

.em-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--lemon-mute, #4a4a4a);
  font-weight: 600;
}

.em-form input,
.em-form select {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,.16);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.em-form input:focus,
.em-form select:focus {
  outline: none;
  border-color: var(--lemon-yellow, #f5c518);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.25);
}

.em-form input:invalid:not(:placeholder-shown) {
  border-color: #d23a3a;
}

.em-error {
  min-height: 18px;
  font-size: 13px;
  color: #b81f1f;
  margin: 2px 0 -6px;
}

.em-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.em-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .08s, box-shadow .12s, background .12s;
}
.em-btn:active { transform: translateY(1px); }
.em-btn:disabled { opacity: .6; cursor: not-allowed; }

.em-btn--ghost {
  background: transparent;
  border-color: rgba(0,0,0,.18);
  color: inherit;
}
.em-btn--ghost:hover { background: rgba(0,0,0,.04); }

.em-btn--primary {
  background: var(--lemon-yellow, #f5c518);
  color: #1a1a1a;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.em-btn--primary:hover { box-shadow: 0 5px 0 rgba(0,0,0,.18); }
.em-btn--primary:active { box-shadow: 0 2px 0 rgba(0,0,0,.18); }

.em-fine {
  font-size: 11px;
  color: var(--lemon-mute, #4a4a4a);
  margin: 14px 0 0;
  line-height: 1.5;
}

@media (max-width: 540px) {
  .em-modal { padding: 22px 20px 18px; border-radius: 14px; }
  .em-title { font-size: 22px; }
  .em-row--triple { grid-template-columns: 1fr 1fr 1fr; }
  .em-actions { flex-direction: column-reverse; }
  .em-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .em-veil, .em-modal { animation: none; }
}

/* =============================================================
   V31 Task 3.2 — Inline takeover mode (desktop ≥768)
   When EnrollmentModal.show is invoked with mountMode='inline',
   the modal mounts inside .nx-main-host--enroll (NOT body) and
   the .em-modal--inline class drops the fixed positioning + veil
   so it lives inside the main column alongside the chat sidebar.
   ============================================================= */
@media (min-width: 768px) {
  /* Root wrapper of an inline-mounted modal — no fixed positioning. */
  .em-root[data-em-mount="inline"] {
    position: relative;
    inset: auto;
    z-index: auto;
    width: 100%;
    height: 100%;
  }
  .em-modal.em-modal--inline {
    position: relative;        /* NOT fixed */
    width: 100%;
    max-width: none;
    margin: 0 auto;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 24px;
    inset: auto;
    top: auto;
    left: auto;
    transform: none;
    max-height: none;
    overflow: visible;
  }
  /* Defang the veil in inline mode — strip its absolute positioning,
     backdrop dimming, blur, and flex centering. The veil is a PARENT of
     .em-modal, so `display: none` would hide the modal too (bug found via
     puppeteer end-to-end test post-SHIPPED). */
  .em-root[data-em-mount="inline"] .em-veil {
    position: static;
    inset: auto;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: block;
    width: 100%;
    height: auto;
    opacity: 1;
    pointer-events: auto;
    padding: 0;
  }
  /* The inner card retains its visual identity but caps width so it
     reads comfortably inside the main pane. */
  .em-modal.em-modal--inline .em-card {
    margin: 0 auto;
    max-width: 720px;
  }
}

/* Mobile (<768) — inline mode shouldn't typically activate here, but if it
   does (caller forces it), gracefully fall back to the overlay layout so
   the form remains usable on small viewports. */
@media (max-width: 767px) {
  .em-modal.em-modal--inline {
    position: fixed;
    inset: 0;
  }
}

/* =============================================================
   v0.8 D — Addon section above the form. NOT sneaky:
   • visible "Pre-selected · uncheck to skip" badge
   • running total updates live (data-em-total)
   • clear price per item
   ============================================================= */
.em-addons {
  margin: 0 0 18px;
  padding: 18px 18px 14px;
  background: linear-gradient(180deg, rgba(255, 200, 87, 0.10) 0%, transparent 100%);
  border: 1px dashed var(--ink, #0E2A3A);
  border-radius: 14px;
}
.em-addons-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.em-addons-eye {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink, #0E2A3A);
}
.em-addons-pre {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mute, #4A6678);
  background: rgba(255, 255, 255, 0.7);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--rule, #DDE9EE);
  transition: opacity 240ms ease;
}
.em-addons-sub {
  font-size: 13px;
  color: var(--mute, #4A6678);
  margin: 0 0 14px;
  line-height: 1.45;
}
.em-addons-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
/* V36 UX Phase 5 / DAV-N17 — AddonRow host. Stacked rows with gentle gap
 * so the always-open layout breathes between options. The [hidden] attr
 * (set when AddonRow isn't loaded) defaults to display:none. */
.em-addons-host[data-em-addons-host] {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.em-addons-host[data-em-addons-host][hidden] {
  display: none;
}
/* When AddonRow has mirrored selection state, the legacy grid is kept in
 * the DOM as the POST source of truth but visually hidden. */
.em-addons-grid--mirror[hidden] {
  display: none;
}
.em-addon {
  display: block;
  cursor: pointer;
  position: relative;
}
.em-addon input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.em-addon-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid var(--rule, #DDE9EE);
  border-radius: 10px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.em-addon:hover .em-addon-tile {
  border-color: var(--ink, #0E2A3A);
  transform: translateX(1px);
}
.em-addon input:focus-visible + .em-addon-tile {
  outline: 2px solid var(--lemon, #FFC857);
  outline-offset: 2px;
}
.em-addon input:checked + .em-addon-tile {
  background: var(--lemon, #FFC857);
  border-color: var(--ink, #0E2A3A);
  box-shadow: 2px 2px 0 var(--ink, #0E2A3A);
  transform: translate(-1px, -1px);
}
.em-addon-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.em-addon-meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.em-addon-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink, #0E2A3A);
}
.em-addon-sub {
  font-size: 12.5px;
  color: var(--mute, #4A6678);
  line-height: 1.3;
}
.em-addon-price {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--ink, #0E2A3A);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.em-addon-price small {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--mute, #4A6678);
  margin-left: 1px;
}
.em-addons-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid var(--ink, #0E2A3A);
  border-radius: 10px;
}
.em-addons-total-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute, #4A6678);
}
.em-addons-total-amount {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 24px;
  color: var(--ink, #0E2A3A);
  font-variant-numeric: tabular-nums;
}
.em-addons-total-amount small {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--mute, #4A6678);
  margin-left: 2px;
}
@media (max-width: 480px) {
  .em-addons { padding: 14px 14px 10px; }
  .em-addon-tile { padding: 10px; gap: 10px; }
  .em-addon-icon { font-size: 20px; width: 28px; }
}

/* =============================================================
   V33A F8 / DAV-36 + DAV-37 / R3 + R11 — Confirmation banner +
   Edit-details panel + Mailing-address fieldset
   ============================================================= */

.em-banner {
  background: #fff;
  border: 1.5px solid rgba(0,0,0,.08);
  border-radius: 14px;
  padding: 16px 18px;
  margin: 0 0 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.em-banner-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.em-banner-title {
  font-family: var(--lemon-serif, "Fraunces", Georgia, serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--lemon-ink, #1a1a1a);
}

.em-banner-edit-cue {
  font-size: 12px;
  color: var(--lemon-mute, #4a4a4a);
}

.em-banner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
}

.em-banner-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.em-banner-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--lemon-mute, #4a4a4a);
  font-weight: 600;
}

.em-banner-value {
  font-size: 14px;
  color: var(--lemon-ink, #1a1a1a);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .em-banner-grid { grid-template-columns: 1fr; gap: 6px; }
  .em-banner { padding: 14px; }
}

.em-fieldset {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.em-legend {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: var(--lemon-mute, #4a4a4a);
  padding: 0 6px;
}

.em-edit {
  margin-top: 8px;
  border: 1px dashed rgba(0,0,0,.18);
  border-radius: 10px;
  padding: 6px 12px;
  background: rgba(0,0,0,.015);
}

.em-edit-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--lemon-ink, #1a1a1a);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}

.em-edit-summary:hover { color: #000; }

.em-edit[open] .em-edit-summary {
  border-bottom: 1px solid rgba(0,0,0,.08);
  margin-bottom: 8px;
  padding-bottom: 8px;
}

.em-edit-note {
  font-size: 12px;
  color: var(--lemon-mute, #4a4a4a);
  margin: 0 0 10px;
  line-height: 1.4;
}

.em-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 4px 0 8px;
}

.em-edit-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@media (max-width: 480px) {
  .em-edit-grid { grid-template-columns: 1fr; }
}

