/* ============================================================
   CONTACT FORM — styles.css
   Design: ink-blue/slate on warm off-white canvas.
   Signature: fluid gradient stroke that traces the input
   border on focus — one deliberate, premium detail.
   Mobile-first, WCAG AA compliant, reduced-motion aware.
   ============================================================ */

/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Palette */
  --color-canvas: #F7F5F2;
  /* warm off-white page bg   */
  --color-card: #FFFFFF;
  --color-ink: #1A1A2E;
  /* near-black headings       */
  --color-ink-mid: #3D3D5C;
  /* body text                 */
  --color-ink-soft: #7B7B9A;
  /* hints, legends            */
  --color-border: #D8D6F0;
  /* resting input border      */
  --color-border-hover: #A09EC8;
  --color-accent: #4A3AFF;
  /* primary blue-violet       */
  --color-accent-2: #C850C0;
  /* gradient end (magenta)    */
  --color-success-bg: #EDFAF3;
  --color-success-ink: #1A6B43;
  --color-success-bdr: #6FCF97;
  --color-error-bg: #FFF0F0;
  --color-error-ink: #991B1B;
  --color-error-bdr: #FCA5A5;
  --color-disabled: #E8E7F4;

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Spacing scale (4 px base) */
  --sp-1: 0.25rem;
  /*  4px */
  --sp-2: 0.5rem;
  /*  8px */
  --sp-3: 0.75rem;
  /* 12px */
  --sp-4: 1rem;
  /* 16px */
  --sp-5: 1.25rem;
  /* 20px */
  --sp-6: 1.5rem;
  /* 24px */
  --sp-8: 2rem;
  /* 32px */
  --sp-10: 2.5rem;
  /* 40px */
  --sp-12: 3rem;
  /* 48px */

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* Transitions */
  --trans-fast: 150ms ease;
  --trans-normal: 250ms ease;
  --trans-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-card: 0 4px 32px rgba(26, 26, 46, 0.08),
    0 1px 4px rgba(26, 26, 46, 0.04);
  --shadow-focus: 0 0 0 3px rgba(74, 58, 255, 0.22);
}

/* ── 2. RESET & BASE ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-ink-mid);
  background-color: var(--color-canvas);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── 3. SCREEN-READER ONLY UTILITY ───────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── 4. PAGE LAYOUT ───────────────────────────────────────── */
.page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-4);
}

/* ── 5. CARD ──────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-8) var(--sp-6);
  width: 100%;
  max-width: 560px;
  position: relative;
}

@media (min-width: 480px) {
  .card {
    padding: var(--sp-10) var(--sp-8);
  }
}

/* ── 6. CARD HEADER ───────────────────────────────────────── */
.card__header {
  margin-bottom: var(--sp-8);
}

.card__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--sp-2);
}

.card__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--color-ink);
  margin-bottom: var(--sp-3);
}

.card__subtitle {
  font-size: 0.9375rem;
  color: var(--color-ink-soft);
  line-height: 1.55;
}

/* ── 7. STATUS MESSAGE ────────────────────────────────────── */
.status {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-6);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;

  /* Animated entrance */
  animation: slideDown var(--trans-slow) both;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status[hidden] {
  display: none;
}

.status--success {
  background-color: var(--color-success-bg);
  border: 1px solid var(--color-success-bdr);
  color: var(--color-success-ink);
}

.status--error {
  background-color: var(--color-error-bg);
  border: 1px solid var(--color-error-bdr);
  color: var(--color-error-ink);
}

.status__icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1.4;
}

/* ── 8. FORM SHELL (blur container) ──────────────────────── */
.form-shell {
  position: relative;
}

/* Blur state applied by JS during loading/feedback */
.form-shell--blurred .form {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
  transition: filter var(--trans-slow);
}

/* ── 9. LOADING OVERLAY ───────────────────────────────────── */
.form-overlay {
  position: absolute;
  inset: 0;
  display: none;
  /* JS shows it */
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-md);
}

.form-overlay--visible {
  display: flex;
}

/* ── 10. SPINNER ──────────────────────────────────────────── */
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;

  /* Gradient conic trick — more elegant than a dashed border */
  background: conic-gradient(from 0deg,
      var(--color-accent) 0%,
      var(--color-accent-2) 50%,
      transparent 100%);
  animation: spin 0.75s linear infinite;
  position: relative;
}

/* White hole in the centre → ring effect */
.spinner::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--color-card);
}

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

/* ── 11. FORM & FIELDS ────────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  transition: filter var(--trans-slow);
}

/* Individual field wrapper */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Label */
.field__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-ink);
  letter-spacing: 0.01em;
}

.field__required {
  color: var(--color-accent);
  margin-left: var(--sp-1);
}

/* ── SIGNATURE ELEMENT: gradient stroke focus ─────────────
   On focus we swap the solid border for a 2 px gradient
   outline using a pseudo-element technique.
   The parent gets `position: relative` so the pseudo-
   element can be placed flush against the input edges.
─────────────────────────────────────────────────────────── */
.field__input-wrapper {
  position: relative;
}

