/* Tickaboo — shared component patterns.
 *
 * Governed by design-guide/current.md (the DNA) and design-guide/motion-plan.md
 * (the choreography). Colours come from tokens.css custom properties only:
 * a raw hex in this file is a contract violation.
 *
 * House rules enforced here: no shadows anywhere, no gradients except text
 * scrims, one peach element per screen, round shape family, rounded stroke
 * terminals on every icon.
 */

/* ─── Motion tokens (motion-plan.md §2) ─── */
:root {
  --dur-blink: 110ms;
  --dur-tap: 120ms;
  --dur-release: 260ms;
  --dur-swap: 240ms;
  --dur-icon: 320ms;
  --dur-enter: 600ms;
  --dur-draw: 800ms;
  --dur-peek: 500ms;

  --ease-out: cubic-bezier(0.22, 0.61, 0.21, 1);
  --ease-spring: cubic-bezier(0.34, 1.36, 0.64, 1);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-draw: cubic-bezier(0.4, 0, 0.2, 1);

  --dist-enter: 20px;
  --dist-slide: 12px;
  --stagger: 80ms;

  --header-h: 64px;
  --header-h-lg: 76px;

  /* v2 ground: white page, cream/mist demoted to soft washes for section
     alternation. Gradient stops use tokens only, no raw hex. */
  --wash-sage: linear-gradient(180deg, var(--color-surface-tint) 0%, color-mix(in srgb, var(--color-surface) 50%, var(--color-surface-tint)) 100%);
  --wash-cream: linear-gradient(180deg, var(--color-surface-tint) 0%, color-mix(in srgb, var(--color-paper) 45%, var(--color-surface-tint)) 100%);
}

html { scroll-behavior: smooth; }
/* clip, never hidden: overflow-x:hidden turns <body> into a scroll container
   and silently breaks every position:sticky on the page. */
body { overflow-x: clip; }

::selection { background: var(--color-accent-2); color: var(--color-ink); }

/* Brand rule: depth is surface steps, never shadow. Kill the scaffold's lift. */
.btn:hover { transform: none; }
:where(a, button, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: none;
}

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--color-primary); color: var(--color-paper);
  padding: 0.75rem 1.25rem; border-radius: var(--radius);
  font-family: var(--font-heading); font-weight: 600;
  transition: top var(--dur-swap) var(--ease-out);
}
.skip-link:focus { top: 1rem; text-decoration: none; }

/* ─── Surfaces and section rhythm ─── */
.surface-cream { background: var(--color-paper); }
.surface-white { background: var(--color-surface-tint); }
.surface-mist  { background: var(--color-surface); }
.surface-teal  { background: var(--color-dark); color: var(--color-dark-ink); }
.surface-wash-sage  { background: var(--wash-sage); }
.surface-wash-cream { background: var(--wash-cream); }

.section { padding-block: var(--section-pad); position: relative; }
.section--lg { padding-block: var(--section-pad-lg); }
.centred { text-align: center; }
h2.centred { max-width: 22ch; margin-inline: auto; font-size: clamp(2.1rem, 1.8rem + 1.6vw, 2.85rem); }
.section-lead {
  max-width: 62ch; margin: 0 auto clamp(2.5rem, 5vw, 3.5rem);
  text-align: center; color: var(--color-muted);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem); line-height: 1.6;
}

/* ─── Kicker: names a product surface, never restates the heading ─── */
.kicker {
  display: block;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--color-primary);
  margin: 0 0 0.9rem;
}

/* ─── Accent word: Quicksand 700 + hand-painted underline ───
   Used sparingly, one word per selected title. The underline is a filled
   SVG brush stroke; data-URIs can't reference custom properties, so the
   fill is written literally as #1E6B63 — the exact value of --color-primary,
   not a new colour. */
