/* Capture Co base styles and shared components (CAP-45). Reads only --ui-* roles and --cc-* scales from tokens.css,
   so the same markup renders in brand colors or, inside .cc-event, in the event tokens. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body.cc {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--ui-font-body);
  font-size: var(--cc-text-md);
  line-height: var(--cc-leading-body);
}

body.cc img, body.cc video, body.cc svg { max-width: 100%; }

body.cc a { color: var(--ui-accent); }
body.cc a:hover { color: var(--ui-accent-strong); }

body.cc :focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 2px;
}

.cc h1, .cc h2, .cc h3 {
  margin: 0;
  font-family: var(--ui-font-display);
  font-weight: 400;
  line-height: var(--cc-leading-tight);
}
.cc h1 { font-size: var(--cc-text-3xl); }
.cc h2 { font-size: var(--cc-text-2xl); }
.cc h3 { font-size: var(--cc-text-xl); line-height: var(--cc-leading-snug); }
.cc p { margin: 0; }

.cc-eyebrow {
  font-size: var(--cc-text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
}

.cc-muted { color: var(--ui-text-muted); }
.cc-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.cc-skip {
  position: absolute; left: var(--cc-space-3); top: -100px; z-index: 100;
  padding: var(--cc-space-2) var(--cc-space-4); border-radius: var(--cc-radius-md);
  background: var(--ui-accent); color: var(--ui-accent-ink);
}
.cc-skip:focus { top: var(--cc-space-3); }

.cc-container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: var(--cc-space-4); }
.cc-main { flex: 1; padding-block: var(--cc-space-6); }
.cc-stack { display: flex; flex-direction: column; gap: var(--cc-space-4); }
.cc-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cc-space-3); }
.cc-grid { display: grid; gap: var(--cc-space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- header, footer ---------- */

.cc-header { border-bottom: 1px solid var(--ui-border); background: var(--ui-bg); }
.cc-header__inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--cc-space-4);
  min-height: 64px; flex-wrap: wrap;
}

.cc-brand {
  display: inline-flex; align-items: center; gap: var(--cc-space-2); min-height: var(--cc-target);
  font-family: var(--ui-font-display); font-size: var(--cc-text-xl);
  color: var(--ui-text) !important; text-decoration: none;
}
.cc-brand svg { width: 24px; height: 24px; color: var(--ui-accent); }

.cc-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cc-space-1) var(--cc-space-4); }
.cc-nav a {
  display: inline-flex; align-items: center; min-height: var(--cc-target);
  color: var(--ui-text) !important; text-decoration: none; font-size: var(--cc-text-sm);
}
.cc-nav a:hover, .cc-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.cc-nav a.cc-nav__quiet { color: var(--ui-text-muted) !important; }

/* "Sign out" in the workspace layout: a button that looks like a quiet nav link in the top bar */
.cc-nav__form { display: contents; }
.cc-nav__button {
  display: inline-flex; align-items: center; min-height: var(--cc-target); padding: 0; background: none; border: 0;
  font: inherit; font-size: var(--cc-text-sm); color: var(--ui-text-muted); cursor: pointer;
}
.cc-nav__button:hover { text-decoration: underline; text-underline-offset: 4px; }

