/* OneVoice27 web channel — visual direction from onevoice27.org/en + SAC co-brand
   Themes: dark (default, campaign brand) | light (optional; data-theme="light") */

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;600;700&family=Noto+Serif:wght@400;600&display=swap");

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --ov-bg: #000000;
  --ov-page-glow-a: rgba(150, 65, 173, 0.42);
  --ov-page-glow-b: rgba(0, 213, 254, 0.1);
  --ov-surface: rgba(18, 10, 28, 0.88);
  --ov-surface-solid: #120a1c;
  --ov-panel-border: rgba(255, 97, 188, 0.28);
  --ov-magenta: #ff61bc;
  --ov-cyan: #00d5fe;
  --ov-purple: #9641ad;
  --ov-text: #f5f5f5;
  --ov-muted: #8e8e8e;
  --ov-bot-bubble: rgba(255, 255, 255, 0.07);
  --ov-bot-border: rgba(255, 255, 255, 0.06);
  --ov-user-bubble: linear-gradient(135deg, rgba(255, 97, 188, 0.92), rgba(150, 65, 173, 0.95));
  --ov-user-text: #ffffff;
  --ov-strong: #ffffff;
  --ov-bot-strong: var(--ov-cyan);
  --ov-header-border: rgba(255, 255, 255, 0.08);
  --ov-progress-track: rgba(255, 255, 255, 0.1);
  --ov-composer-bg: rgba(0, 0, 0, 0.25);
  --ov-input-bg: rgba(0, 0, 0, 0.35);
  --ov-input-border: rgba(255, 255, 255, 0.12);
  --ov-logo-primary-filter: drop-shadow(0 0 28px rgba(255, 97, 188, 0.2));
  --ov-logo-secondary-filter: none;
  --ov-logo-header-filter: none;
  --ov-logo-header-sac-filter: none;
  --ov-theme-btn-bg: rgba(255, 255, 255, 0.08);
  --ov-theme-btn-border: rgba(255, 255, 255, 0.14);
  --font-ui: "Noto Sans", Helvetica, Arial, sans-serif;
  --font-body: "Noto Serif", "Times New Roman", Georgia, serif;
  --radius-panel: 1.25rem;
  --radius-bubble: 1rem;
  --shadow-panel: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--ov-panel-border);
  --chat-max: 26rem;
}

html[data-theme="light"] {
  color-scheme: light;
  --ov-bg: #f4f0f8;
  --ov-page-glow-a: rgba(150, 65, 173, 0.14);
  --ov-page-glow-b: rgba(0, 127, 152, 0.08);
  --ov-surface: rgba(255, 255, 255, 0.92);
  --ov-surface-solid: #ffffff;
  --ov-panel-border: rgba(150, 65, 173, 0.22);
  --ov-magenta: #d941a0;
  --ov-cyan: #0089a3;
  --ov-purple: #7a3590;
  --ov-text: #1a1224;
  --ov-muted: #6b6575;
  --ov-bot-bubble: rgba(150, 65, 173, 0.07);
  --ov-bot-border: rgba(150, 65, 173, 0.12);
  --ov-user-bubble: linear-gradient(135deg, #e84baa, #8b3da5);
  --ov-user-text: #ffffff;
  --ov-strong: #1a1224;
  --ov-bot-strong: #8b3da5;
  --ov-header-border: rgba(26, 18, 36, 0.08);
  --ov-progress-track: rgba(26, 18, 36, 0.1);
  --ov-composer-bg: rgba(244, 240, 248, 0.95);
  --ov-input-bg: #ffffff;
  --ov-input-border: rgba(26, 18, 36, 0.12);
  /* White OneVoice SVG + white SAC PNG → readable dark marks on light bg */
  --ov-logo-primary-filter: brightness(0) saturate(100%);
  --ov-logo-secondary-filter: invert(1) brightness(0.15);
  --ov-logo-header-filter: brightness(0) saturate(100%);
  --ov-logo-header-sac-filter: invert(1) brightness(0.15);
  --ov-theme-btn-bg: rgba(26, 18, 36, 0.05);
  --ov-theme-btn-border: rgba(26, 18, 36, 0.12);
  --shadow-panel: 0 20px 48px rgba(80, 40, 100, 0.12), 0 0 0 1px var(--ov-panel-border);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ov-text);
  background:
    radial-gradient(ellipse 90% 60% at 50% 18%, var(--ov-page-glow-a) 0%, transparent 58%),
    radial-gradient(ellipse 55% 40% at 50% 55%, var(--ov-page-glow-b) 0%, transparent 52%),
    var(--ov-bg);
  min-height: 100dvh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.is-embed {
  background: var(--ov-bg);
  min-height: 100dvh;
}

/* ——— App shell ——— */
.app {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem 1.5rem;
  gap: 1rem;
}

body.is-embed .app {
  padding: 0;
  min-height: 100dvh;
  justify-content: stretch;
}

/* Brand lockup (standalone only) */
.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.brand-lockup__primary {
  display: block;
  width: min(16rem, 78vw);
  height: auto;
  filter: var(--ov-logo-primary-filter);
}

.brand-lockup__divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: min(12rem, 62vw);
  margin: 0.7rem 0 0.55rem;
  color: var(--ov-muted);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.brand-lockup__divider::before,
.brand-lockup__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--ov-magenta) 55%, transparent),
    color-mix(in srgb, var(--ov-cyan) 45%, transparent),
    transparent
  );
}