/* Base input / textarea styles */
.field__input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-ink);
  background: var(--color-canvas);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  outline: none;
  transition:
    border-color var(--trans-normal),
    box-shadow var(--trans-normal),
    background var(--trans-normal);
  -webkit-appearance: none;
  appearance: none;
}

.field__input::placeholder {
  color: #BCBAD4;
}

/* Hover */
.field__input:hover:not(:disabled) {
  border-color: var(--color-border-hover);
  background: #FDFCFB;
}

/* ── THE SIGNATURE FOCUS STATE ──
   Instead of a plain outline, we draw a glowing gradient
   ring that evokes an ink-stroke — the page's one bold
   design risk.
─────────────────────────────────────────────────────────── */
.field__input:focus {
  border-color: transparent;
  background: #FFFFFF;
  box-shadow:
    0 0 0 2px var(--color-accent),
    /* inner solid ring  */
    0 0 0 5px rgba(74, 58, 255, 0.14),
    /* soft outer glow   */
    var(--shadow-focus);
}

/* Textarea specifics */
.field__input--textarea {
  resize: vertical;
  min-height: 130px;
}

/* Hint text */
.field__hint {
  font-size: 0.8125rem;
  color: var(--color-ink-soft);
  margin-top: calc(-1 * var(--sp-1));
}

/* Inline error message */
.field__error {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-error-ink);
  min-height: 1.1rem;
  /* prevents layout shift */
  display: block;
}

/* Invalid state styling */
.field--invalid .field__input {
  border-color: var(--color-error-bdr);
  background: var(--color-error-bg);
}

.field--invalid .field__input:focus {
  box-shadow:
    0 0 0 2px var(--color-error-bdr),
    0 0 0 5px rgba(252, 165, 165, 0.25);
}

/* Disabled state */
.field__input:disabled {
  background: var(--color-disabled);
  color: var(--color-ink-soft);
  cursor: not-allowed;
  border-color: var(--color-border);
}

/* ── 12. REQUIRED LEGEND ──────────────────────────────────── */
.form__legend {
  font-size: 0.8125rem;
  color: var(--color-ink-soft);
  margin-top: calc(-1 * var(--sp-2));
}

/* ── 13. SUBMIT BUTTON ────────────────────────────────────── */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);

  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #FFFFFF;

  background: linear-gradient(135deg,
      var(--color-accent) 0%,
      var(--color-accent-2) 100%);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--sp-4) var(--sp-6);
  cursor: pointer;
  width: 100%;
  margin-top: var(--sp-2);
  position: relative;
  overflow: hidden;

  transition:
    opacity var(--trans-normal),
    transform var(--trans-fast),
    box-shadow var(--trans-normal);
}

/* Shimmer sweep on hover */
.btn-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg,
      transparent 30%,
      rgba(255, 255, 255, 0.18) 50%,
      transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.55s ease;
}

.btn-submit:hover::before {
  transform: translateX(100%);
}

.btn-submit:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(74, 58, 255, 0.35);
  transform: translateY(-1px);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(74, 58, 255, 0.25);
}

/* Focus ring for keyboard users */
.btn-submit:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--color-card),
    0 0 0 5px var(--color-accent);
}

.btn-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-submit__arrow {
  font-size: 1.1rem;
  transition: transform var(--trans-normal);
  display: inline-block;
}

.btn-submit:hover:not(:disabled) .btn-submit__arrow {
  transform: translateX(4px);
}

/* ── 14. REDUCED MOTION ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .spinner {
    animation: none;
    border: 3px solid var(--color-accent);
    border-top-color: transparent;
  }
}

/* ── 15. DARK MODE (system preference) ───────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --color-canvas: #12121F;
    --color-card: #1C1C30;
    --color-ink: #EEEEF8;
    --color-ink-mid: #B0AECF;
    --color-ink-soft: #6B6990;
    --color-border: #2E2C4A;
    --color-border-hover: #4A4870;
    --color-disabled: #252440;
    --color-success-bg: #0D2E1F;
    --color-success-ink: #6FCF97;
    --color-success-bdr: #1A6B43;
    --color-error-bg: #2E1212;
    --color-error-ink: #FCA5A5;
    --color-error-bdr: #991B1B;
    --shadow-card: 0 4px 40px rgba(0, 0, 0, 0.4);
  }

  .field__input {
    background: #16162A;
  }

  .field__input:hover:not(:disabled) {
    background: #1A1A2E;
  }

  .field__input:focus {
    background: #1E1E34;
  }

  .spinner::after {
    background: var(--color-card);
  }
}

/* ── 16. RESPONSIVE TWEAKS ────────────────────────────────── */
@media (min-width: 640px) {
  .card__eyebrow {
    font-size: 0.8125rem;
  }
}