/* Base reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Color palette — WCAG AA compliant
   Background: #ffffff
   Body text: #1a1a1a on white = 17.4:1
   Muted text: #4a4a4a on white = 9.7:1
   Primary (buttons/links): #0055a4 on white = 7.1:1
   Primary hover: #003d75 on white = 10.7:1
   Error: #c22b2b on white = 5.9:1
   Tab inactive bg: #e8e8e8, text #4a4a4a = 4.6:1
   Tab active bg: #ffffff, text #1a1a1a = 17.4:1
   Focus ring: #0055a4
*/

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #4a4a4a;
  --color-primary: #0055a4;
  --color-primary-hover: #003d75;
  --color-error: #c22b2b;
  --color-border: #cccccc;
  --color-tab-inactive: #e8e8e8;
  --color-input-bg: #fafafa;
  --color-success: #1a7a3a;
  --max-width: 40rem;
  --space: 1rem;
}

html {
  font-size: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  padding: var(--space);
}

/* Layout — single column, max width for readability */
header,
main {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Header / Logo */
header {
  text-align: center;
  padding: var(--space) 0;
}

header img {
  max-width: 200px;
  height: auto;
}

/* Main content sections stacked */
main {
  display: flex;
  flex-direction: column;
  gap: calc(var(--space) * 2);
}

/* Description section */
#description h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

#description p {
  margin-bottom: 0.75rem;
  color: var(--color-muted);
}

/* Terms page content */
#terms h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

#terms h2 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

#terms p,
#terms ul {
  margin-bottom: 0.75rem;
  color: var(--color-muted);
}

#terms ul {
  padding-left: 1.5rem;
}

#terms li {
  margin-bottom: 0.5rem;
}

#terms a {
  color: var(--color-primary);
  text-decoration: underline;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

#terms a:hover {
  color: var(--color-primary-hover);
}

/* Tabs */
[role="tablist"] {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
}

[role="tab"] {
  font: inherit;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  min-width: 44px;
  border: 2px solid transparent;
  border-bottom: none;
  background: var(--color-tab-inactive);
  color: var(--color-muted);
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: background 0.15s, color 0.15s;
}

[role="tab"][aria-selected="true"] {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
  margin-bottom: -2px;
  font-weight: 600;
}

[role="tab"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* Tab panels */
[role="tabpanel"] {
  padding: var(--space) 0;
}

[role="tabpanel"][hidden] {
  display: none;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

form > div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

input[type="text"],
input[type="email"],
textarea {
  font: inherit;
  font-size: 1rem;
  padding: 0.625rem 0.75rem;
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-input-bg);
  color: var(--color-text);
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
  border-color: var(--color-primary);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* Checkbox rows */
form > div:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

form > div:has(input[type="checkbox"]) label {
  font-weight: 400;
  font-size: 0.875rem;
}

form > div:has(input[type="checkbox"]) label a {
  color: var(--color-primary);
  text-decoration: underline;
}

form > div:has(input[type="checkbox"]) label a:hover {
  color: var(--color-primary-hover);
}

/* Submit buttons — 44px touch target */
button[type="submit"] {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  min-height: 44px;
  min-width: 44px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.15s;
}

button[type="submit"]:hover {
  background: var(--color-primary-hover);
}

button[type="submit"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Inline error messages */
span.error {
  color: var(--color-error);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Form status live region */
#form-status {
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  min-height: 0;
}

#form-status:not(:empty) {
  border: 1px solid var(--color-border);
}

/* Responsive: wider screens */
@media (min-width: 768px) {
  body {
    padding: calc(var(--space) * 2);
  }

  header,
  main {
    max-width: 48rem;
  }

  main {
    gap: calc(var(--space) * 2.5);
  }

  header img {
    max-width: 260px;
  }
}

/* Prevent horizontal overflow at all widths */
html {
  overflow-x: hidden;
}

body {
  max-width: 100vw;
}
