/* Shared styles for the public pages (landing, buy, checkout, AML, 404).
   Colors, radii and sizes come from tokens.css. */

:root {
  /* Derived from the tokens (not new colors): hover states and loading placeholders. */
  --color-hover-bg: color-mix(in srgb, var(--color-field-muted) 50%, var(--color-surface));
  --color-border-hover: color-mix(in srgb, var(--color-border) 70%, var(--color-text-subtle));
  --color-primary-hover: color-mix(in srgb, var(--color-primary) 84%, var(--color-surface));
  /* Darker variants of the status tokens for small text on white: the tokens themselves are
     below the 4.5:1 WCAG AA contrast ratio (danger 3.9, warning 3.6, success 2.7). */
  --color-danger-text: color-mix(in srgb, var(--color-danger) 78%, var(--color-text));
  --color-warning-text: color-mix(in srgb, var(--color-warning) 80%, var(--color-text));
  --color-success-text: color-mix(in srgb, var(--color-success) 70%, var(--color-text));
  --page-gutter: 16px;
  color-scheme: light;
}

/* ---- reset ------------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px var(--page-gutter) 40px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

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

button,
input,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---- focus ------------------------------------------------------------------------------- */

:focus-visible {
  /* Transparent outline keeps a visible indicator in forced-colors mode. */
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

/* Headings focused programmatically after a screen change don't need a ring. */
[tabindex='-1']:focus {
  outline: none;
  box-shadow: none;
}

/* ---- utilities --------------------------------------------------------------------------- */

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

.muted {
  color: var(--color-text-muted);
}

.copy-buffer {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* Icon parts drawn in the color of the surface behind the icon (the "!" of the info icon,
   the envelope flap, the fold of the paper plane). */
.icon-cut {
  fill: var(--icon-cut, var(--color-surface));
}

.icon-cut[fill='none'] {
  fill: none;
  stroke: var(--icon-cut, var(--color-surface));
}

/* ---- layout ------------------------------------------------------------------------------ */

main,
.site-footer {
  width: 100%;
  max-width: var(--card-width);
}

.card {
  position: relative; /* dropdown panels may extend past the bottom edge — no overflow clipping */
  width: 100%;
  padding: var(--card-padding);
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.noscript {
  color: var(--color-text-muted);
}

/* ---- typography helpers ------------------------------------------------------------------ */

.checkout-meta {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 20px;
  overflow-wrap: anywhere;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 20px;
}

/* ---- buttons ----------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--button-height);
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.btn .icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-border-strong);
}

.btn:disabled {
  background: var(--color-disabled-bg);
  border-color: transparent;
  color: var(--color-disabled-text);
  cursor: not-allowed;
}

.btn[aria-busy='true'] {
  cursor: progress;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 40px;
  padding: 0 16px;
  font-size: var(--text-sm);
}

/* Text-style button ("Change"). */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover:not(:disabled) {
  background: var(--color-hover-bg);
}

.link-btn:disabled {
  color: var(--color-text-muted);
  cursor: progress;
}

.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- form controls ----------------------------------------------------------------------- */

.field + .field {
  margin-top: 16px;
}

.input {
  display: block;
  width: 100%;
  height: var(--control-height);
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  font-size: var(--text-md); /* 16px keeps iOS from zooming in */
  font-weight: 500;
  transition: border-color 0.15s ease;
}

.input::placeholder {
  color: var(--color-placeholder);
  font-weight: 400;
  opacity: 1;
}

.input:hover {
  border-color: var(--color-border-hover);
}

.input:focus {
  border-color: var(--color-border-strong);
}

.input[aria-invalid='true'] {
  border-color: var(--color-danger);
}

.field-help {
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 18px;
}

.field-error,
.form-error {
  margin-top: 8px;
  color: var(--color-danger-text);
  font-size: var(--text-sm);
  line-height: 20px;
}

.form-message:empty {
  display: none;
}

.form-message {
  margin-top: 8px;
  font-size: var(--text-sm);
  line-height: 20px;
}

.form-message.is-error {
  color: var(--color-danger-text);
}

.form-message.is-info {
  color: var(--color-warning-text);
}

.form-message.is-success {
  color: var(--color-success-text);
}

/* ---- pills ------------------------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.pill .icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* "You pay network fee": 173×28px in the reference, with a 14px icon 9px from the left edge. */
.pill-info {
  padding: 0 8px 0 9px;
  background: var(--color-info-bg);
  color: var(--color-info); /* the "!" inside the icon stays white (.icon-cut default) */
}

.pill-info .icon {
  width: 14px;
  height: 14px;
}

/* "Popular choice": 120×24px in the reference. */
.pill-success {
  height: 24px;
  padding: 0 11px;
  background: var(--color-success-bg);
  color: var(--color-success);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ---- result screens (paid, expired, not found…) ------------------------------------------ */

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.result-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  border-radius: 50%;
}

.result-icon .icon {
  width: 28px;
  height: 28px;
}

.result-icon.is-success {
  background: var(--color-success);
  color: var(--color-primary-text);
}

.result-icon.is-muted {
  background: var(--color-field-muted);
  color: var(--color-text-muted);
}

.result-icon.is-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.result-title {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 28px;
}

.result-text {
  max-width: 400px;
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 15px;
  line-height: 22px;
}

.result-text strong {
  color: var(--color-text);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.result > .btn {
  margin-top: 24px;
}

/* ---- skeleton ---------------------------------------------------------------------------- */

.skeleton {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(
      90deg,
      transparent 0%,
      color-mix(in srgb, var(--color-surface) 65%, transparent) 50%,
      transparent 100%
    )
    0 0 / 200% 100% no-repeat,
    var(--color-divider);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 150% 0, 0 0;
  }
  to {
    background-position: -50% 0, 0 0;
  }
}

.skeleton-stack {
  display: grid;
  gap: 12px;
}

.sk-meta {
  width: 45%;
  height: 16px;
}

.sk-title {
  width: 42%;
  height: 38px;
}

.sk-pills {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 8px;
}

.sk-pill {
  width: 170px;
  height: 30px;
  border-radius: var(--radius-pill);
}

.sk-pill + .sk-pill {
  width: 150px;
  border-radius: var(--radius-sm);
}

.sk-label {
  width: 72px;
  height: 16px;
  margin-top: 8px;
}

.sk-field {
  height: var(--control-height);
  border-radius: var(--radius-lg);
}

.sk-button {
  height: var(--button-height);
  margin-top: 12px;
  border-radius: var(--radius-md);
}

/* ---- footer ------------------------------------------------------------------------------ */

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 20px;
  text-align: center;
}

.footer-link {
  border-radius: 4px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-link:hover {
  color: var(--color-text);
}

.contact-links {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.contact-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-primary-text);
  transition: background-color 0.15s ease;
  --icon-cut: var(--color-primary);
}

.contact-btn:hover {
  background: var(--color-primary-hover);
  --icon-cut: var(--color-primary-hover);
}

.contact-btn .icon {
  width: 17px;
  height: 17px;
}

/* ---- small screens ----------------------------------------------------------------------- */

@media (max-width: 520px) {
  body {
    padding-top: 16px;
    padding-bottom: 32px;
  }

  .card {
    padding: 24px 20px;
    border-radius: 24px;
  }
}

/* ---- motion ------------------------------------------------------------------------------ */

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