.brand-lockup__secondary {
  display: block;
  width: min(10rem, 48vw);
  height: auto;
  opacity: 0.92;
  filter: var(--ov-logo-secondary-filter);
}

body.is-embed .brand-lockup--page {
  display: none;
}

/* ——— Chat panel ——— */
.chat-panel {
  width: min(var(--chat-max), 100%);
  height: min(36rem, calc(100dvh - 11rem));
  max-height: 42rem;
  display: flex;
  flex-direction: column;
  background: var(--ov-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

body.is-embed .chat-panel {
  width: 100%;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--ov-surface-solid);
}

.chat-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem 0.75rem;
  border-bottom: 1px solid var(--ov-header-border);
  flex-shrink: 0;
}

.chat-header__brands {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
}

.chat-header__ov {
  display: block;
  width: min(11.5rem, 58vw);
  height: auto;
  filter: var(--ov-logo-header-filter);
}

.chat-header__sac {
  display: block;
  width: min(7.5rem, 40vw);
  height: auto;
  opacity: 0.9;
  filter: var(--ov-logo-header-sac-filter, var(--ov-logo-secondary-filter));
}

.chat-header__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
}

.chat-header__copy {
  text-align: right;
}

.chat-header__title {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ov-cyan);
}

.chat-header__status {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--ov-muted);
}

/* Theme toggle */
.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 52px;
  border: 1px solid var(--ov-theme-btn-border);
  background: var(--ov-theme-btn-bg);
  color: var(--ov-muted);
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--ov-text);
  border-color: color-mix(in srgb, var(--ov-magenta) 45%, transparent);
  outline: none;
}

.theme-toggle__icon {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  flex-shrink: 0;
}

.theme-toggle__icon svg {
  width: 100%;
  height: 100%;
}

html[data-theme="dark"] .theme-toggle__icon--sun,
html:not([data-theme]) .theme-toggle__icon--sun,
html[data-theme="light"] .theme-toggle__icon--moon {
  display: none;
}

html[data-theme="light"] .theme-toggle__icon--sun {
  display: block;
}

/* Progress: four commitment items */
.progress {
  display: flex;
  gap: 0.35rem;
  padding: 0 1rem 0.75rem;
  flex-shrink: 0;
}

