/* ==========================================================================
   Terrapin brand stylesheet for landing pages
   --------------------------------------------------------------------------
   Ported from the Terrapin design system used on tryterrapin.com and the
   mobile app. Aesthetic: calm, premium fintech trust, one violet accent.

   USAGE
     <link rel="stylesheet" href="/assets/css/terrapin.css">

   RULES OF THE ROAD
     - Use the CSS variables below. Do not hard-code hex colours.
     - `--primary` is the ONLY marketing accent. `--gold` is reserved for
       investor/premium surfaces and is intentionally out of scope here.
     - Dark mode is automatic (prefers-color-scheme). Every colour you use
       must come from a token so it flips correctly.
     - Typography is the native OS font stack. Do not add web fonts: they
       cost a render-blocking round trip and landing page speed is revenue.

   This file is owned by Terrapin. If you need a token that does not exist,
   open an issue rather than overriding one locally.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Typography — native stack, zero web-font downloads */
  --font-display: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Base scale — warm neutral with a faint violet undertone */
  --background: 240 20% 96%;
  --foreground: 240 10% 4%;

  --card: 0 0% 100%;
  --card-foreground: 240 10% 4%;

  --surface-1: 240 18% 93%;
  --surface-2: 240 14% 90%;
  --surface-3: 240 12% 87%;

  /* Brand — single violet accent, aligned to the mobile app (#7752BA) */
  --primary: 262 40% 53%;
  --primary-foreground: 240 37% 98%;
  --accent-muted: 276 78% 95%;

  --secondary: 240 16% 92%;
  --secondary-foreground: 240 12% 14%;

  --muted: 240 16% 92%;
  --muted-foreground: 240 6% 32%;
  --muted-foreground-dim: 240 4% 46%;

  --destructive: 0 72% 45%;
  --destructive-foreground: 0 0% 100%;
  --success: 156 100% 26%;
  --success-foreground: 146 26% 97%;
  --warning: 27 94% 50%;
  --warning-foreground: 24 39% 13%;

  --border: 240 8% 82%;
  --border-subtle: 240 8% 88%;
  --input: 240 8% 80%;
  --ring: 262 40% 53%;

  --radius: 0.75rem;

  /* Gradient end-stop tuned for AA contrast in light mode */
  --gradient-accent-end: 280 38% 46%;
  --gradient-primary: linear-gradient(135deg, hsl(262 40% 53%), hsl(274 36% 46%));
  --gradient-radial-glow: radial-gradient(ellipse at 50% 0%, hsl(262 40% 53% / 0.07) 0%, transparent 55%);

  /* Multi-layer shadow scale */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0.5px 1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.03), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.03), 0 8px 16px rgba(0, 0, 0, 0.04), 0 16px 32px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.04), 0 16px 32px rgba(0, 0, 0, 0.05), 0 24px 48px rgba(0, 0, 0, 0.03);

  /* Material — translucent chrome */
  --material-thick-bg: rgba(255, 255, 255, 0.78);
  --material-thick-blur: blur(24px) saturate(160%);
  --material-border: rgba(0, 0, 0, 0.06);

  /* Motion */
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;

  /* Layout rhythm */
  --container-max: 1120px;
  --section-y: clamp(3.5rem, 8vw, 7rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 251 60% 3%;
    --foreground: 249 14% 92%;

    --card: 254 43% 8%;
    --card-foreground: 249 14% 92%;

    --surface-1: 253 35% 10%;
    --surface-2: 253 31% 13%;
    --surface-3: 253 28% 15%;

    /* Lavender step-up for dark, aligned to the mobile app (#A688DD) */
    --primary: 262 56% 70%;
    --primary-foreground: 251 60% 3%;
    --accent-muted: 262 24% 27%;

    --secondary: 253 31% 13%;
    --secondary-foreground: 249 14% 92%;

    --muted: 253 31% 13%;
    --muted-foreground: 250 6% 62%;
    --muted-foreground-dim: 250 5% 52%;

    --destructive: 360 76% 67%;
    --success: 158 100% 34%;
    --success-foreground: 147 53% 4%;
    --warning: 26 90% 62%;
    --warning-foreground: 25 59% 8%;

    --border: 253 25% 16%;
    --border-subtle: 253 30% 10%;
    --input: 253 25% 16%;
    --ring: 262 56% 70%;

    --gradient-accent-end: 280 52% 74%;
    --gradient-primary: linear-gradient(135deg, hsl(262 56% 70%), hsl(280 52% 74%));
    --gradient-radial-glow: radial-gradient(ellipse at 50% 0%, hsl(262 56% 70% / 0.10) 0%, transparent 55%);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22), 0 0.5px 1px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.18), 0 4px 8px rgba(0, 0, 0, 0.22);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.18), 0 8px 16px rgba(0, 0, 0, 0.22), 0 16px 32px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.22), 0 16px 32px rgba(0, 0, 0, 0.25), 0 24px 48px rgba(0, 0, 0, 0.18);

    --material-thick-bg: rgba(30, 20, 60, 0.78);
    --material-thick-blur: blur(32px) saturate(160%);
    --material-border: rgba(180, 160, 255, 0.10);
  }
}

/* --------------------------------------------------------------------------
   2. Reset + base
   -------------------------------------------------------------------------- */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-body);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; height: auto; }

a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 4px);
}

/* Skip link — keyboard users land here first */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
  font-weight: 700;
}

h1 { font-size: clamp(2.25rem, 5.5vw, 3.75rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.75rem, 3.5vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }
h4 { font-size: 1.0625rem; }

p { text-wrap: pretty; }

.lead {
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  color: hsl(var(--muted-foreground));
  line-height: 1.6;
}

.eyebrow {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--primary));
}

