/* packages/tokens/tokens.css */
/*
 * TrustFill design tokens (docs/ARCHITECTURE.md, Shared code and repo layout; docs/BRAND.md for
 * what each color is for and the contrast pairs).
 *
 * Plain CSS custom properties, named by purpose rather than by value (--color-surface, not
 * --white). These are the light theme, which every frontend uses. The caller's pages and the help
 * page also follow a dark scheme, whose values are in dark.css (W-078). The admin console and ops
 * map them into Tailwind's theme (packages/ui/src/theme.css); the customer form can use them
 * directly as var(--color-...).
 *
 * The names follow Tailwind's theme namespaces (--color-*, --font-*, --radius-*,
 * --shadow-*), so `bg-surface` or `rounded-md` in the admin console read these values.
 *
 * W-084 (brand brief): neutrals are tinted toward pine, and marigold joins as the one color for
 * "live" and "the caller typed this". Every frontend reads this one palette; none keeps a copy.
 */
:root {
  /* Backgrounds */
  --color-surface: #ffffff; /* page and card background */
  --color-surface-muted: #f4f7f6; /* sidebars, table headers, quiet areas */
  --color-surface-hover: #ebf0ee; /* hovered rows and menu items */

  /* Text */
  --color-text: #14201d; /* body text */
  --color-text-muted: #56645f; /* secondary text, captions */
  --color-text-inverse: #ffffff; /* text on dark or brand backgrounds */
  --color-attribution: #5e5e5e; /* "Google Maps" beside Google content: one of Google's own grays (W-102), 6.5:1 on white */

  /* Lines */
  --color-border: #dbe2df; /* dividers, card and input borders */
  --color-border-strong: #b5c1bc; /* hovered inputs */
  --color-border-field: #84938d; /* the caller's inputs: 3.2:1 on white, so each field is visible (WCAG 1.4.11) */

  /* Brand and actions */
  --color-primary: #0f6b5c; /* primary buttons, links, selection */
  --color-primary-hover: #0b574b;
  --color-on-primary: #ffffff; /* text and icons on --color-primary */
  --color-primary-halo: rgb(15 107 92 / 0.18); /* pine at 18%: the halo round a focused field on the caller's form */
  --color-primary-soft: #e6f2ef; /* mint wash: the caller seal, New tags, selected rows, quiet brand panels */
  --color-ink: #0d2b26; /* brand ink: live session bars, dark marketing bands, link preview cards */
  --color-focus: #2f7ff0; /* focus rings */

  /*
   * Live (marigold). Only for "live right now" or "the caller typed this": never a button, never
   * text on white. Text goes on the wash in --color-on-live-soft, or on marigold in --color-on-live.
   */
  --color-live: #f2b13c; /* live dots, the caller's marker, typing highlights (fills only) */
  --color-live-soft: #fff5e0; /* the wash behind a field the caller is typing in, "1 live" counts */
  --color-on-live-soft: #7a4f00; /* text on --color-live-soft (6.6:1) */
  --color-on-live: #3d2800; /* text and icons on --color-live */

  /* Status */
  --color-danger: #c4302b; /* destructive actions, errors */
  --color-danger-hover: #a52823;
  --color-on-danger: #ffffff;
  --color-success: #1d7a3e;
  --color-warning: #9a5b00;

  /* Type: system fonts only, so no font files or third-party hosts */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shape */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-popover: 0 4px 16px rgb(20 32 29 / 0.12), 0 1px 3px rgb(20 32 29 / 0.08);
}

/* packages/tokens/dark.css */
/*
 * The dark scheme (W-078, decided with the owner 2026-11-13; derived from the brand in W-087,
 * docs/BRAND.md → Dark theme). For the pages that follow the viewer's prefers-color-scheme: the
 * caller's pages (/s and /start) and the help pages, which get it in /brand/base.css. The console,
 * ops and the side panel are light only and never import this file.
 *
 * These are values, not a switch: a page maps its own variables onto them inside its
 * `@media (prefers-color-scheme: dark)` block. Each is named after the light token it stands in for.
 * Ink-dark surfaces tinted toward pine, and a lighter pine accent.
 */