/* the signed-in Account menu: a <details> that works without script (cc.js also closes it on an outside click and Escape) */
.cc-menu { position: relative; }
.cc-menu__button {
  display: inline-flex; align-items: center; gap: var(--cc-space-2); min-height: var(--cc-target);
  list-style: none; cursor: pointer; color: var(--ui-text-muted); font-size: var(--cc-text-sm);
}
.cc-menu__button::-webkit-details-marker { display: none; }
.cc-menu__button::after { content: ""; width: 0.45em; height: 0.45em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.cc-menu__button:hover, .cc-menu[open] .cc-menu__button { text-decoration: underline; text-underline-offset: 4px; }
.cc-menu__panel {
  position: absolute; right: 0; z-index: 20; min-width: 12rem; margin-top: var(--cc-space-1); padding: var(--cc-space-2);
  display: flex; flex-direction: column; background: var(--ui-surface); border: 1px solid var(--ui-border-strong);
  border-radius: var(--cc-radius-sm); box-shadow: var(--cc-shadow-sm);
}
.cc-menu__panel form { display: contents; }
.cc-menu__panel a, .cc-menu__panel button {
  display: flex; align-items: center; width: 100%; min-height: var(--cc-target); padding: 0 var(--cc-space-3);
  background: none; border: 0; border-radius: var(--cc-radius-sm); font: inherit; font-size: var(--cc-text-sm);
  color: var(--ui-text) !important; text-align: left; text-decoration: none; cursor: pointer;
}
.cc-menu__panel a:hover, .cc-menu__panel button:hover { background: var(--ui-surface-2); text-decoration: none; }
@media (max-width: 767px) {
  /* in the wrapped nav the panel opens in the flow, full width, so it can never run off a narrow screen */
  .cc-menu { position: static; flex-basis: 100%; }
  .cc-menu__panel { position: static; margin-top: 0; box-shadow: none; }
}

.cc-footer { border-top: 1px solid var(--ui-border); padding-block: var(--cc-space-5); font-size: var(--cc-text-sm); color: var(--ui-text-muted); }
.cc-footer__inner { display: flex; flex-wrap: wrap; gap: var(--cc-space-2) var(--cc-space-5); justify-content: space-between; align-items: center; }
.cc-footer a { display: inline-flex; align-items: center; min-height: var(--cc-target); color: var(--ui-text-muted); }

/* ---------- button ---------- */

.cc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--cc-space-2);
  min-height: var(--cc-target); padding: 10px 20px;
  border: 1px solid transparent; border-radius: var(--ui-radius);
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background var(--cc-dur-fast) var(--cc-ease), border-color var(--cc-dur-fast) var(--cc-ease);
}
.cc-btn--primary { background: var(--ui-accent); color: var(--ui-accent-ink) !important; }
.cc-btn--primary:hover { background: var(--ui-accent-strong); }
.cc-btn--secondary { background: transparent; color: var(--ui-text) !important; border-color: var(--ui-border-strong); }
.cc-btn--secondary:hover { background: var(--ui-surface-2); }
.cc-btn--ghost { background: transparent; color: var(--ui-text) !important; }
.cc-btn--ghost:hover { background: var(--ui-surface-2); }
.cc-btn--danger { background: var(--ui-danger); color: var(--ui-bg) !important; }
.cc-btn--sm { min-height: var(--cc-target); padding: 6px 14px; font-size: var(--cc-text-sm); }
.cc-btn--lg { min-height: 52px; padding: 14px 28px; font-size: var(--cc-text-lg); }
.cc-btn--block { display: flex; width: 100%; }
.cc-btn[disabled], .cc-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.cc-btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.cc-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--ui-accent-ink); border-top-color: transparent;
  animation: cc-spin 0.8s linear infinite;
}
.cc-btn--secondary[aria-busy="true"]::after, .cc-btn--ghost[aria-busy="true"]::after { border-color: var(--ui-text); border-top-color: transparent; }
@keyframes cc-spin { to { transform: rotate(360deg); } }

/* ---------- field ---------- */

.cc-field { display: flex; flex-direction: column; gap: var(--cc-space-1); }
.cc-field__label { font-size: var(--cc-text-sm); font-weight: 600; }
.cc-input {
  width: 100%; min-height: var(--cc-target); padding: 10px 12px;
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius);
  background: var(--ui-surface); color: var(--ui-text); font: inherit;
}
textarea.cc-input { min-height: 140px; resize: vertical; font-family: inherit; }
.cc-input::placeholder { color: var(--ui-text-muted); opacity: 1; }
.cc-input[aria-invalid="true"] { border-color: var(--ui-danger); }
.cc-input--code { font-size: var(--cc-text-xl); letter-spacing: 0.08em; text-transform: uppercase; }
.cc-field__help { font-size: var(--cc-text-sm); color: var(--ui-text-muted); }
.cc-field__error { font-size: var(--cc-text-sm); color: var(--ui-danger); }
.cc-field__status { font-size: var(--cc-text-sm); color: var(--ui-text-muted); min-height: 1.4em; }
.cc-field__status[data-state="error"] { color: var(--ui-danger); }
.cc-input[readonly] { background: var(--ui-surface-2); color: var(--ui-text-muted); }

