/*
 * The style of the service's pages, the same as croon.dev's: its tokens,
 * type ramp, pill buttons, and wordmark (from the website's
 * app/assets/scss, with its fluid sizes written out as clamp()). Inter and
 * JetBrains Mono are self-hosted, under the SIL Open Font License 1.1.
 */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
}

@font-face {
  font-family: 'JetBrains Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
  --color-text: #111111;
  --color-text-muted: #62625e;
  --color-background: #ffffff;
  --color-surface: #f7f7f6;
  --color-border: #e2e2df;
  --color-accent: #111111;
  --color-accent-hover: #2b2b29;
  --color-on-accent: #ffffff;
  --color-success: #047857;
  --color-success-fill: #10b981;
  --color-success-soft: #d1fae5;
  --color-warning: #c2410c;
  --color-warning-soft: #ffedd5;
  --color-danger: #c93838;
  --color-danger-soft: rgb(201 56 56 / 10%);

  --font-primary: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono Variable', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --space-2: clamp(0.8rem, 0.6961rem + 0.2625vw, 1.2rem);
  --space-3: clamp(1.2rem, 1.0961rem + 0.2625vw, 1.6rem);
  --space-4: clamp(1.6rem, 1.3921rem + 0.5249vw, 2.4rem);
  --space-6: clamp(2.4rem, 2.0882rem + 0.7874vw, 3.6rem);
  --space-8: clamp(3.2rem, 2.7843rem + 1.0499vw, 4.8rem);
  --space-12: clamp(4.8rem, 4.1764rem + 1.5748vw, 7.2rem);
  --space-16: clamp(6.4rem, 5.5685rem + 2.0997vw, 9.6rem);

  --radius-pill: 10rem;
  --border-width: 0.1rem;
  --duration-fast: 0.2s;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);

  --max-width: 179.2rem;
  --header-height: clamp(6.4rem, 5.5685rem + 2.0997vw, 9.6rem);
  --button-height: clamp(4.4rem, 3.9843rem + 1.0499vw, 6rem);
  --page-margin: clamp(2rem, 0.8567rem + 2.8871vw, 6.4rem);
}

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

html {
  font-size: 62.5%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-primary);
  font-size: clamp(1.5rem, 1.3701rem + 0.3281vw, 2rem);
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
p {
  margin: 0;
}

h1 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
}

/* As on croon.dev: the bar stays at the top on a translucent, blurred
   background over a line; scrolling down hides it and scrolling up brings
   it back (pages.js). */
.header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: var(--border-width) solid var(--color-border);
  background: color-mix(in srgb, var(--color-background) 80%, transparent);
  backdrop-filter: blur(16px);
  transition: transform 0.6s cubic-bezier(0.7, 0, 0.2, 1);
}

.header--hidden {
  transform: translateY(-100%);
}

.header__bar,
.page,
.footer {
  width: 100%;
  max-width: calc(var(--max-width) + var(--page-margin) * 2);
  margin: 0 auto;
  padding: 0 var(--page-margin);
}

.header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--header-height);
}