:root {
  /* Backgrounds */
  --color-dark-page: #0b1412; /* behind the card (light: --color-surface-muted) */
  --color-dark-surface: #111c19; /* the card */
  --color-dark-surface-muted: #16241f; /* quiet areas, a field the agent typed */

  /* Text */
  --color-dark-text: #e4ece9; /* 14.5:1 on the card */
  --color-dark-text-muted: #98a9a3; /* 7.1:1 on the card */
  --color-dark-attribution: #ffffff; /* "Google Maps" on dark: Google allows white (W-102), 17.4:1 on the card */

  /* Lines */
  --color-dark-border: #263732;
  --color-dark-border-field: #5f716c; /* an input's edge: 3.4:1 on the card (WCAG 1.4.11) */

  /* Brand and actions */
  --color-dark-primary: #5cc4ad; /* 8.3:1 on the card */
  --color-dark-primary-hover: #7dd3bf;
  --color-dark-on-primary: #071a16; /* 8.5:1 on --color-dark-primary */
  --color-dark-primary-soft: #123a33; /* the deep pine wash: the seal, the flash, selected choices */
  --color-dark-on-primary-soft: #cfe9e2; /* the seal's text: 9.8:1 on the wash */
  --color-dark-primary-halo: rgb(92 196 173 / 0.22); /* the accent at 22%: the halo round a focused field */

  /* Status */
  --color-dark-danger: #ff8a80;

  /* The select caret (controls.css) in --color-dark-text-muted (#98a9a3) */
  --control-caret-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2398a9a3' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
}

/* packages/tokens/controls.css */
/*
 * Form controls shared by every frontend (W-045, W-084). Plain CSS: the Tailwind apps import it
 * unlayered, so it wins over px-* utilities; the caller pages get it in /brand/base.css.
 *
 * Selects: our own caret, inset from the right edge by the same amount as the text's left
 * padding, instead of the browser's, which sits against the edge. Each frontend sets
 * --control-pad-x to its inputs' horizontal padding (0.75rem by default, the console's px-3).
 * test/browser/polish.spec.ts (expectCaretInset) checks it in the console and on the caller's form.
 * [data-caret] gives a button that opens a list (the side panel's searchable picker) the same caret.
 * The SVG is a data: URI, which every host's CSP allows for images.
 */
:root {
  --control-pad-x: 0.75rem;
  /* stroke is --color-text-muted (#56645f) */
  --control-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2356645f' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
}

select,
[data-caret] {
  appearance: none;
  padding-right: calc(var(--control-pad-x) + 1.5rem);
  background-image: var(--control-caret);
  background-repeat: no-repeat;
  background-position: right var(--control-pad-x) center;
  background-size: 1rem;
}
select[multiple],
select[size]:not([size="1"]) {
  padding-right: var(--control-pad-x);
  background-image: none;
}

/* packages/tokens/brand.css */
/*
 * The mark, the lockup and their motion (W-084, docs/BRAND.md). Plain CSS for every frontend:
 * the Tailwind apps import it through packages/ui or their own stylesheet, the marketing site
 * from its stylesheet, and the caller pages get it in /brand/base.css.
 *
 * The SVG comes from packages/tokens/src/mark.ts (markSvg(), or <Mark> in React), whose parts
 * carry the tf-mark-* classes used here.
 */

.tf-mark {
  display: inline-block;
  flex: none;
  overflow: visible; /* the Meet slide starts just outside the 32×32 box */
  vertical-align: middle;
}
.tf-mark * {
  transform-box: fill-box;
  transform-origin: center;
}

/* The lockup: the mark plus "TrustFill" in a single color. The mark is 1.4× the text size. */
.tf-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}
.tf-lockup .tf-mark {
  width: 1.4em;
  height: 1.4em;
}

