/*
 * Cardelli Plugins.
 *
 * Dark by default — these pages sit next to a DAW, and every plugin host is
 * dark. `prefers-color-scheme: light` is honoured for people who ask for it.
 *
 * Layout is CSS: grid for the product cards, flex for rows. State that CSS can
 * express — loading, empty, disabled, current page, status colour — is driven
 * from an attribute here rather than by JavaScript writing inline styles.
 */

:root {
  color-scheme: dark;

  --bg: #0b0d10;
  --bg-raised: #14171c;
  --bg-sunken: #07080a;
  --line: #262b33;
  --line-strong: #39404b;

  --text: #e8eaed;
  --text-dim: #9aa3af;
  --text-faint: #6b7480;

  --accent: #ff7a45;
  --accent-hover: #ff8f61;
  --accent-ink: #1a0d06;
  --focus: #7cc4ff;

  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;

  --radius: 10px;
  --radius-lg: 16px;
  --measure: 68ch;
  --gutter: clamp(1rem, 4vw, 2.5rem);

  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #fbfbfa;
    --bg-raised: #ffffff;
    --bg-sunken: #f1f1ef;
    --line: #e2e2df;
    --line-strong: #c8c8c3;
    --text: #16181c;
    --text-dim: #565c66;
    --text-faint: #838a94;
    --accent: #d24a13;
    --accent-hover: #b83d0c;
    --accent-ink: #ffffff;
    --focus: #0b62c4;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 1rem;
  max-width: var(--measure);
  text-wrap: pretty;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

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

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

code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
}

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

.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.6rem 1rem;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

section {
  padding-block: clamp(2.5rem, 7vw, 4.5rem);
  border-top: 1px solid var(--line);
}

section:first-of-type {
  border-top: 0;
}

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

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  font-size: 1rem;
  font-weight: 620;
  letter-spacing: 0.01em;
  margin: 0;
}

.brand a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-mark {
  width: 1.4rem;
  height: 1.4rem;
  flex: none;
  color: var(--accent);
}

.nav-list {
  display: flex;
  gap: clamp(0.75rem, 3vw, 1.75rem);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.925rem;
}

.nav-list a {
  color: var(--text-dim);
  text-decoration: none;
}

.nav-list a:hover {
  color: var(--text);
}

.nav-list a[aria-current='page'] {
  color: var(--text);
  font-weight: 560;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2.5rem;
  color: var(--text-faint);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0 0 0.35rem;
}

.site-footer a {
  color: var(--text-dim);
}

/* --- hero --------------------------------------------------------------- */

.hero {
  padding-block: clamp(3rem, 10vw, 6rem);
}

.hero .lede {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-dim);
  max-width: 52ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.62rem 1.15rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 520;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    transform 0.06s ease;
}

.button:hover:not(:disabled) {
  border-color: var(--text-faint);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled,
.button[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  padding-inline: 0.5rem;
}

.button.ghost:hover:not(:disabled) {
  color: var(--text);
}

.button.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

/* A button waiting on the network stops accepting a second click. */
.button[data-busy='true'] {
  pointer-events: none;
  opacity: 0.7;
}

/* --- cards / product grid ----------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card h3 {
  margin-bottom: 0.35rem;
}

.card .card-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
  flex: 1;
}

.card-prices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.price-amount {
  font-size: 1.05rem;
  font-weight: 600;
}

.price-note {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-faint);
}

.card-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Loading and empty states are content, not spinners. */
.card.placeholder {
  color: var(--text-faint);
  justify-content: center;
  min-height: 8rem;
  border-style: dashed;
}

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

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.badge.neutral {
  background: var(--bg-sunken);
  color: var(--text-dim);
  border-color: var(--line);
}

.badge[data-status='active'],
.badge[data-status='paid'],
.badge[data-status='trialing'] {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 32%, transparent);
}

.badge[data-status='pending'],
.badge[data-status='past_due'] {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
}

.badge[data-status='canceled'],
.badge[data-status='refunded'],
.badge[data-status='revoked'],
.badge[data-status='expired'] {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

/* --- panels, forms, tables ---------------------------------------------- */

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 1.5rem;
}

.panel > :last-child {
  margin-bottom: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  max-width: 26rem;
}

label {
  font-size: 0.875rem;
  font-weight: 540;
}

input[type='email'],
input[type='text'] {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
}

input::placeholder {
  color: var(--text-faint);
}

.hint {
  color: var(--text-faint);
  font-size: 0.85rem;
}

.stack {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stack > li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  background: var(--bg-sunken);
}

.stack > li.muted {
  border-style: dashed;
  background: none;
  color: var(--text-faint);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  margin-bottom: 1rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  color: var(--text-dim);
  font-weight: 560;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Wide content scrolls inside its own box; the page never scrolls sideways. */
.table-scroll {
  overflow-x: auto;
}

/* --- license key -------------------------------------------------------- */

.license-key {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.license-key code {
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.06em;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  user-select: all;
  word-break: break-all;
}

/* --- status region ------------------------------------------------------ */

.status {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: 0.925rem;
}

.status[data-tone='error'] {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, var(--bg-raised));
}

.status[data-tone='success'] {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, var(--bg-raised));
}

/* --- steps -------------------------------------------------------------- */

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.steps > li {
  counter-increment: step;
}

.steps > li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.75rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--line-strong);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.steps h3 {
  margin-bottom: 0.25rem;
}

.steps p {
  color: var(--text-dim);
  font-size: 0.925rem;
  margin: 0;
}

/* --- misc --------------------------------------------------------------- */

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

.lede {
  color: var(--text-dim);
  font-size: 1.05rem;
}

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

/* --- pay what you want -------------------------------------------------- */

.pwyw {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.pwyw-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 560;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.pwyw-amount {
  display: block;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0.15rem 0 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* The suggested figure is highlighted until the visitor moves off it. */
.pwyw[data-suggested='true'] .pwyw-amount {
  color: var(--accent);
}

.pwyw-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pwyw-slider {
  flex: 1 1 12rem;
  min-width: 8rem;
  accent-color: var(--accent);
  height: 1.75rem;
  cursor: pointer;
}

.pwyw-or {
  color: var(--text-faint);
  font-size: 0.85rem;
}

.pwyw-dollar {
  color: var(--text-dim);
  margin-right: -0.35rem;
}

.pwyw-exact {
  width: 5.5rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.pwyw-hint {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin: 0.75rem 0 1rem;
}

.pwyw .button {
  width: 100%;
}