.logo {
  font-size: clamp(2.4rem, 2.0882rem + 0.7874vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  text-decoration: none;
}

.page {
  flex: 1;
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

.page__label,
.footer {
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 1.022rem + 0.1969vw, 1.4rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

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

.page__title {
  max-width: 14ch;
  margin-top: var(--space-6);
  font-size: clamp(3.6rem, 2.1969rem + 3.5433vw, 9rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.page__body {
  display: grid;
  gap: var(--space-4);
  max-width: 72rem;
  margin-top: var(--space-8);
}

/* Two columns of six: the title and what goes with it stay in view on the
   left while the content scrolls on the right; one column on a phone. */
.page--split {
  /* The same space above the title as the sticky column keeps under the
     header, so it does not jump when the page starts to scroll. */
  padding-top: var(--space-8);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
  align-items: start;
}

.page--split .page__head {
  position: sticky;
  top: calc(var(--header-height) + var(--space-8));
}

.page--split .page__body {
  max-width: none;
  margin-top: var(--space-6);
}

.page__side {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.page__side .actions {
  margin-top: 0;
}

@media (max-width: 1100px) {
  .page--split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-8);
  }

  .page--split .page__head {
    position: static;
  }
}

.lead {
  font-size: clamp(1.8rem, 1.5402rem + 0.6562vw, 2.8rem);
  line-height: 1.3;
  letter-spacing: -0.015em;
}

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

.price {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-6) 0;
  border-top: var(--border-width) solid var(--color-border);
  border-bottom: var(--border-width) solid var(--color-border);
}

.price__amount {
  font-size: clamp(3.6rem, 2.1969rem + 3.5433vw, 9rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.checks {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.checks li {
  position: relative;
  padding-left: var(--space-6);
}

/* A short rule before each item, like the website's lists. */
.checks li::before {
  content: '';
  position: absolute;
  top: 0.75em;
  left: 0;
  width: var(--space-3);
  height: var(--border-width);
  background: var(--color-text);
}

/* A license's state badge with the action that changes it, centred on one line. */
.license__state {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* A dialog over the page, such as the admin's new license. */
.dialog {
  width: min(56rem, calc(100% - var(--page-margin) * 2));
  padding: var(--space-8);
  border: var(--border-width) solid var(--color-border);
  border-radius: 1.2rem;
  background: var(--color-background);
  color: var(--color-text);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 40%);
}

.dialog__head {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.dialog__title {
  margin: 0;
  font-size: clamp(2rem, 1.8rem + 0.5vw, 2.8rem);
  font-weight: 500;
}

/* A checkbox with its label beside it, as in the admin's forms. */
.checkbox {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.checkbox input {
  width: auto;
  margin: 0;
}

.key {
  padding: var(--space-4) var(--space-6);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--space-2);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 1.3921rem + 0.5249vw, 2.4rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  user-select: all;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--button-height);
  padding: 0 var(--space-6);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.button--primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.button--secondary {
  border-color: var(--color-text);
  background: transparent;
  color: var(--color-text);
}

.button--small {
  min-height: clamp(3.6rem, 3.3922rem + 0.5249vw, 4.4rem);
  padding: 0 var(--space-4);
  font-size: clamp(1.3rem, 1.222rem + 0.1969vw, 1.6rem);
}

.button--plain {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.button:disabled {
  cursor: progress;
  opacity: 0.55;
}

.button:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.3rem;
}

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

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

/* As croon.dev's: the copyright, and the site's links on the right. */
.footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  justify-content: space-between;
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
  border-top: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
}

.footer__links {
  display: flex;
  gap: var(--space-4);
}

.footer__links a {
  text-decoration: none;
}

@media (hover: hover) {
  .footer__links a:hover {
    color: var(--color-text);
  }
}

@media (prefers-reduced-motion: reduce) {
  .header,
  .button,
  .license__head::after {
    transition: none;
  }

  .toast {
    animation: none;
  }

  .toast--success {
    animation: toast-out 0s 4s forwards;
  }
}

/* The account: forms, toasts, and one card per license. */

.inline {
  display: inline;
  margin: 0;
}

.field {
  display: grid;
  gap: var(--space-2);
}

/* A form of several fields, each a label over its input. */
.form {
  display: grid;
  gap: var(--space-6);
}

.field__label,
.license__row dt {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 1.022rem + 0.1969vw, 1.4rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.field__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.input {
  flex: 1 1 24rem;
  min-height: var(--button-height);
  padding: 0 var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-background);
  color: var(--color-text);
  font: inherit;
}

/* The height of a small button, for fields beside one. */
.input--small {
  min-height: clamp(3.6rem, 3.3921rem + 0.5249vw, 4.4rem);
  font-size: clamp(1.3rem, 1.222rem + 0.1969vw, 1.6rem);
}

.input:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.1rem;
  border-color: var(--color-text);
}

/* The panel's toast: in the corner, the kind's colour as a bar and a tint.
   Success leaves after four seconds unless the pointer rests on it; an
   error stays until it is closed. */
.toast {
  --toast-color: var(--color-success-fill);
  --toast-icon: var(--color-success);

  position: fixed;
  right: 2rem;
  bottom: 2rem;
  z-index: 10;
  display: flex;
  gap: var(--space-3);
  align-items: center;
  width: min(38rem, calc(100vw - 4rem));
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
  font-size: clamp(1.4rem, 1.322rem + 0.1969vw, 1.6rem);
  font-weight: 500;
  line-height: 1.4;
  background: color-mix(in srgb, var(--toast-color) 8%, var(--color-background));
  border: var(--border-width) solid color-mix(in srgb, var(--toast-color) 30%, var(--color-background));
  border-radius: 1rem;
  box-shadow:
    inset 0.4rem 0 0 var(--toast-color),
    0 1.2rem 3.2rem rgb(0 0 0 / 12%);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.toast--success {
  animation:
    toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1),
    toast-out 0.2s ease-in 4s forwards;
}

.toast--success:hover {
  animation-play-state: paused;
}

.toast--error {
  --toast-color: var(--color-danger);
  --toast-icon: var(--color-danger);
}

.toast__icon {
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  fill: none;
  stroke: var(--toast-icon);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast__message {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast__dismiss,
.dialog__close {
  display: grid;
  flex: none;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0;
  border: 0;
  border-radius: 0.6rem;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.toast__dismiss svg,
.dialog__close svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
}

@media (hover: hover) {
  .toast__dismiss:hover {
    background: rgb(0 0 0 / 6%);
    color: var(--color-text);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(1.5rem);
  }
}

@keyframes toast-out {
  to {
    visibility: hidden;
    opacity: 0;
    transform: translateX(0.75rem);
  }
}

.badge {
  display: inline-block;
  padding: 0.3rem 1rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 1.022rem + 0.1969vw, 1.3rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--success {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.badge--warning {
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.badge--error {
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

/* One license: a card that opens and closes, its summary always shown. */
.license {
  border: var(--border-width) solid var(--color-border);
  border-radius: 1.2rem;
}

/* The name over the domains, then the badge and the chevron. */
.license__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.2rem var(--space-3);
  align-items: center;
  padding: var(--space-4) var(--space-6);
  list-style: none;
  cursor: pointer;
}

.license__head .badge {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.license__head::-webkit-details-marker {
  display: none;
}

/* A chevron that turns when the card opens. */
.license__head::after {
  content: '';
  grid-row: 1 / span 2;
  grid-column: 3;
  width: 0.8rem;
  height: 0.8rem;
  border-right: 0.2rem solid var(--color-text-muted);
  border-bottom: 0.2rem solid var(--color-text-muted);
  transform: rotate(45deg);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.license[open] > .license__head::after {
  transform: rotate(225deg);
}

.license__head:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: -0.2rem;
  border-radius: 1.2rem;
}

/* Renaming from the title: a pencil beside the name, which the script
   shows, makes the name editable in place; the form's row is hidden then. */
.license__rename {
  display: inline-grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  margin-left: 0.4rem;
  padding: 0;
  border: 0;
  border-radius: 0.6rem;
  background: none;
  color: var(--color-text-muted);
  vertical-align: middle;
  cursor: pointer;
}

.license__rename svg {
  width: 1.6rem;
  height: 1.6rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .license__rename:hover {
    background: var(--color-surface);
    color: var(--color-text);
  }
}

.has-script [data-rename-row] {
  display: none;
}

/* The name while it is edited: no field, a faint underline under the text. */
.license__name-text[contenteditable] {
  outline: none;
  box-shadow: inset 0 -0.2rem 0 var(--color-border);
  cursor: text;
}

/* Hidden but still taking its place, so the line keeps its height and the
   domains under it do not move. */
.license__name--editing .license__rename {
  visibility: hidden;
}

.license__domains {
  overflow-wrap: break-word;
  font-size: clamp(1.3rem, 1.222rem + 0.1969vw, 1.6rem);
  color: var(--color-text-muted);
}

.license__body {
  display: grid;
  gap: var(--space-6);
  padding: 0 var(--space-6) var(--space-6);
}

.license__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
}

/* Inside a card, text and notes at the small size, and the key no larger
   than it needs to be to copy it. */
.license__body .muted,
.license__body p,
.license__foot .button--plain {
  font-size: clamp(1.3rem, 1.222rem + 0.1969vw, 1.6rem);
}

.license__body .key {
  padding: var(--space-2) var(--space-3);
  font-size: clamp(1.4rem, 1.322rem + 0.1969vw, 1.7rem);
}

.license__foot .actions {
  margin-top: 0;
}

.license__rows {
  display: grid;
  gap: var(--space-4);
  margin: 0;
}

/* The label over its value. */
.license__row {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
}


.license__row dd {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}


.license__name {
  margin: 0;
  overflow-wrap: break-word;
  font-size: clamp(2rem, 1.7402rem + 0.6562vw, 3rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.domains {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.domains__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: var(--border-width) solid var(--color-border);
  font-weight: 500;
}

/* A module of its own under the page's main part, across its width: Your
   payments under Your licenses. */
.module {
  display: grid;
  align-content: start;
  gap: var(--space-8);
  min-height: 60vh;
  width: 100%;
  max-width: calc(var(--max-width) + var(--page-margin) * 2);
  margin: 0 auto;
  padding: var(--space-12) var(--page-margin) var(--space-16);
  border-top: var(--border-width) solid var(--color-border);
}

/* Modules one after another, as in the admin, take only their own height. */
.module--compact {
  min-height: 0;
}

/* The same size as the page's title, without the label over it. */
.module__title {
  margin: 0;
}

.module__body {
  display: grid;
  gap: var(--space-4);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(1.3rem, 1.222rem + 0.1969vw, 1.6rem);
}

.table th {
  padding: 0 var(--space-3) var(--space-3) 0;
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 1.022rem + 0.1969vw, 1.4rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: left;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.table td {
  padding: var(--space-3) var(--space-3) var(--space-3) 0;
  border-top: var(--border-width) solid var(--color-border);
  vertical-align: middle;
}

/* A line under the last row too, so every row sits between two. */
.table tbody tr:last-child td {
  border-bottom: var(--border-width) solid var(--color-border);
}

.module__body > .muted {
  margin-top: var(--space-3);
  font-size: clamp(1.3rem, 1.222rem + 0.1969vw, 1.6rem);
}

.table__amount {
  white-space: nowrap;
}

.table__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  justify-content: flex-end;
}

/* On a phone the table scrolls sideways rather than squeezing. */
@media (max-width: 640px) {
  .module__body {
    overflow-x: auto;
  }

  .table {
    min-width: 56rem;
  }
}

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