/* Meet: the tiles slide in from opposite corners, the overlap fades in, then the check draws. Once, on load. */
.tf-mark--meet .tf-mark-caller {
  animation: tf-meet-caller 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.tf-mark--meet .tf-mark-business {
  animation: tf-meet-business 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.tf-mark--meet .tf-mark-overlap {
  animation: tf-meet-overlap 1.2s both;
}
.tf-mark--meet .tf-mark-check {
  stroke-dasharray: 27;
  animation: tf-meet-check 1.2s ease-out both;
}
@keyframes tf-meet-caller {
  0% {
    transform: translate(6px, -6px);
    opacity: 0;
  }
  50%,
  100% {
    transform: none;
    opacity: 1;
  }
}
@keyframes tf-meet-business {
  0% {
    transform: translate(-6px, 6px);
    opacity: 0;
  }
  50%,
  100% {
    transform: none;
    opacity: 1;
  }
}
@keyframes tf-meet-overlap {
  0%,
  45% {
    opacity: 0;
  }
  55%,
  100% {
    opacity: 1;
  }
}
@keyframes tf-meet-check {
  0%,
  60% {
    stroke-dashoffset: 27;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/*
 * Live, then confirmed. While the session is live (tf-mark--live, with the dots drawn: markSvg({ dots:
 * true })), the caller's tile breathes and the dots bounce. Swap to tf-mark--confirmed on
 * complete: the dots clear and the check draws.
 */
.tf-mark--live .tf-mark-caller {
  animation: tf-breathe 1.8s ease-in-out infinite;
}
.tf-mark--live .tf-mark-dots circle {
  animation: tf-dot 0.9s ease-in-out infinite;
}
.tf-mark--live .tf-mark-dots circle:nth-child(2) {
  animation-delay: 0.15s;
}
.tf-mark--live .tf-mark-dots circle:nth-child(3) {
  animation-delay: 0.3s;
}
.tf-mark--live .tf-mark-check {
  stroke-dasharray: 27;
  stroke-dashoffset: 27;
}
.tf-mark--confirmed .tf-mark-dots {
  opacity: 0;
  transition: opacity 0.2s;
}
.tf-mark--confirmed .tf-mark-check {
  stroke-dasharray: 27;
  animation: tf-draw 0.45s ease-out 0.15s both;
}
@keyframes tf-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
@keyframes tf-dot {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-1.2px);
  }
}
@keyframes tf-draw {
  from {
    stroke-dashoffset: 27;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* Reduced motion: the finished mark, at once. */
@media (prefers-reduced-motion: reduce) {
  .tf-mark *,
  .tf-mark .tf-mark-dots circle {
    animation: none !important;
    transition: none !important;
  }
  .tf-mark .tf-mark-check {
    stroke-dashoffset: 0 !important;
  }
  .tf-mark .tf-mark-dots {
    opacity: 0;
  }
}

/*
 * The live dot (W-085): marigold, with a soft pulse while something is live. A fill only, never
 * the only sign: put the word "live" (or a count) beside it. Used by the console's nav count and
 * live banner, and meant for the side panel's live bar too.
 */
.tf-live-dot {
  display: inline-block;
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--color-live);
  animation: tf-live-pulse 1.8s infinite;
}
@keyframes tf-live-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-live) 55%, transparent);
  }
  70% {
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--color-live) 0%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-live) 0%, transparent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tf-live-dot {
    animation: none;
  }
}

/*
 * An answer the caller just changed (W-086; the console too since W-156): its row gets the live
 * wash for a moment. The class stays on for 2.5s (TYPING_MS); the wash fades over the last of it.
 */
@keyframes tf-typing-wash {
  0%,
  60% {
    background-color: var(--color-live-soft);
  }
  100% {
    background-color: transparent;
  }
}
.typing-wash {
  animation: tf-typing-wash 2.5s ease-out forwards;
}
@media (prefers-reduced-motion: reduce) {
  .typing-wash {
    animation: none;
  }
}

/*
 * The caller seal (W-087, docs/BRAND.md → The caller seal): a mint pill with the mark and
 * "Verified by TrustFill", only on pages for people outside the business. Pine on mint is 5.6:1.
 * A page can recolor it for a dark theme with --seal-bg and --seal-text; the mark keeps its colors.
 */
.tf-seal {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 1.75rem;
  padding: 0.2em 0.75em 0.2em 0.45em;
  border: 0;
  border-radius: 999px;
  background: var(--seal-bg, var(--color-primary-soft));
  color: var(--seal-text, var(--color-primary));
  font: 600 0.8125rem/1.2 var(--font-sans);
  white-space: nowrap;
}
.tf-seal .tf-mark {
  width: 1.15rem;
  height: 1.15rem;
}

/*
 * Staff's nudge to show the next step (W-162): one soft pine ring out from Show to caller when the
 * caller has finished what they can see. Once, and not at all under reduced motion.
 */
.tf-nudge-pulse {
  animation: tf-nudge-pulse 1.4s ease-out 1;
}
@keyframes tf-nudge-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary) 45%, transparent);
  }
  100% {
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--color-primary) 0%, transparent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tf-nudge-pulse {
    animation: none;
  }
}