.accent--quicksand {
  font-family: var(--font-accent);
  font-weight: 700;
  font-style: normal;
  color: var(--color-primary);
  position: relative;
  white-space: nowrap;
}
.accent--quicksand::after {
  content: "";
  position: absolute;
  left: -1.5%; right: -1.5%; bottom: -0.16em;
  height: 0.24em;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M2.5 8.6 C 24 4.2, 55 2.6, 96 3.4 C 106 3.6, 114 4.2, 117.5 5.1 C 118.6 5.5, 118.3 6.6, 116.8 6.7 C 96 6.2, 66 6.4, 38 8.2 C 24 9.1, 12 10.2, 5 11 C 3.2 11.1, 1.8 10.2, 2 9.4 Z' fill='%231E6B63' fill-opacity='0.85'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}

/* ─── The tick-hatch icon ─── */
.icon-tick { width: 20px; height: 20px; flex: none; overflow: visible; }
.icon-tick :is(path, circle) { stroke-linecap: round; stroke-linejoin: round; fill: none; }
.icon-tick .icon-head,
.icon-tick .icon-tail { stroke: currentColor; stroke-width: 2.2; }
.icon-tick .icon-tail { stroke-dasharray: 16; stroke-dashoffset: 0; }
@keyframes tail-draw { from { stroke-dashoffset: 16; } to { stroke-dashoffset: 0; } }
.icon-tick .icon-eyes { fill: currentColor; stroke: none; transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.1); } }
.is-blinking .icon-eyes { animation: blink calc(var(--dur-blink) * 2) var(--ease-inout); }

/* ─── Buttons: v2 pill system ───
   Peach retires everywhere; teal is the only CTA colour now. Primary and
   secondary both carry a disc (.btn__disc) holding the eyeless brand mark
   (.icon-mark); the disc is optional markup, so a .btn without one (pages
   this pass does not touch) still renders as an evenly-padded plain pill. */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0;
  gap: 0.625rem;
  border-width: 0;
  transition: background-color var(--dur-swap) var(--ease-out),
              color var(--dur-swap) var(--ease-out),
              scale var(--dur-release) var(--ease-spring);
}
.btn:has(.btn__disc) { padding-right: 3.25rem; }
.btn:active { scale: 0.97; transition-duration: var(--dur-tap); transition-timing-function: var(--ease-out); }
.btn:hover .icon-tail,
.btn:focus-visible .icon-tail { animation: tail-draw var(--dur-icon) var(--ease-draw); }
.btn:hover .icon-eyes, .btn:focus-visible .icon-eyes { animation: blink calc(var(--dur-blink) * 2) var(--ease-inout) 180ms; }

.btn--accent, .btn--cta, .btn--primary { background: var(--color-primary); color: var(--color-paper); }
.btn--accent:hover, .btn--cta:hover, .btn--primary:hover {
  background: var(--color-dark); filter: none; box-shadow: none; color: var(--color-paper);
}
.btn--accent .btn__disc, .btn--cta .btn__disc, .btn--primary .btn__disc {
  background: var(--color-surface-tint); color: var(--color-primary);
}
.btn--secondary, .btn--ghost {
  background: var(--color-surface-tint); color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.btn--secondary:hover, .btn--ghost:hover { background: var(--color-surface); border-color: var(--color-accent-2); }
.btn--secondary .btn__disc, .btn--ghost .btn__disc {
  background: var(--color-surface-tint); color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.btn--lg { min-height: 3.5rem; padding: 0 1.75rem; font-size: 1.0625rem; }
.btn--lg:has(.btn__disc) { padding-right: 3.75rem; }
.btn--block { display: flex; width: 100%; }

/* The disc: white (or hairline-bordered white on secondary/ghost), parked
   at the trailing edge, holding the eyeless mark. Never swallows the pill. */
.btn__disc {
  position: absolute; top: 0.4375rem; bottom: 0.4375rem; right: 0.4375rem;
  aspect-ratio: 1; border-radius: 999px;
  display: grid; place-items: center;
  transition: right var(--dur-swap) var(--ease-out);
}
.btn:hover .btn__disc, .btn:focus-visible .btn__disc { right: 0.25rem; }

/* Eyeless brand mark: single continuous stroke, buttons only. The
   tick-with-eyes stays reserved for checklist bullets and status chips. */
.icon-mark { width: 18px; height: 18px; flex: none; overflow: visible; }
.icon-mark path {
  fill: none; stroke: currentColor; stroke-width: 3;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 46; stroke-dashoffset: 0;
}
@keyframes mark-draw { from { stroke-dashoffset: 46; } to { stroke-dashoffset: 0; } }
.btn:hover .icon-mark path, .btn:focus-visible .icon-mark path { animation: mark-draw var(--dur-icon) var(--ease-draw); }

/* Underline-draw text link */
.link-draw { position: relative; color: var(--color-primary); font-weight: 500; }
.link-draw::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-swap) var(--ease-out);
}
.link-draw:hover { color: var(--color-ink); text-decoration: none; }
.link-draw:hover::after, .link-draw:focus-visible::after { transform: scaleX(1); }

