/* Sigmate design system — tokens + primitives. One source of truth for the site and the app. */

:root {
  /* Surfaces */
  --paper: #f7f5ef;        /* page background, warm */
  --surface: #ffffff;      /* cards, panels */
  --surface-2: #f1eee6;    /* wells, inset areas */
  --line: #e4e0d6;         /* hairlines */
  --line-strong: #cfcabd;

  /* Ink */
  --ink: #17181a;
  --ink-2: #4b4f57;
  --ink-3: #8a8f98;
  --ink-inverse: #f7f5ef;

  /* Signal (one accent, used sparingly) */
  --signal: #1f6f55;
  --signal-hover: #185a45;
  --signal-tint: #e6f1ec;
  --signal-ink: #0f3d2e;

  /* Feedback */
  --ok: #1f6f55;
  --warn: #b7791f;
  --warn-tint: #fbf3e2;
  --danger: #b9382c;
  --danger-tint: #fbe9e6;

  /* Type */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px; --fs-16: 16px;
  --fs-18: 18px; --fs-20: 20px; --fs-24: 24px; --fs-32: 32px; --fs-44: 44px; --fs-60: 60px;
  --lh-tight: 1.15; --lh: 1.5; --lh-loose: 1.65;
  --w-regular: 400; --w-medium: 500; --w-semibold: 600;

  /* Space (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px; --s-20: 80px;

  /* Shape */
  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-pill: 999px;

  /* Elevation (soft, warm, never glowing) */
  --shadow-1: 0 1px 2px rgba(23, 24, 26, .06);
  --shadow-2: 0 4px 14px rgba(23, 24, 26, .08), 0 1px 2px rgba(23, 24, 26, .05);
  --shadow-3: 0 18px 40px rgba(23, 24, 26, .14), 0 2px 6px rgba(23, 24, 26, .06);

  /* Motion — one language. 140 tiny response · 200 controls · 280 cards/layout · 420 premium reveal · 650 cinematic (hero only). */
  --t-1: 140ms; --t-2: 200ms; --t-3: 280ms; --t-4: 420ms; --t-5: 650ms;
  --t-fast: var(--t-1); --t: var(--t-2); --t-slow: var(--t-3);
  --ease: cubic-bezier(.22, 1, .36, 1);      /* decelerate into place, never bounce */
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --lift: 8px;                               /* reveal travel (4px on phones) */
  --ring: 0 0 0 3px rgba(31, 111, 85, .08);

  /* Layout */
  --bp-sm: 640px; --bp-md: 900px; --bp-lg: 1200px;
  --focus: 0 0 0 3px rgba(31, 111, 85, .28);
}

