@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Source+Sans+3:wght@300;400;500;600&display=swap');

:root {
  --black: #000000;
  --white: #ffffff;
  --pink: #f2c2cb;
  --pink-light: #f8d8de;
  --pink-header: #f5d0d6;
  --gray: #666666;
  --border: 1px solid var(--black);
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Source Sans 3', 'Segoe UI', sans-serif;
  --max-width: 820px;
}

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--black);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

#main-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Logo ── */
.logo {
  text-align: right;
  padding: 1.25rem 1.5rem 0;
}

.logo__img {
  display: inline-block;
  height: 28px;
  width: auto;
  max-width: 140px;
}

.logo--center {
  text-align: center;
  padding: 0 0 2rem;
}

.logo--center .logo__img {
  height: 32px;
}

/* ── Footer ── */
.hesdin-footer {
  margin-top: auto;
  padding-top: 2rem;
  width: 100%;
  overflow: hidden;
  background: var(--white);
  flex-shrink: 0;
}

.hesdin-footer__img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
}

/* ── Welcome hero (image 1) ── */
.welcome-hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.welcome-hero__column {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

.welcome-hero__top {
  flex: 1;
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
  min-height: 45vh;
}

.welcome-hero__top .logo {
  color: var(--white);
}

.welcome-hero__top .logo__img {
  filter: invert(1);
}

.welcome-hero__title {
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 10vw, 5.5rem);
  font-weight: 700;
  line-height: 1.05;
  margin: 2rem 0 0;
}

.welcome-hero__bottom {
  flex: 1;
  padding: 2.5rem 1.5rem 2rem;
}

.welcome-hero__bottom p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.welcome-hero__actions {
  border-top: none;
  margin-top: 2rem;
  padding-top: 0;
}

/* ── Form container ── */
.form-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

.form-page--wide {
  max-width: 900px;
}

/* ── Headings ── */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  margin: 2rem 0 1rem;
}

.section-title:first-child {
  margin-top: 0.5rem;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  margin: 0.5rem 0 1rem;
}

.intro-text {
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* ── Info box (image 2) ── */
.info-box {
  border: var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 2rem;
}

.info-box__left {
  padding: 1rem 1.25rem;
  border-right: var(--border);
  font-size: 0.9rem;
}

.info-box__right {
  padding: 1rem 1.25rem;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.checklist li::before {
  content: '☐';
  flex-shrink: 0;
  font-size: 1rem;
}

/* ── Form fields ── */
.field {
  margin-bottom: 0;
}

.field + .field {
  border-top: none;
}

.field-group {
  border: var(--border);
  margin-bottom: 1.25rem;
}

.field-group .field {
  border-bottom: var(--border);
}

.field-group .field:last-child {
  border-bottom: none;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 0.85rem 0.25rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: none;
  padding: 0.25rem 0.85rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  background: transparent;
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  background: #fafafa;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.field--bordered {
  border: var(--border);
  margin-bottom: 0.75rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-row .field--bordered {
  margin-bottom: 0;
}

/* ── Pink questionnaire style ── */
.question-block {
  border: var(--border);
  margin-bottom: 1rem;
}

.question-block__header {
  background: var(--pink-header);
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: var(--border);
}

.question-block__text {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: var(--border);
}

.question-block__answers {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: var(--border);
}

.question-block__answers .question-text {
  grid-column: 1;
}

.yes-no-group {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.yes-no-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.yes-no-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--black);
  cursor: pointer;
}

.details-box {
  background: var(--pink-light);
  padding: 0.75rem;
  border-top: var(--border);
}

.details-box textarea {
  width: 100%;
  min-height: 120px;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
  padding: 0.5rem;
}

.details-box[hidden] {
  display: none;
}

/* Reference form pink inputs */
.field--pink {
  border: var(--border);
  margin-bottom: 0;
}

.field--pink label {
  display: block;
  background: var(--white);
  border-bottom: var(--border);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.field--pink textarea,
.field--pink input {
  display: block;
  width: 100%;
  background: var(--pink-light);
  border: none;
  padding: 0.6rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
  min-height: 72px;
}

.field--pink input {
  min-height: auto;
}

.field--pink + .field--pink {
  border-top: none;
}

.pink-section-header {
  background: var(--pink-header);
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: var(--border);
  border-bottom: none;
  margin-top: 1.5rem;
}

.pink-section-header + .field--pink {
  margin-top: 0;
}

/* ── Emergency contacts ── */
.emergency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.emergency-card {
  border: var(--border);
}

.emergency-card .field {
  border-bottom: var(--border);
}

.emergency-card .field:last-child {
  border-bottom: none;
}

/* ── Signature pad ── */
.signature-field {
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.signature-pad__wrap {
  padding: 0 0.85rem 0.5rem;
  max-width: 100%;
}

.signature-pad__canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 140px;
  box-sizing: border-box;
  background: #fafafa;
  border: 1px dashed #999;
  border-radius: 2px;
  cursor: crosshair;
  touch-action: none;
}

.signature-pad__clear {
  display: inline-block;
  margin: 0 0.85rem 0.65rem;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--gray);
  text-decoration: underline;
  cursor: pointer;
}

.signature-pad__clear:hover {
  color: var(--black);
}

.signature-field.field-error .signature-pad__canvas {
  border-color: #c45c6a;
  box-shadow: inset 0 0 0 1px #c45c6a;
}

/* ── Consent ── */
.consent-text {
  font-size: 0.9rem;
  margin: 1rem 0;
}

/* ── Step wizard ── */
.steps-nav {
  display: none;
}

.form-step {
  display: none;
}

.form-step.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.form-step.active:has(.hesdin-footer) .form-page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-step--welcome.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: var(--border);
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1.75rem;
  border: var(--border);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  letter-spacing: 0.02em;
}

.btn:hover {
  background: var(--black);
  color: var(--white);
}

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

.btn:disabled:hover {
  background: var(--white);
  color: var(--black);
}

.btn--primary {
  background: var(--black);
  color: var(--white);
}

.btn--primary:hover {
  background: #333;
  color: var(--white);
}

.btn--text {
  border: none;
  background: none;
  text-decoration: underline;
  padding: 0.75rem 0.5rem;
}

.btn--text:hover {
  background: none;
  color: var(--gray);
}

/* ── Progress bar ── */
.progress-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: var(--border);
  padding: 0.5rem 1.25rem;
  flex-shrink: 0;
}