.cc-alert {
  padding: var(--cc-space-3) var(--cc-space-4); border-radius: var(--ui-radius);
  border: 1px solid var(--ui-border-strong); background: var(--ui-surface-2);
}
.cc-alert--danger { border-color: var(--ui-danger); }

/* ---------- card, stat, badge ---------- */

.cc-card {
  display: flex; flex-direction: column; gap: var(--cc-space-3);
  padding: var(--cc-space-5); border: 1px solid var(--ui-border); border-radius: var(--cc-radius-lg);
  background: var(--ui-surface); box-shadow: var(--cc-shadow-sm);
}
.cc-card--flat { box-shadow: none; }

.cc-stat { display: flex; flex-direction: column; gap: 2px; }
.cc-stat__value { font-family: var(--ui-font-display); font-size: var(--cc-text-2xl); line-height: 1; }
.cc-stat__label { font-size: var(--cc-text-sm); color: var(--ui-text-muted); }

.cc-badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--cc-radius-pill);
  border: 1px solid var(--ui-border-strong); background: var(--ui-surface);
  font-size: var(--cc-text-xs); font-weight: 600; letter-spacing: 0.04em; white-space: nowrap;
}
.cc-badge--essentials { border-color: var(--ui-accent); color: var(--ui-accent); }
.cc-badge--signature, .cc-badge--partner { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-accent-ink); }
.cc-badge--legacy { color: var(--ui-text-muted); border-style: dashed; }

/* ---------- locked feature, checklist ---------- */

.cc-locked {
  display: flex; align-items: center; justify-content: space-between; gap: var(--cc-space-4); flex-wrap: wrap;
  padding: var(--cc-space-4); border: 1px dashed var(--ui-border-strong); border-radius: var(--cc-radius-lg);
}
.cc-locked__text { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; }
.cc-locked__title { font-weight: 600; display: flex; align-items: center; gap: var(--cc-space-2); }
.cc-locked__reason { font-size: var(--cc-text-sm); color: var(--ui-text-muted); }

.cc-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cc-checklist__item {
  display: flex; align-items: center; gap: var(--cc-space-3); min-height: var(--cc-target);
  padding-block: var(--cc-space-2); border-bottom: 1px solid var(--ui-border);
}
.cc-checklist__item:last-child { border-bottom: 0; }
.cc-checklist__mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ui-border-strong);
  display: inline-flex; align-items: center; justify-content: center;
}
.cc-checklist__item[data-done="true"] .cc-checklist__mark { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-accent-ink); }
.cc-checklist__item[data-done="true"] .cc-checklist__text { color: var(--ui-text-muted); text-decoration: line-through; }
.cc-checklist__mark svg { width: 14px; height: 14px; }

/* ---------- tabs, bottom navigation ---------- */

.cc-tabs { display: flex; gap: var(--cc-space-1); border-bottom: 1px solid var(--ui-border); overflow-x: auto; }
.cc-tab {
  flex: none; display: inline-flex; align-items: center; min-height: var(--cc-target); padding: 0 var(--cc-space-4);
  border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ui-text-muted); font: inherit; font-weight: 600; cursor: pointer;
}
.cc-tab[aria-selected="true"] { color: var(--ui-text); border-bottom-color: var(--ui-accent); }
.cc-tabpanel[hidden] { display: none; }

.cc-bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 40; display: flex;
  border-top: 1px solid var(--ui-border); background: var(--ui-surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.cc-bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; font-size: var(--cc-text-xs); font-weight: 600; text-decoration: none;
  color: var(--ui-text-muted) !important;
}
.cc-bottomnav a[aria-current="page"] { color: var(--ui-accent) !important; }
.cc-bottomnav svg { width: 22px; height: 22px; }
/* ... and "Sign out" is the last tab on a phone */
.cc-bottomnav form { display: contents; }
.cc-bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 0; background: none; border: 0; font: inherit; font-size: var(--cc-text-xs); font-weight: 600;
  color: var(--ui-text-muted); cursor: pointer;
}

