/* ==========================================================================
   Base: design tokens, reset, typography, shared components
   ========================================================================== */

:root {
  /* Colors */
  --c-purple: #7245ff;
  --c-pink: #f41e78;
  --c-lilac: #dad0fb;
  --c-lavender: #e5ddfd;
  --c-plum: #51379d;
  --c-deep: #3a1f7a;
  --c-ink: #231843;
  --c-ink-soft: #493489;
  --c-white: #fff;
  --c-line: rgba(35, 24, 67, 0.12);
  --c-line-strong: rgba(35, 24, 67, 0.25);
  --c-success: #1f8a5b;

  /* Typography */
  --f-head: "Montserrat", "Segoe UI", Arial, sans-serif;
  --f-body: "Roboto", "Segoe UI", Arial, sans-serif;

  /* Radii */
  --r-sm: 16px;
  --r-md: 24px;
  --r-pill: 999px;

  /* Layout */
  --container: 1160px;
  --gutter: 40px;
  --section-gap: 96px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 1023px) {
  :root {
    --gutter: 24px;
    --section-gap: 72px;
  }
}

/* Line breaks taken from the 1440 and 320 designs; in between the columns
   are narrower than those lines, so the text wraps on its own */
@media (min-width: 640px) and (max-width: 1199px) {
  .br-design {
    display: none;
  }
}

@media (max-width: 639px) {
  :root {
    --gutter: 16px;
    --section-gap: 20px;
  }
}

/* ---------- Reset ---------- */

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

/*
 * Line height is set as a ratio in --lh and rounded to whole pixels,
 * the way the design tool does it (16px × 1.35 = 21.6 → 22px).
 * Without round() support the plain ratio is used.
 */
* {
  line-height: var(--lh);
  line-height: round(calc(var(--lh) * 1em), 1px);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--c-purple);
  color: var(--c-white);
  font-family: var(--f-body);
  font-size: 16px;
  --lh: 1.35;
  -webkit-font-smoothing: antialiased;
}

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

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

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

/* Not the font shorthand: it would also reset the rounded line height */
button,
input,
textarea,
select {
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--c-pink);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--c-white);
  color: var(--c-ink);
  font-weight: 500;
  transform: translateY(-200%);
  transition: transform 0.2s;
}

.skip-link:focus {
  transform: none;
}

@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;
  }
}

/* ---------- Layout ---------- */

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

.section {
  padding-top: var(--section-gap);
}

.section-head {
  display: grid;
  gap: 12px;
  margin-bottom: 40px;
  text-align: center;
}

.section-head__title {
  font-family: var(--f-head);
  font-size: clamp(28px, 2.2vw + 12px, 40px);
  font-weight: 700;
  --lh: 1.15;
}

.section-head__lead {
  font-size: clamp(16px, 0.4vw + 13px, 18px);
  opacity: 0.85;
  text-wrap: balance;
}

@media (max-width: 639px) {
  .section-head {
    margin-bottom: 20px;
  }

  .section-head__title {
    font-size: 26px;
  }

  /* Lines break where the design breaks them */
  .section-head__lead {
    font-size: 16px;
    text-wrap: wrap;
  }
}

/* ---------- Card ---------- */

.card {
  padding: 32px;
  border-radius: var(--r-md);
  background: var(--c-white);
  color: var(--c-ink);
}

.card__title {
  font-size: 22px;
  font-weight: 700;
  /* At 22/30 Figma puts the baseline 1px lower than the browser does */
  translate: 0 1px;
}

.card__text {
  overflow-wrap: anywhere;
}

.card__hint {
  color: var(--c-ink-soft);
  font-size: 13px;
}

@media (max-width: 639px) {
  .card {
    padding: 20px;
    border-radius: 16px;
    font-size: 15px;
  }

  .card__title {
    font-size: 18px;
    translate: none;
  }
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--c-pink);
  --btn-fg: var(--c-white);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 16px 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition:
    transform 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out),
    background-color 0.2s,
    opacity 0.2s;
}

/* Inline icons (e.g. "opens in a new tab") stay icon-sized */
.btn svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.btn:hover:not(:disabled) {
  box-shadow: 0 10px 24px -10px rgba(244, 30, 120, 0.8);
  transform: translateY(-2px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.btn--outline {
  --btn-bg: transparent;
  --btn-fg: var(--c-ink);

  border: 2px solid currentColor;
}

.btn--outline:hover:not(:disabled) {
  --btn-bg: var(--c-white);
  box-shadow: 0 10px 24px -12px rgba(35, 24, 67, 0.5);
}

.btn--block {
  width: 100%;
}

/* Phones: square-ish 60px buttons as in the 320px design */
@media (max-width: 639px) {
  .btn {
    min-height: 0;
    padding: 20px;
    border-radius: 16px;
    font-size: 15px;
  }

  .btn--outline {
    padding: 16px 28px;
    border-radius: 30px;
  }
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- Form controls ---------- */

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  color: var(--c-ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-pill);
  background: var(--c-white);
  color: var(--c-ink);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
  color: var(--c-ink-soft);
  opacity: 0.8;
}

.input:focus {
  border-color: var(--c-purple);
  outline: none;
  box-shadow: 0 0 0 3px rgba(114, 69, 255, 0.2);
}

.input[aria-invalid="true"] {
  border-color: var(--c-pink);
}

textarea.input {
  min-height: 112px;
  border-radius: var(--r-sm);
  resize: vertical;
}

.form-message {
  font-size: 14px;
  font-weight: 500;
}

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

.form-message--error {
  color: var(--c-pink);
}

/* ---------- Chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--c-lavender);
  color: var(--c-ink);
  font-size: 13px;
  font-weight: 500;
}

.chip--confirmed {
  background: var(--c-ink-soft);
  color: var(--c-white);
}

.chip--rejected {
  background: var(--c-deep);
  color: var(--c-white);
}

.chip--accent {
  background: var(--c-pink);
  color: var(--c-white);
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  right: 0;
  bottom: 24px;
  left: 0;
  z-index: 60;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding-inline: var(--gutter);
  pointer-events: none;
}

.toast {
  max-width: 480px;
  padding: 14px 22px;
  border-radius: var(--r-sm);
  background: var(--c-ink);
  color: var(--c-white);
  font-size: 15px;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.35s var(--ease-spring);
}

.toast.is-leaving {
  animation: toast-out 0.25s ease-in forwards;
}

/* ---------- Scroll reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
  transition-delay: calc(var(--reveal-i, 0) * 80ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.no-js .reveal {
  opacity: 1;
  transform: none;
}

/* ---------- Keyframes ---------- */

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

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }

  40%,
  80% {
    transform: translateX(6px);
  }
}