.progress-bar__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.progress-bar__track {
  flex: 1;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--black);
  transition: width 0.3s ease;
  border-radius: 2px;
}

.progress-bar__label {
  font-size: 0.75rem;
  color: var(--gray);
  white-space: nowrap;
}

/* ── Save status ── */
.save-status {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--black);
  color: var(--white);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 200;
}

.save-status:not(:empty) {
  opacity: 1;
}

.save-status.error {
  background: #c0392b;
}

/* ── Validation errors ── */
.field-error,
.question-block.field-error {
  outline: 2px solid #c45c6a;
  outline-offset: -2px;
}

.field--pink.field-error {
  border-color: #c45c6a;
  box-shadow: inset 0 0 0 2px #c45c6a;
}

.field-error-msg {
  margin: 0;
  padding: 0.35rem 0.85rem 0.65rem;
  font-size: 0.85rem;
  color: #c45c6a;
  font-weight: 500;
  line-height: 1.3;
}

.field--pink .field-error-msg {
  padding: 0.5rem 1rem 0.85rem;
  background: var(--pink-light);
}

.field--bordered .field-error-msg {
  padding-top: 0;
}

.question-block .field-error-msg {
  padding: 0.6rem 1rem 0.85rem;
  border-top: 1px solid #f0b8c0;
  background: #fdf5f6;
}

.emergency-card .field-error-msg {
  padding: 0.5rem 0.85rem 0.75rem;
  border-top: 1px solid #f0b8c0;
}

/* ── Success page ── */
.success-message {
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: 500px;
  margin: 0 auto;
}

.success-message h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: 1rem;
}

.success-message p {
  color: var(--gray);
  margin-bottom: 2rem;
}

/* ── Candidate name highlight ── */
.candidate-highlight {
  color: #c45c6a;
  font-weight: 600;
}

/* ── Health table header ── */
.health-table-header {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  background: var(--pink-header);
  border: var(--border);
  border-bottom: none;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
}

.health-table-header span:first-child {
  text-align: left;
  padding: 0.6rem 1rem;
  border-right: var(--border);
}

.health-table-header span {
  padding: 0.6rem 0.5rem;
  border-right: var(--border);
}

.health-table-header span:last-child {
  border-right: none;
}

/* ── Single question step ── */
.single-question-step .question-block {
  margin-top: 1rem;
}

.single-question-step .instruction {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--gray);
}

.single-question-step.active:has(.hesdin-footer) .form-page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.single-question-step .field--pink {
  flex: none;
}

.single-question-step .field--pink textarea {
  flex: none;
  min-height: 72px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .info-box {
    grid-template-columns: 1fr;
  }

  .info-box__left {
    border-right: none;
    border-bottom: var(--border);
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .emergency-grid {
    grid-template-columns: 1fr;
  }

  .question-block__answers {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .yes-no-group {
    justify-content: flex-start;
  }

  .health-table-header {
    grid-template-columns: 1fr 50px 50px;
    font-size: 0.75rem;
  }

  .btn-row {
    flex-direction: column-reverse;
  }

  .btn-row .btn {
    width: 100%;
    text-align: center;
  }

  .welcome-hero__title {
    font-size: clamp(2.2rem, 12vw, 3.5rem);
  }

  .logo__img {
    height: 24px;
    max-width: 120px;
  }

  .hesdin-footer {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    width: calc(100% + 2.5rem);
  }
}

@media (min-width: 641px) {
  .form-page {
    padding: 0 2rem;
  }

  .hesdin-footer {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }

  .welcome-hero__top,
  .welcome-hero__bottom {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (min-width: 1024px) {
  .welcome-hero {
    flex-direction: row;
    align-items: stretch;
  }

  .welcome-hero__top,
  .welcome-hero__bottom {
    flex: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 3.5rem;
  }

  .welcome-hero__top {
    min-height: auto;
  }

  .welcome-hero__bottom {
    min-height: auto;
  }

  .welcome-hero__column {
    max-width: 520px;
  }

  .welcome-hero__title {
    font-size: clamp(3rem, 5vw, 4.5rem);
    margin-top: 2.5rem;
  }

  .welcome-hero__bottom p {
    font-size: 1rem;
    line-height: 1.7;
  }
}