/* ---------- toast, sheet ---------- */

.cc-toasts {
  position: fixed; z-index: 60; inset: auto var(--cc-space-4) var(--cc-space-4) var(--cc-space-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--cc-space-2); pointer-events: none;
}
.cc-toast {
  pointer-events: auto; max-width: 420px; padding: var(--cc-space-3) var(--cc-space-4);
  border-radius: var(--ui-radius); background: var(--ui-text); color: var(--ui-bg); box-shadow: var(--cc-shadow-md);
}

.cc-sheet {
  width: 100%; max-width: 560px; margin: auto auto 0 auto; padding: var(--cc-space-5);
  border: 0; border-radius: var(--cc-radius-xl) var(--cc-radius-xl) 0 0;
  background: var(--ui-surface); color: var(--ui-text); box-shadow: var(--cc-shadow-lg);
}
.cc-sheet::backdrop { background: var(--cc-overlay); }
@media (min-width: 768px) { .cc-sheet { margin: auto; border-radius: var(--cc-radius-xl); } }

/* ---------- empty state, price card, faq, qr ---------- */

.cc-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--cc-space-3); text-align: center;
  padding: var(--cc-space-7) var(--cc-space-4); border: 1px dashed var(--ui-border-strong); border-radius: var(--cc-radius-lg);
}
.cc-empty p { max-width: 36ch; color: var(--ui-text-muted); }

.cc-price { position: relative; }
.cc-price--featured { border-color: var(--ui-accent); border-width: 2px; }
.cc-price__amount { font-family: var(--ui-font-display); font-size: var(--cc-text-3xl); line-height: 1; }
.cc-price__per { font-size: var(--cc-text-sm); color: var(--ui-text-muted); }
.cc-price__features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--cc-space-2); }
.cc-price__features li { display: flex; gap: var(--cc-space-2); }
.cc-price__features li::before { content: "\2713"; color: var(--ui-accent); font-weight: 700; }

.cc-faq { border-top: 1px solid var(--ui-border); }
.cc-faq details { border-bottom: 1px solid var(--ui-border); }
.cc-faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--cc-space-4);
  min-height: var(--cc-target); padding-block: var(--cc-space-3); cursor: pointer; font-weight: 600; list-style: none;
}
.cc-faq summary::-webkit-details-marker { display: none; }
.cc-faq summary::after { content: "+"; font-size: var(--cc-text-xl); line-height: 1; }
.cc-faq details[open] summary::after { content: "\2212"; }
.cc-faq__answer { padding-bottom: var(--cc-space-4); color: var(--ui-text-muted); max-width: 70ch; }

.cc-qr {
  display: inline-flex; flex-direction: column; align-items: center; gap: var(--cc-space-3);
  padding: var(--cc-space-4); border: 1px solid var(--ui-border); border-radius: var(--cc-radius-lg); background: #FFFFFF; color: #0D0E12;
}
.cc-qr__code { width: 180px; height: 180px; }
.cc-qr__code svg, .cc-qr__code img { display: block; width: 100%; height: 100%; }
.cc-qr__caption { font-size: var(--cc-text-sm); word-break: break-all; text-align: center; }

/* ---------- layouts ---------- */

.cc-topbar { border-bottom: 1px solid var(--ui-border); background: var(--ui-surface); }
.cc-workspace .cc-main { padding-bottom: calc(var(--cc-space-8) + 56px); }
@media (min-width: 768px) {
  .cc-bottomnav { display: none; }
  .cc-workspace .cc-main { padding-bottom: var(--cc-space-6); }
}
@media (max-width: 767px) {
  .cc-topbar .cc-nav { display: none; }
}