.progress__seg {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: var(--ov-progress-track);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.progress__seg.is-done {
  background: linear-gradient(90deg, var(--ov-magenta), var(--ov-cyan));
  box-shadow: 0 0 10px color-mix(in srgb, var(--ov-magenta) 35%, transparent);
}

.progress__seg.is-active {
  background: var(--ov-magenta);
  box-shadow: 0 0 10px color-mix(in srgb, var(--ov-magenta) 45%, transparent);
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  /* Floor so the log keeps a couple of lines of context when the
     commitments block squeezes it — without it, flexbox collapses this to
     zero the moment the four items appear. */
  min-height: 3.5rem;
  padding: 0.85rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scroll-behavior: smooth;
}

.msg {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-bubble);
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: msg-in 0.28s ease both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg--bot {
  align-self: flex-start;
  background: var(--ov-bot-bubble);
  border: 1px solid var(--ov-bot-border);
  border-bottom-left-radius: 0.3rem;
  font-family: var(--font-body);
  color: var(--ov-text);
}

.msg--user {
  align-self: flex-end;
  background: var(--ov-user-bubble);
  border-bottom-right-radius: 0.3rem;
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--ov-user-text);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ov-magenta) 22%, transparent);
}

/* Confirmation image, sent once at the end of a completed walkthrough */
.msg--image {
  padding: 0.35rem;
  background: var(--ov-bot-bubble);
  border: 1px solid var(--ov-bot-border);
  /* Hard-clip to the bubble's own rounded rect — without this, the img's
     separately-rounded corners can leave a hairline sliver of the bubble
     background exposed on one edge (a subpixel rounding mismatch between
     the two radii, browser-dependent). */
  overflow: hidden;
  /* .messages is a column flexbox, and a flex item with overflow != visible
     loses its content-based automatic minimum size (CSS flexbox spec) —
     without this, the flex-shrink pass crushes this bubble down to ~13px
     instead of its actual (tall) image height. */
  flex-shrink: 0;
  cursor: pointer;
}

.msg--image img {
  display: block;
  width: 100%;
  max-width: 16rem;
  height: auto;
}

.msg--image__hint {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--ov-muted);
  text-align: center;
}

/* Full-screen viewer for the confirmation image — meant to be shown to a
   volunteer/staff member for a freebie/coupon redemption, so it needs to
   read clearly at a glance, not as a thumbnail buried in the chat. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.6rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lightbox__close:hover,
.lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.msg strong {
  font-weight: 700;
  color: var(--ov-strong);
}

.msg--bot strong {
  color: var(--ov-bot-strong);
}

.msg--user strong {
  color: var(--ov-user-text);
}

.msg a {
  color: var(--ov-cyan);
}

/* Commitments multi-select — web-only (WhatsApp has no equivalent widget,
   see docs/ARCHITECTURE.md "Commitment multi-select (web only)"). Rows read
   as selectable list items, not literal checkboxes: a soft outline by
   default, a filled tinted background + a small circular check mark once
   toggled on. */
.commitments {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.15rem 1rem 0.7rem;
  /* Must be able to give ground. All four items together are taller than
     the panel on a phone, and the panel is `overflow: hidden` with nothing
     else scrollable — an unshrinkable block here pushes the Continue button
     and the composer clean off the bottom with no way to reach them. */
  flex: 0 1 auto;
  min-height: 0;
}

.commitments:empty {
  display: none;
}

.commitments__list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  /* The list is the part that scrolls, so the Continue button below it
     stays pinned and visible however many items there are. */
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.commitment-pill {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--ov-bot-border);
  background: var(--ov-bot-bubble);
  color: var(--ov-text);
  border-radius: 0.9rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.commitment-pill:hover {
  border-color: color-mix(in srgb, var(--ov-magenta) 45%, var(--ov-bot-border));
}

.commitment-pill:focus-visible {
  outline: 2px solid var(--ov-cyan);
  outline-offset: 2px;
}

.commitment-pill:active {
  transform: scale(0.99);
}

.commitment-pill.is-selected {
  border-color: var(--ov-magenta);
  background: color-mix(in srgb, var(--ov-magenta) 14%, var(--ov-bot-bubble));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ov-magenta) 35%, transparent);
}

.commitment-pill__check {
  flex-shrink: 0;
  margin-top: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  border: 1.5px solid var(--ov-muted);
  background: transparent;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.commitment-pill.is-selected .commitment-pill__check {
  border-color: var(--ov-magenta);
  background: linear-gradient(135deg, var(--ov-magenta), var(--ov-purple));
}

.commitment-pill.is-selected .commitment-pill__check::after {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.14rem;
  width: 0.28rem;
  height: 0.5rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}

.commitment-pill__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.commitment-pill__title {
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ov-text);
}