/* ─── Header + nav: logo and one action, nothing else ─── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--color-surface-tint);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-swap) var(--ease-inout);
}
.site-header.is-scrolled { border-bottom-color: var(--color-border); }
.site-header__inner {
  max-width: var(--page-max); margin: 0 auto;
  padding: 0 var(--container-pad);
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.site-header__brand { display: flex; align-items: center; padding-block: 0.65rem; }
.site-header__brand img { height: 26px; width: auto; }
.site-nav { display: flex; align-items: center; }
.nav-cta { min-height: 2.75rem; padding: 0 1rem; font-size: 0.875rem; gap: 0.4rem; }
.nav-cta .icon-tick { width: 17px; height: 17px; }
/* v2: the nav pill is teal always (peach retired), so it no longer needs to
   swap colour when an in-content CTA is visible. body.cta-visible (see
   site.js) now only governs the sticky mobile bar. */

@media (min-width: 720px) {
  .site-header__inner { height: var(--header-h-lg); gap: 1.5rem; }
  .site-header__brand img { height: 32px; }
  .nav-cta { min-height: 2.75rem; padding: 0 1.25rem; font-size: 0.9375rem; gap: 0.55rem; }
  .nav-cta .icon-tick { width: 20px; height: 20px; }
}

/* ─── Curl divider: the mark's stroke as a hand-off between fields ─── */
.curl-divider {
  position: absolute; left: 0; right: 0; top: 1px;
  display: block; width: 100%; height: clamp(38px, 5.5vw, 82px);
  transform: translateY(-100%);
  pointer-events: none;
}
.curl-divider--flip { transform: translateY(-100%) scaleX(-1); }
.curl-divider--dark path  { fill: var(--color-dark); }
.curl-divider--white path { fill: var(--color-surface-tint); }
.curl-divider--mist path  { fill: var(--color-surface); }
.curl-divider--cream path { fill: var(--color-paper); }

/* ─── The peek ───
   The whole master mark, never redrawn, rising over an edge and clipped by
   the container. Because the mark is a teal ring with a transparent opening,
   a cream disc sits behind the head so the face and eyes read on any field. */
.peek { position: absolute; width: 88px; height: 42px; pointer-events: none; overflow: hidden; }
.peek::after {
  content: ""; position: absolute; left: 5px; top: 13px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--color-paper);
}
.peek::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: url("/assets/images/symbol.svg") no-repeat -14px -21px / 110px 84.1px;
}

/* ─── Trust strip ─── */
.trust-strip {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0.5rem 1.5rem;
  font-size: 0.875rem; color: var(--color-muted);
}
.trust-strip li { display: flex; align-items: center; gap: 0.5rem; }
.trust-strip li::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--color-accent-2);
}