.text-muted { color: hsl(var(--muted-foreground)); }
.text-dim { color: hsl(var(--muted-foreground-dim)); }
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.fine-print {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: hsl(var(--muted-foreground-dim));
}

/* --------------------------------------------------------------------------
   4. Layout
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.container-narrow { max-width: 720px; }

.section { padding-block: var(--section-y); }
.section-sm { padding-block: calc(var(--section-y) * 0.6); }

.section-alt { background-color: hsl(var(--surface-1)); }

.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 2rem; }

.center { text-align: center; }
.center .lead, .center p { margin-inline: auto; }
.center .container-narrow { margin-inline: auto; }

.grid { display: grid; gap: clamp(1rem, 2.5vw, 1.75rem); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.center .cluster { justify-content: center; }

/* --------------------------------------------------------------------------
   5. Header + footer
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--material-thick-bg);
  backdrop-filter: var(--material-thick-blur);
  -webkit-backdrop-filter: var(--material-thick-blur);
  border-bottom: 1px solid var(--material-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
}

/* The logo is a horizontal wordmark (1200×327) and already contains the word
   "Terrapin" — don't set type next to it. Height is fixed and width follows,
   so the lockup can never be stretched. */
.brand {
  display: inline-flex;
  align-items: center;
  color: hsl(var(--foreground));
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand img { height: 1.75rem; width: auto; }

/* There is a black wordmark and a white one. Show whichever has contrast
   against the current background. */
.brand .logo-light { display: block; }
.brand .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .brand .logo-light { display: none; }
  .brand .logo-dark { display: block; }
}

.site-footer {
  border-top: 1px solid hsl(var(--border-subtle));
  padding-block: 2.5rem;
  background-color: hsl(var(--surface-1));
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  list-style: none;
  padding: 0;
}
.footer-links a {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}
.footer-links a:hover { color: hsl(var(--foreground)); }

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8125rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-normal) var(--ease-spring),
              background-color var(--duration-fast) ease,
              opacity var(--duration-fast) ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--gradient-primary);
  color: hsl(var(--primary-foreground));
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { box-shadow: var(--shadow-lg); }

.btn-secondary {
  background-color: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background-color: hsl(var(--surface-1)); }

.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover { background-color: hsl(var(--surface-2)); }

.btn-lg { padding: 1rem 2rem; font-size: 1.0625rem; }
.btn-block { width: 100%; }

/* --------------------------------------------------------------------------
   7. Cards + surfaces
   -------------------------------------------------------------------------- */

.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border-subtle));
  border-radius: calc(var(--radius) + 4px);
  padding: clamp(1.25rem, 3vw, 1.75rem);
  box-shadow: var(--shadow-sm);
}

.card-feature { display: flex; flex-direction: column; gap: 0.625rem; }
.card-feature h3 { font-size: 1.125rem; }
.card-feature p { color: hsl(var(--muted-foreground)); font-size: 0.9375rem; }

.card-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.25rem;
  border-radius: calc(var(--radius) - 2px);
  background-color: hsl(var(--accent-muted));
  color: hsl(var(--primary));
  font-size: 1.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.75rem;
  border-radius: 999px;
  background-color: hsl(var(--accent-muted));
  color: hsl(var(--primary));
  font-size: 0.8125rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   8. Hero
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  padding-block: clamp(3rem, 7vw, 6rem) var(--section-y);
  background-image: var(--gradient-radial-glow);
  overflow: hidden;
}

.hero .container { position: relative; }
.hero h1 { margin-bottom: 1rem; }
.hero .lead { max-width: 44ch; }
.hero .cluster { margin-top: 2rem; }

/* --------------------------------------------------------------------------
   9. App store badges
   -------------------------------------------------------------------------- */

.store-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.center .store-badges { justify-content: center; }

.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.6875rem 1.125rem;
  border-radius: var(--radius);
  background-color: hsl(var(--foreground));
  color: hsl(var(--background));
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-normal) var(--ease-spring);
}
.store-badge:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.store-badge svg { width: 1.5rem; height: 1.5rem; flex: none; fill: currentColor; }
.store-badge span { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.store-badge .store-badge-sub { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.8; }
.store-badge .store-badge-name { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }

/* --------------------------------------------------------------------------
   10. Social proof
   -------------------------------------------------------------------------- */

.quote {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}
.quote blockquote { font-size: 1.0625rem; line-height: 1.55; }
.quote figcaption {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: auto;
}
.stars { color: hsl(var(--warning)); letter-spacing: 0.1em; font-size: 0.9375rem; }

.stat { text-align: center; }
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat-label { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }

/* --------------------------------------------------------------------------
   11. FAQ
   -------------------------------------------------------------------------- */

.faq { border-top: 1px solid hsl(var(--border-subtle)); }
.faq details {
  border-bottom: 1px solid hsl(var(--border-subtle));
  padding-block: 1.125rem;
}
.faq summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  flex: none;
  font-size: 1.25rem;
  font-weight: 400;
  color: hsl(var(--muted-foreground));
  transition: transform var(--duration-normal) var(--ease-spring);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin-top: 0.75rem; color: hsl(var(--muted-foreground)); }

/* --------------------------------------------------------------------------
   12. Forms
   -------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 0.375rem; text-align: left; }
.field label { font-size: 0.875rem; font-weight: 600; }

.input {
  width: 100%;
  padding: 0.8125rem 1rem;
  font: inherit;
  font-size: 1rem;
  color: hsl(var(--foreground));
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
}
.input::placeholder { color: hsl(var(--muted-foreground-dim)); }

/* --------------------------------------------------------------------------
   13. Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-6 { margin-top: 3rem; }