.commitment-pill__desc {
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ov-muted);
}

.commitment-pill__continue {
  appearance: none;
  flex-shrink: 0;
  border: none;
  border-radius: 52px;
  background: linear-gradient(135deg, var(--ov-magenta), var(--ov-purple));
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease;
}

.commitment-pill__continue:hover {
  filter: brightness(1.06);
}

.commitment-pill__continue:active {
  transform: scale(0.98);
}

/* Save-to-WhatsApp card — web-only, shown once at DONE alongside the
   confirmation image (see docs/ARCHITECTURE.md "Save-to-WhatsApp"). Styled
   as a bot-bubble-like card rather than a plain link so it reads as part of
   the conversation, not a stray footer control. */
.save-link {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0 1rem 0.7rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--ov-bot-border);
  background: var(--ov-bot-bubble);
  border-radius: var(--radius-bubble);
  flex-shrink: 0;
}

.save-link:empty {
  display: none;
}

.save-link__intro {
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ov-text);
}

.save-link__button {
  align-self: flex-start;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  border: none;
  border-radius: 52px;
  background: linear-gradient(135deg, var(--ov-magenta), var(--ov-purple));
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease;
}

.save-link__button:hover,
.save-link__button:focus-visible {
  filter: brightness(1.06);
}

.save-link__button:active {
  transform: scale(0.98);
}

/* Quick replies */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.35rem 1rem 0.55rem;
  flex-shrink: 0;
  min-height: 0;
}

.suggestions:empty {
  display: none;
}

.chip {
  appearance: none;
  border: 1px solid var(--ov-magenta);
  background: transparent;
  color: var(--ov-magenta);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.45rem 0.95rem;
  border-radius: 52px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.chip:hover,
.chip:focus-visible {
  background: var(--ov-magenta);
  color: #fff;
  outline: none;
}

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

.chip--primary {
  background: var(--ov-magenta);
  color: #fff;
}

.chip--primary:hover,
.chip--primary:focus-visible {
  filter: brightness(1.06);
  background: var(--ov-magenta);
}

/* Composer */
.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem 0.85rem;
  border-top: 1px solid var(--ov-header-border);
  flex-shrink: 0;
  background: var(--ov-composer-bg);
}

.composer__input {
  flex: 1;
  min-width: 0;
  appearance: none;
  border: 1px solid var(--ov-input-border);
  background: var(--ov-input-bg);
  color: var(--ov-text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  border-radius: 52px;
  outline: none;
  transition: border-color 0.15s ease;
}

.composer__input::placeholder {
  color: var(--ov-muted);
}

.composer__input:focus {
  border-color: color-mix(in srgb, var(--ov-cyan) 60%, transparent);
}

.composer__send {
  appearance: none;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ov-magenta), var(--ov-purple));
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.composer__send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.composer__send:active:not(:disabled) {
  transform: scale(0.96);
}

.composer__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer__send svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

/* Footer actions */
.panel-footer {
  display: flex;
  justify-content: center;
  padding: 0 1rem 0.55rem;
  flex-shrink: 0;
}

.panel-footer:empty {
  display: none;
}

.link-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--ov-muted);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  padding: 0.25rem;
}

.link-btn:hover {
  color: var(--ov-text);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .msg {
    animation: none;
  }
  .progress__seg {
    transition: none;
  }
  body {
    transition: none;
  }
}

@media (max-width: 420px) {
  .app {
    padding: 0.75rem 0.65rem 1rem;
  }
  /* Drop the page lockup on phones — the panel header already carries both
     logos, and repeating them costs ~40% of the screen on a screen whose
     job is completing the commitment. Same call `body.is-embed` makes. */
  .brand-lockup--page {
    display: none;
  }
  body:not(.is-embed) .chat-panel {
    /* With the lockup gone the panel can fill the viewport; 1.75rem is the
       .app top + bottom padding below. The 42rem desktop cap would
       otherwise still bind and leave the space unused. */
    height: calc(100dvh - 1.75rem);
    max-height: none;
  }
  .brand-lockup__primary {
    width: min(13.5rem, 76vw);
  }
  .theme-toggle__label {
    display: none;
  }
}
