@layer base, components, utilities;

:root {
  --color-paper:      #f5f4f0;
  --color-ink:        #18181b;
  --color-ink-muted:  #52525b;
  --color-surface:    #ffffff;
  --color-border:     #d4d4d8;
  --color-error:      #7f1d1d;
  --color-error-bg:   color-mix(in srgb, var(--color-error) 8%, transparent);

  --bg:           var(--color-paper);
  --fg:           var(--color-ink);
  --fg-muted:     var(--color-ink-muted);
  --surface:      var(--color-surface);
  --border:       var(--color-border);
  --border-focus: var(--color-ink);
  --accent:       var(--color-ink);
  --accent-fg:    var(--color-paper);
  --error:        var(--color-error);
  --error-bg:     var(--color-error-bg);

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --text-eyebrow:   0.6875rem;
  --text-sm:        0.8125rem;
  --text-base:      1rem;
  --text-h1-mobile: 1.625rem;
  --text-h1:        2rem;
  --leading-tight: 1.1;
  --leading-snug:  1.4;
  --leading-body:  1.6;

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-20: 5rem;

  --radius-sm: 2px;
  --max-width: 32rem;

  --duration-fast: 120ms;
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #111110;
    --fg:           #e8e8e4;
    --fg-muted:     #888882;
    --surface:      #1c1c1a;
    --border:       #333330;
    --border-focus: #e8e8e4;
    --accent:       #e8e8e4;
    --accent-fg:    #111110;
    --error:        #c87171;
    --error-bg:     color-mix(in srgb, #c87171 10%, transparent);
  }
}

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

  html,
  body {
    margin: 0;
    padding: 0;
  }

  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-body);
    color: var(--fg);
    background-color: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1,
  h2,
  p {
    margin: 0;
  }

  a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.15em;
    text-decoration-color: var(--border);
    transition: text-decoration-color var(--duration-fast) var(--ease-out);
  }

  a:hover {
    text-decoration-color: currentColor;
  }
}

@layer components {
  main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-12) var(--space-5) var(--space-8);
  }

  header {
    padding-bottom: var(--space-10);
    margin-bottom: var(--space-10);
    border-bottom: 1px solid var(--border);
  }

  h1 {
    font-size: var(--text-h1-mobile);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: var(--leading-tight);
    color: var(--fg);
    margin-bottom: var(--space-3);
  }

  .tagline {
    color: var(--fg-muted);
    margin-bottom: var(--space-2);
  }

  .access {
    color: var(--fg-muted);
    font-size: var(--text-sm);
  }

  section {
    display: flex;
    flex-direction: column;
  }

  h2 {
    font-size: var(--text-eyebrow);
    font-weight: 500;
    letter-spacing: 0.12em;
    line-height: var(--leading-snug);
    text-transform: uppercase;
    color: var(--fg-muted);
    margin-bottom: var(--space-4);
  }

  form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
  }

  label {
    font-size: var(--text-sm);
    color: var(--fg);
  }

  input,
  textarea {
    font: inherit;
    color: var(--fg);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    width: 100%;
    transition:
      border-color var(--duration-fast) var(--ease-out),
      box-shadow var(--duration-fast) var(--ease-out),
      background-color var(--duration-fast) var(--ease-out);
  }

  textarea {
    resize: vertical;
    min-height: 6rem;
    line-height: var(--leading-body);
  }

  input:focus,
  textarea:focus {
    outline: none;
  }

  input:focus-visible,
  textarea:focus-visible {
    border-color: var(--border-focus);
    box-shadow:
      0 0 0 2px var(--surface),
      0 0 0 4px var(--border-focus);
  }

  .gdpr {
    font-size: var(--text-sm);
    color: var(--fg-muted);
    margin-top: var(--space-1);
  }

  button {
    font: inherit;
    font-weight: 500;
    background-color: var(--accent);
    color: var(--accent-fg);
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    align-self: flex-start;
    transition: opacity var(--duration-fast) var(--ease-out);
  }

  button:hover:not(:disabled) {
    opacity: 0.85;
  }

  button:focus {
    outline: none;
  }

  button:focus-visible {
    box-shadow:
      0 0 0 2px var(--bg),
      0 0 0 4px var(--accent);
  }

  button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  footer {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-8);
    color: var(--fg-muted);
    border-top: 1px solid var(--border);
  }

  footer small {
    font-size: var(--text-sm);
  }
}

@layer utilities {
  .hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  #form-status {
    min-height: 1.2rem;
    font-size: var(--text-sm);
    color: var(--fg);
  }

  #form-status.error {
    color: var(--error);
  }

  input:user-invalid,
  textarea:user-invalid {
    border-color: var(--error);
    background-color: var(--error-bg);
  }
}

@media (min-width: 768px) {
  main {
    padding-top: var(--space-20);
  }

  h1 {
    font-size: var(--text-h1);
  }
}

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