@media (max-width: 640px) { :root { --lift: 4px; } }
@media (prefers-reduced-motion: reduce) {
  /* Keep opacity changes, drop travel and transforms. */
  :root { --lift: 0px; }
  *, *::before, *::after { transition-property: opacity, color, background-color, border-color, box-shadow !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .btn:hover, .btn:active { transform: none !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-ui); font-size: var(--fs-14); line-height: var(--lh); -webkit-font-smoothing: antialiased; }
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-1); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Type scale */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; line-height: 1.05; }
.h1 { font-size: var(--fs-44); } .h2 { font-size: var(--fs-32); } .h3 { font-size: var(--fs-24); }
.eyebrow { font-size: var(--fs-12); font-weight: var(--w-semibold); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); } .small { font-size: var(--fs-12); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: 40px; padding: 0 var(--s-4); border-radius: var(--r-2); border: 1px solid transparent; font-weight: var(--w-medium); font-size: var(--fs-14); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), color var(--t-fast); user-select: none; }
.btn:hover { text-decoration: none; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: var(--t-1); }
.btn .arr { display: inline-block; transition: transform var(--t-2) var(--ease); }
.btn:hover .arr { transform: translateX(3px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--ink); color: var(--ink-inverse); }
.btn-primary:hover { background: #000; }
.btn-signal { background: var(--signal); color: #fff; }
.btn-signal:hover { background: var(--signal-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: var(--fs-13); border-radius: var(--r-1); }
.btn-lg { height: 48px; padding: 0 var(--s-6); font-size: var(--fs-15); border-radius: var(--r-3); }
.btn-block { width: 100%; }

/* Inputs */
.field { display: block; margin-bottom: var(--s-3); }
.field > .label { display: block; font-size: var(--fs-12); font-weight: var(--w-medium); color: var(--ink-2); margin-bottom: var(--s-1); }
.input, .select, .textarea { width: 100%; height: 40px; padding: 0 var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--surface); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.textarea { height: auto; padding: var(--s-2) var(--s-3); resize: vertical; }
.input::placeholder { color: var(--ink-3); }
.input:hover, .select:hover { border-color: #b9b3a5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--signal); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.help { font-size: var(--fs-12); color: var(--ink-3); margin-top: var(--s-1); }
.help.error { color: var(--danger); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }

/* Switch */
.switch { position: relative; width: 36px; height: 20px; border-radius: var(--r-pill); background: var(--line-strong); border: 0; cursor: pointer; flex: none; transition: background var(--t-fast); }
.switch::before { content: ""; position: absolute; inset: -12px; } /* 44px hit area */
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--t) var(--ease); }
.switch[aria-checked="true"] { background: var(--signal); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

/* Cards, surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); }
.well { background: var(--surface-2); border-radius: var(--r-2); }
.hr { height: 1px; background: var(--line); border: 0; margin: var(--s-4) 0; }

/* Tags, chips */
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--s-2); border-radius: var(--r-1); font-size: var(--fs-11); font-weight: var(--w-semibold); letter-spacing: .04em; text-transform: uppercase; background: var(--surface-2); color: var(--ink-2); }
.tag-signal { background: var(--signal-tint); color: var(--signal-ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s-3); border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); font-size: var(--fs-13); font-weight: var(--w-medium); color: var(--ink-2); cursor: pointer; transition: all var(--t-fast); }
.chip:hover { border-color: #b9b3a5; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-2); background: var(--surface-2); }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 var(--s-3); border-radius: 7px; font-size: var(--fs-13); font-weight: var(--w-medium); color: var(--ink-2); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Tooltip (pure CSS, hover/focus) */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 3px); background: var(--ink); color: var(--ink-inverse); font-size: var(--fs-12); line-height: 1.3; padding: 6px 8px; border-radius: var(--r-1); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast) var(--ease); z-index: 30; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: var(--ink); color: var(--ink-inverse); padding: 10px 14px; border-radius: var(--r-2); font-size: var(--fs-13); box-shadow: var(--shadow-3); opacity: 0; pointer-events: none; transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); z-index: 60; display: flex; gap: var(--s-3); align-items: center; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: transparent; border: 0; color: #9fd8c2; font-weight: var(--w-semibold); cursor: pointer; padding: 0; }

/* Skeleton */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-1); }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.1s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Dialog / sheet */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: var(--r-3); box-shadow: var(--shadow-3); max-width: min(560px, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: rgba(23, 24, 26, .45); }
dialog[open] { animation: dlg-in var(--t) var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); padding: var(--s-6) var(--s-6) 0; }
.dlg-body { padding: var(--s-4) var(--s-6) var(--s-6); }
.dlg-title { font-size: var(--fs-20); font-weight: var(--w-semibold); margin: 0; letter-spacing: -.01em; }
.x { width: 32px; height: 32px; border-radius: var(--r-1); border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 18px; line-height: 1; }
.x:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 640px) {
  dialog.sheet { max-width: 100vw; width: 100vw; margin: auto 0 0; border-radius: var(--r-3) var(--r-3) 0 0; max-height: 92vh; overflow: auto; }
  dialog.sheet[open] { animation: sheet-in var(--t-slow) var(--ease); }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Reveal helpers */
.fade-in { animation: fade-in var(--t) var(--ease) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* Premium reveal: opacity 0→1, lift→0, 420ms. */
.reveal { opacity: 0; transform: translateY(calc(var(--lift) * 1.75)); transition: opacity var(--t-4) var(--ease), transform var(--t-4) var(--ease); }
.reveal.in { opacity: 1; transform: none; }
/* The Sigmate settle: a portrait arrives into a finished signature, once. */
@keyframes settle { from { opacity: 0; transform: translateY(7px) scale(.985); } to { opacity: 1; transform: none; } }
/* Text link: underline grows left → right. */
.ul { position: relative; text-decoration: none !important; }
.ul::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform var(--t-2) var(--ease); }
.ul:hover::after, .ul[aria-current="true"]::after { transform: scaleX(1); }
/* Tiny status: green dot + Ready */
.ready { display: inline-flex; align-items: center; gap: 6px; color: var(--signal-ink); font-size: var(--fs-12); font-weight: var(--w-medium); }
.ready::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); }
/* PRO mark: tiny, green, never a lock */
.pro { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; border-radius: 4px; font-size: 9.5px; font-weight: var(--w-semibold); letter-spacing: .08em; background: var(--signal-tint); color: var(--signal-ink); vertical-align: middle; }
.expand { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-slow) var(--ease); }
.expand > * { overflow: hidden; }
.expand.open { grid-template-rows: 1fr; }

/* Mark */
.mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: var(--w-semibold); letter-spacing: -.01em; }
.mark svg { width: 28px; height: 28px; display: block; }
.mark:hover { text-decoration: none; }