/* ─── Sticky mobile CTA bar ─── */
.sticky-cta {
  position: fixed; inset: auto 0 0; z-index: 45;
  display: flex; padding: 0.625rem 1rem calc(0.625rem + env(safe-area-inset-bottom));
  background: var(--color-surface-tint);
  border-top: 1px solid var(--color-border);
  translate: 0 100%;
  transition: translate var(--dur-swap) var(--ease-out);
}
.sticky-cta .btn { flex: 1; }
.sticky-cta.is-on { translate: 0 0; transition-duration: var(--dur-peek); }
@media (min-width: 768px) { .sticky-cta { display: none; } }

/* ─── Footer: the illustration with an info card over it, site-wide ─── */
.site-footer {
  position: relative; isolation: isolate;
  background: var(--color-surface-tint);
  padding-top: clamp(5rem, 20vw, 16rem);
}
/* Bottom aligned and sized to the full width, so the illustration's flat white
   sky sits at the top of the footer and dissolves into the page above. */
.site-footer__scene {
  position: absolute; inset: 0; z-index: -1; display: block;
  background: url("/assets/images/illustration-centre.webp") no-repeat 50% 100% / 100% auto;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 14%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 14%);
}
.site-footer__inner {
  max-width: var(--page-max); margin: 0 auto;
  padding: 0 var(--container-pad) clamp(2rem, 5vw, 3rem);
}
.site-footer__card {
  position: relative;
  background: var(--color-surface-tint);
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 4vw, 2.75rem);
  display: grid; gap: 2rem;
}
.site-footer__card > .peek { top: -41px; right: clamp(1.5rem, 6vw, 4rem); width: 54px; }
.site-footer__brand img { height: 30px; width: auto; }
.site-footer__brand p { margin: 1rem 0 0; max-width: 34ch; font-size: 0.9375rem; color: var(--color-muted); }
.site-footer__col h2 {
  font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--color-muted); margin-bottom: 0.75rem; font-weight: 600;
}
.site-footer__col ul { list-style: none; margin: 0; padding: 0; }
.site-footer__col a { display: inline-block; padding-block: 0.4rem; font-size: 0.9375rem; }
.site-footer__tagline {
  grid-column: 1 / -1;
  font-family: var(--font-heading); font-weight: 600;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
  color: var(--color-primary); margin: 0;
}
.site-footer__legal {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 0.5rem 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem; color: var(--color-muted);
}
.site-footer__legal p { margin: 0; }
@media (min-width: 800px) {
  .site-footer__card { grid-template-columns: 1.6fr 1fr 1fr; gap: 2.5rem 3rem; }
}

/* ─── Breadcrumbs ─── */
.crumbs { font-size: 0.875rem; color: var(--color-muted); margin: 0 0 1.5rem; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; }
.crumbs li + li::before { content: "/"; margin-right: 0.5rem; color: var(--color-border); }
.crumbs a { color: var(--color-primary); }

/* ─── Legal / prose pages ─── */
.doc { max-width: 68ch; }
.doc h2 { margin-top: 2.5rem; font-size: 1.5rem; }
.doc h3 { margin-top: 1.75rem; font-size: 1.15rem; }
.doc ul { padding-left: 1.15rem; }
.doc li { margin-bottom: 0.5rem; }
.doc__updated { font-size: 0.875rem; color: var(--color-muted); }

/* ─── Entrance system ─── */
.js [data-enter]:not(.is-in) { opacity: 0; }
.js [data-enter="rise"]:not(.is-in) { translate: 0 var(--dist-enter); }
.js [data-enter="drop"]:not(.is-in) { clip-path: inset(0 0 100% 0 round var(--radius-lg)); opacity: 1; }
[data-enter] {
  transition: opacity var(--dur-enter) var(--ease-out),
              translate var(--dur-enter) var(--ease-out),
              clip-path var(--dur-enter) var(--ease-out);
  transition-delay: var(--enter-delay, 0ms);
}
[data-enter="drop"] { clip-path: inset(0 round var(--radius-lg)); }

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .js [data-enter]:not(.is-in) { opacity: 1; clip-path: none; translate: none; }
}
