/* Paymata landing: reset, type, layout, shared controls. */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) var(--ground);
}

body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  caret-color: var(--accent);
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
ul, ol { padding: 0; list-style: none; }

::selection { background: var(--accent); color: var(--ink-on-accent); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: var(--ground-3); border-radius: 8px; border: 3px solid var(--ground); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

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

.icon { width: 1.25em; height: 1.25em; flex: none; stroke-width: 1.5; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); font-size: 0.875em; letter-spacing: 0; }

/* Type */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; text-wrap: balance; }
h1 {
  font-size: clamp(3rem, 1.4rem + 6vw, 5.75rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
}
h2 {
  font-size: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}
h3 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem); line-height: 1.15; letter-spacing: -0.015em; }
p { text-wrap: pretty; }
.lede { font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem); color: var(--text-dim); max-width: 56ch; line-height: 1.55; }
.dim { color: var(--text-dim); }
.accent { color: var(--accent-text); }

/* Layout */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section-y); position: relative; }
.sec-head { display: grid; gap: 1.25rem; max-width: 46rem; margin-bottom: clamp(2rem, 5vw, 4rem); }
.sec-head h2 { max-width: 20ch; }

/* Cloth: decorative motif layers. Colour comes from the element, shape from --motif. */
.cloth {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: var(--motif-ink);
  -webkit-mask-image: var(--motif), var(--fade, linear-gradient(#000, #000));
  mask-image: var(--motif), var(--fade, linear-gradient(#000, #000));
  -webkit-mask-size: var(--tile-w) var(--tile-h), 100% 100%;
  mask-size: var(--tile-w) var(--tile-h), 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  mask-repeat: repeat, no-repeat;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.m-rings { --motif: url("../motifs/p-grid.svg"); --tile-w: 112px; --tile-h: 144px; }
.m-checks { --motif: url("../motifs/p-checks.svg"); --tile-w: 136px; --tile-h: 168px; }
.m-stitch { --motif: url("../motifs/p-stitch.svg"); --tile-w: 64px; --tile-h: 64px; }
.m-diamond { --motif: url("../motifs/p-diamond.svg"); --tile-w: 140px; --tile-h: 140px; }
.m-scales { --motif: url("../motifs/p-scales.svg"); --tile-w: 72px; --tile-h: 72px; }
.cloth.is-bright { background-color: var(--line-strong); }

/* A hem is a thin strip of repeating motif that separates sections. */
.hem {
  height: 32px;
  position: relative;
  color: var(--text);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 900ms var(--ease-in-out);
}
.hem .cloth { background-color: var(--line-strong); }
/* Section hems keep the original woven-border motifs; the P is used for backgrounds. */
.hem .m-scales { --motif: url("../motifs/hem-scales.svg"); --tile-w: 32px; --tile-h: 16px; }
.hem .m-stitch { --motif: url("../motifs/hem-stitch.svg"); --tile-w: 28px; --tile-h: 28px; }
.hem .m-diamond { --motif: url("../motifs/hem-diamond.svg"); --tile-w: 40px; --tile-h: 40px; }
.hem.is-in, .no-js .hem { clip-path: inset(0 0 0 0); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.625rem;
  min-height: 48px; padding: 0 1.375rem; border-radius: var(--r-ctl);
  font-weight: 600; font-size: 1rem; line-height: 1; white-space: nowrap; text-decoration: none;
  border: 1px solid transparent;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease, border-color var(--t-hover) ease, color var(--t-hover) ease;
}
.btn[hidden] { display: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--ink-on-accent); }
.btn-ghost { border-color: var(--line-strong); color: var(--text); }
.btn-sm { min-height: 40px; padding: 0 1rem; font-size: 0.9375rem; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-ghost:hover { border-color: var(--text); }
}

/* Store buttons */
.stores { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.store {
  display: inline-flex; align-items: center; gap: 0.75rem; min-height: 56px; padding: 0 1.25rem 0 1rem;
  border-radius: var(--r-ctl); background: var(--accent); color: var(--ink-on-accent); text-decoration: none; text-align: left;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease;
}
.store .icon { width: 1.75rem; height: 1.75rem; }
.store small { display: block; font-size: 0.75rem; line-height: 1.1; font-weight: 500; opacity: 0.8; }
.store strong { display: block; font-size: 1.0625rem; line-height: 1.15; font-weight: 700; }
.store:active { transform: scale(0.97); }
.store.is-pending { cursor: default; }
.store.is-pending:active { transform: none; }
@media (hover: hover) and (pointer: fine) { a.store:hover { background: var(--accent-hover); } }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 36px; padding: 0 0.875rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill); font-size: 0.9375rem; color: var(--text);
  background: transparent;
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
button.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--text); color: var(--ground); border-color: var(--text); }

/* Form controls */
.field { display: grid; gap: 0.5rem; }
.field > label { font-size: 0.875rem; color: var(--text-dim); font-weight: 500; }
.input {
  width: 100%; min-height: 52px; padding: 0 1rem; border-radius: var(--r-ctl);
  background: var(--ground); border: 1px solid var(--line-strong); color: var(--text);
  transition: border-color var(--t-hover) ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* Scroll reveal. Content stays visible without JS. */
.js [data-reveal] { opacity: 0; transform: translateY(16px); filter: blur(2px); }
.js [data-reveal].is-in {
  opacity: 1; transform: none; filter: none;
  transition: opacity var(--t-enter) var(--ease-out) calc(var(--i, 0) * 60ms),
              transform var(--t-enter) var(--ease-out) calc(var(--i, 0) * 60ms),
              filter var(--t-enter) var(--ease-out) calc(var(--i, 0) * 60ms);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; filter: none; }
  .hem { clip-path: none; transition: none; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Theme toggle */
.theme-toggle { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-ctl); color: var(--text-dim); transition: color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle .icon { width: 1.4rem; height: 1.4rem; grid-area: 1 / 1; }
.theme-toggle .i-moon, .theme-toggle[data-mode="light"] .i-sun { display: none; }
.theme-toggle[data-mode="light"] .i-moon { display: block; }
@media (hover: hover) and (pointer: fine) { .theme-toggle:hover { color: var(--text); } }

/* Back to top */
.to-top {
  position: fixed; right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 3vw, 32px); z-index: 38;
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--r-pill);
  background: var(--accent); color: var(--ink-on-accent); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(0.95);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
.to-top .icon { width: 1.4rem; height: 1.4rem; transform: rotate(-90deg); }
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.to-top.is-visible:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) { .to-top.is-visible:hover { background: var(--accent-hover); } }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 40; height: var(--nav-h);
  background: var(--ground); border-bottom: 1px solid transparent;
  transition: border-color var(--t-hover) ease;
}
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.625rem; font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; letter-spacing: -0.03em; text-decoration: none; }
.brand-logo { height: 32px; width: auto; max-width: 180px; object-fit: contain; }
/* Dark mode shows the dark logo, light mode the light one; mirrors the token rules in tokens.css. */
.brand-logo--light { display: none; }
:root[data-theme="light"] .brand-logo--dark { display: none; }
:root[data-theme="light"] .brand-logo--light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .brand-logo--dark { display: none; }
  :root:not([data-theme="dark"]) .brand-logo--light { display: block; }
}
.brand-mark { width: 20px; height: 28px; color: var(--text); }
.nav-links { display: none; gap: 0.25rem; }
.nav-links a { padding: 0.5rem 0.75rem; border-radius: 8px; text-decoration: none; color: var(--text-dim); font-size: 0.9375rem; font-weight: 500; transition: color var(--t-hover) ease; }
@media (hover: hover) and (pointer: fine) { .nav-links a:hover { color: var(--text); } }
.nav-actions { display: flex; align-items: center; gap: 0.5rem; }
.nav-toggle { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-ctl); }
.nav-toggle .icon { width: 1.5rem; height: 1.5rem; }
.nav-toggle .i-x { display: none; }
.nav-toggle[aria-expanded="true"] .i-x { display: block; }
.nav-toggle[aria-expanded="true"] .i-menu { display: none; }
.nav-sheet {
  position: fixed; inset: var(--nav-h) 0 0 0; z-index: 39; background: var(--ground); padding: 1.5rem var(--gutter) 2rem;
  display: grid; align-content: start; gap: 0.25rem; overflow-y: auto;
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
.nav-sheet.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.nav-sheet a { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; text-decoration: none; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
@media (min-width: 1024px) {
  .nav-links { display: flex; }
  .nav-toggle, .nav-sheet { display: none; }
}
@media (max-width: 1023px) { .nav-actions .btn { display: none; } }