/* host dashboard (CAP-49): section navigation beside the page on a wide screen, the bottom tab bar on a phone (they switch at the same width) */
.cc-manage { display: block; }
.cc-sidenav { display: none; }
.cc-manage__body { min-width: 0; }
@media (min-width: 768px) {
  .cc-manage { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--cc-space-6); align-items: start; }
  .cc-sidenav { display: block; position: sticky; top: var(--cc-space-4); }
}
.cc-sidenav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cc-sidenav a { display: block; padding: var(--cc-space-2) var(--cc-space-3); border-radius: var(--cc-radius-md); color: var(--ui-text); text-decoration: none; }
.cc-sidenav a:hover { background: var(--ui-surface-2); }
.cc-sidenav a[aria-current="page"] { background: var(--ui-surface-2); font-weight: 600; }
.cc-stats { display: grid; gap: var(--cc-space-3); grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
.cc-copyline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cc-space-2) var(--cc-space-3); }
.cc-copyline a { overflow-wrap: anywhere; }

.cc-event .cc-main { padding-block: var(--cc-space-5); }

/* ---------- styleguide helpers ---------- */

.cc-sg-section { display: flex; flex-direction: column; gap: var(--cc-space-4); padding-block: var(--cc-space-5); border-bottom: 1px solid var(--ui-border); }
.cc-sg-swatches { display: grid; gap: var(--cc-space-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cc-sg-swatch { display: flex; flex-direction: column; gap: 2px; font-size: var(--cc-text-sm); }
.cc-sg-chip { height: 48px; border-radius: var(--cc-radius-md); border: 1px solid var(--ui-border); }
.cc-sg-event {
  --ev-bg: #FBF6F1; --ev-surface: #FFFFFF; --ev-surface-2: #F1E6DC; --ev-text: #2B1B17; --ev-text-muted: #6B4A41;
  --ev-border: #E2CFC2; --ev-border-strong: #8B6657; --ev-accent: #8C2F39; --ev-accent-strong: #6E232C; --ev-accent-ink: #FFFFFF;
  --ev-focus: #1F5FBF; --ev-danger: #A12A2A; --ev-radius: 14px;
  padding: var(--cc-space-5); border-radius: var(--cc-radius-xl);
  background: var(--ui-bg); color: var(--ui-text); font-family: var(--ui-font-body);
}

@media (prefers-reduced-motion: reduce) {
  .cc *, .cc *::before, .cc *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* a bottom bar shown in place, for the styleguide */
.cc-bottomnav--static { position: static; display: flex !important; border: 1px solid var(--ui-border); border-radius: var(--cc-radius-lg); overflow: hidden; }

/* light/dark switch in the header: shows the mode it switches to */
.cc-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: var(--cc-target); height: var(--cc-target);
  border: 0; border-radius: 50%; background: transparent; color: var(--ui-text); cursor: pointer;
}
.cc-theme-toggle:hover { background: var(--ui-surface-2); }
.cc-theme-toggle svg { width: 22px; height: 22px; }
.cc-theme-toggle__sun { display: none; }
:root[data-theme="dark"] .cc-theme-toggle__sun { display: block; }
:root[data-theme="dark"] .cc-theme-toggle__moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cc-theme-toggle__sun { display: block; }
  :root:not([data-theme="light"]) .cc-theme-toggle__moon { display: none; }
}

/* build and environment corner (outside production only) */
.cc-version {
  position: fixed; bottom: 0; left: 0; z-index: 90; padding: 2px 8px;
  font-size: var(--cc-text-xs); color: var(--ui-text-muted); background: var(--ui-surface);
  border-top-right-radius: var(--cc-radius-sm);
}

/* checklist links are touch targets too */
a.cc-checklist__text { display: inline-flex; align-items: center; min-height: var(--cc-target); }

/* a checkbox with a sentence next to it (sign-up consent): the whole row is the touch target */
.cc-check { display: flex; gap: var(--cc-space-3); align-items: flex-start; min-height: var(--cc-target); cursor: pointer; }
.cc-check input { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; accent-color: var(--ui-accent); }
