/* ============================================
   Sylvia Brinkman Foundation - Application Form
   ============================================ */

/* --- Tighter section padding for transactional form pages --- */
.section {
  padding-top: 40px;
  padding-bottom: 60px;
}

/* --- Container --- */
.apply-container {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 24px 40px;
}

/* --- Step card --- */
.apply-step {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 36px 40px;
  border-top: 3px solid var(--cardinal);
}

.apply-step h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.apply-step .apply-subtitle {
  color: var(--gray-600);
  margin-bottom: 32px;
}

/* --- Award badge --- */
.apply-award-badge {
  display: inline-block;
  background: rgba(88, 0, 24, 0.08);
  color: var(--cardinal);
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
}

/* --- Scholarship description --- */
.apply-description {
  font-size: 0.9rem;
  color: var(--gray-dark, #636366);
  line-height: 1.5;
  margin-bottom: 8px;
  font-style: italic;
}

.apply-subtitle {
  margin-bottom: 28px;
}

/* --- Identity grid (first + last name side by side) --- */
.apply-id-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.apply-id-grid .apply-field {
  margin-bottom: 0;
}

/* --- Spinner on email field --- */
.field-checking-wrap {
  position: relative;
}

.field-checking-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--cardinal);
  border-radius: 50%;
  animation: sbf-spin 0.6s linear infinite;
  display: none;
}

.field-checking-spinner.visible {
  display: block;
}

@keyframes sbf-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* --- Disclosure animation --- */
.apply-disclosure {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s ease;
}

.apply-disclosure.open {
  grid-template-rows: 1fr;
}

.apply-disclosure-inner {
  overflow: hidden;
}

.apply-disclosure-inner > .disclosure-body {
  margin-top: 0;
}

/* --- Inline case messages --- */
/* Heading lives outside the box now (page-level <h2>); the box holds only the
   specific message. Actions live below in .case-msg-actions.
   Spacing follows the 8/16/24 style-guide scale; vertical margins between H2,
   .case-msg, and .case-msg-actions collapse to 16px each. */
.case-msg {
  border-radius: var(--radius-input);
  padding: 16px 24px;
  margin: 16px 0;
}

.case-msg p {
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.55;
}

.case-msg p + p {
  margin-top: 8px;
}

.case-msg-meta {
  font-size: 0.85rem !important;
  font-style: italic;
  margin-top: 16px !important;
  opacity: 0.85;
}

/* Actions row below the box — same shape across apply, delete, reviewer flows.
   Top margin is 0 because .case-msg's 16px bottom margin already supplies the gap. */
.case-msg-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0;
}

.case-msg-actions .btn--link {
  background: transparent;
  border: none;
  color: var(--cardinal);
  text-decoration: underline;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.case-msg-actions .btn--link:hover {
  color: var(--cardinal-dark, #3d0011);
}

.case-msg--check-email {
  background: #e3f2fd;
  border: 1px solid #bbdefb;
}

.case-msg--check-email p { color: #1565c0; }

.case-msg--check-email .em {
  font-weight: 700;
}

.case-msg--choice {
  background: #fff8e1;
  border: 1px solid #ffe082;
}

.case-msg--choice p { color: #5d4037; }

.case-msg--error {
  background: #fbe9e7;
  border: 1px solid #ffccbc;
}

.case-msg--error p { color: #c62828; }

.case-msg--warning {
  background: #fff3e0;
  border: 1px solid #ffe0b2;
}

.case-msg--warning p { color: #bf4500; }

/* --- Messages --- */
.apply-message {
  padding: 16px 20px;
  border-radius: var(--radius-input);
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.apply-message--info {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #bbdefb;
}

.apply-message--success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.apply-message--error {
  background: #fbe9e7;
  color: #c62828;
  border: 1px solid #ffccbc;
}

.apply-message--warning {
  background: #fff3e0;
  color: #bf4500;
  border: 1px solid #ffe0b2;
}

.apply-message ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.apply-message ul li {
  margin-bottom: 4px;
}

/* --- Form fields grid --- */
.apply-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
  align-items: end;
}

.apply-field {
  margin-bottom: 24px;
}

.apply-fields-grid > .apply-field {
  grid-column: 1 / -1; /* Full width by default */
}

.apply-fields-grid > .apply-field--narrow {
  grid-column: auto; /* Takes one column */
}

.apply-field-break {
  grid-column: 1 / -1;
  height: 0;
}

@media (max-width: 600px) {
  .apply-fields-grid {
    grid-template-columns: 1fr;
  }
  .apply-fields-grid > .apply-field--narrow {
    grid-column: 1 / -1;
  }
}

.apply-field-help {
  font-size: 0.75rem;
  /* --gray-400 is 2.21:1 on white and is for borders only; help text is real prose. */
  color: var(--gray-500, #6E6E73);
  margin: 0 0 2px;
  line-height: 1.3;
  font-style: italic;
}

.apply-field label,
.apply-field legend {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.95rem;
  color: var(--black);
}

.apply-field legend {
  padding: 0;
}

.apply-field fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.apply-field .form-input,
.apply-field .form-textarea {
  width: 100%;
}

.apply-field .form-input.is-invalid,
.apply-field .form-textarea.is-invalid,
.apply-field.is-invalid .form-input,
.apply-field.is-invalid .form-textarea {
  border-color: #c62828;
}

.apply-field .field-error {
  color: #c62828;
  font-size: 0.85rem;
  margin-top: 4px;
}

/* Required mark — global scope */
.required-mark {
  color: #c62828;
}

/* Field hint text */
.field-hint {
  font-size: 0.82rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* --- Segmented control (replaces radio buttons for enum fields) --- */
.segment-group {
  display: flex;
  border: 2px solid var(--gray-200, #E8E8ED);
  border-radius: var(--radius-input);
  overflow: hidden;
  background: var(--gray-100);
}

.segment-opt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: background 0.15s, color 0.15s;
  user-select: none;
  position: relative;
}

.segment-opt:not(:last-child) {
  border-right: 2px solid var(--gray-200, #E8E8ED);
}

.segment-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.segment-opt.is-selected {
  background: var(--cardinal);
  color: #fff;
  font-weight: 600;
}

.segment-opt:hover:not(.is-selected) {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* --- Inline field row (e.g. School + GPA side by side) --- */
.apply-field-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.apply-field-row > .apply-field {
  margin-bottom: 0;
}

.apply-field-row > .apply-field--grow {
  flex: 1;
}

.apply-field-row > .apply-field--fixed-sm {
  width: 130px;
  flex-shrink: 0;
}

/* --- Privacy notice --- */
.apply-privacy {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-input);
  padding: 20px 24px;
  margin: 32px 0 24px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--gray-600);
}

.apply-privacy h3 {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 8px;
}

/* --- Consent checkbox --- */
.apply-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 32px;
  cursor: pointer;
}

.apply-consent input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--cardinal);
  cursor: pointer;
  flex-shrink: 0;
}

.apply-consent span {
  font-size: 0.95rem;
  line-height: 1.5;
}

/* --- Eligibility summary --- */
.apply-eligibility {
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-radius: var(--radius-input);
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.apply-eligibility strong {
  color: #bf4500;
}

/* --- Action buttons --- */
.apply-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.apply-actions .btn {
  flex: 1;
  min-width: 160px;
}

/* --- Welcome toast (magic link return) --- */
.welcome-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2e7d32;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

.welcome-toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
}

.welcome-toast svg {
  flex-shrink: 0;
  color: #a5d6a7;
}

/* --- Confirmation card (delete-my-data) --- */
.apply-confirm {
  background: #fbe9e7;
  border: 1px solid #ffccbc;
  border-radius: var(--radius-input);
  padding: 24px;
  margin-bottom: 24px;
}

.apply-confirm p {
  margin-bottom: 8px;
}

.apply-confirm .confirm-warning {
  font-weight: 600;
  color: #c62828;
  margin-top: 16px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .apply-step {
    padding: 24px 20px;
  }

  .apply-id-grid {
    grid-template-columns: 1fr;
  }

  .apply-field-row {
    flex-direction: column;
  }

  .apply-field-row > .apply-field--fixed-sm {
    width: 100%;
  }

  .apply-actions {
    flex-direction: column;
  }

  .apply-actions .btn {
    width: 100%;
  }
}

/* ── Optional fields (SBF-6) ─────────────────────────────────────────────────────────────────── */
/* The counterpart to .required-mark. Saying "(optional)" outright beats the absence of an asterisk,
   which asks the applicant to notice something that is not there. */
.optional-mark {
  color: var(--gray-500, #6E6E73);
  font-weight: 400;
  font-size: 0.85em;
}

/* ── Character counter (SBF-7) ───────────────────────────────────────────────────────────────── */
/* The limits are part of the question design — a limit that makes a student choose what matters
   produces a better answer than one that rewards endurance. They only do that job if the applicant
   can see them. */
.apply-field-count {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--gray-500, #6E6E73);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.apply-field-count.is-near {
  color: #8a5a00;
}
.apply-field-count.is-over {
  color: #c62828;
  font-weight: 600;
}
.apply-field-count.is-over .apply-field-count-num {
  text-decoration: underline;
}

/* ============================================
   The scholarship page (scholarships/page.html)
   ============================================ */
/* The form sits on the page itself, below a hairline seam, rather than in its own card: the page
   above it already carries the award's name, requirements and dates, and a second framed block
   would read as a second page. The identity fields stay put and the disclosure opens beneath
   them, exactly as before — only the address changed. */
.sch-apply-seam {
  border-top: 1px solid var(--gray-200);
  margin-top: 36px;
  padding-top: 28px;
}

.sch-apply-seam .apply-step {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  border-top: 0;
}

/* Where the form would be, when there is no form: upcoming, closed, or complete without a winner. */
.sch-state-panel {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-input);
  padding: 28px 32px;
  text-align: center;
  margin-top: 8px;
}

.sch-state-panel h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.sch-state-panel p {
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

/* Awarded: the recipient, ahead of everything else on the page. */
.sch-winner {
  background: #ede7f6;
  border: 1px solid #d1c4e9;
  border-radius: var(--radius-input);
  padding: 28px 32px;
  text-align: center;
  margin-bottom: 28px;
}

.sch-winner-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4527a0;
  font-weight: 700;
}

.sch-winner-name {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--black);
  margin: 6px 0 4px;
}

.sch-winner p {
  color: var(--gray-600);
  font-size: 0.92rem;
  margin-bottom: 0;
}

.sch-state-actions {
  margin-top: 24px;
}

/* ── The read-only view after the deadline (js/apply-form.js makeReadOnly) ─────────────────── */
.apply-message--info { background: #f6f4f3; border-left: 4px solid var(--cardinal, #580018); color: var(--black, #1d1d1f); padding: 12px 16px; margin: 12px 0 20px; font-size: 0.95rem; }
.apply--view .form-input[readonly], .apply--view .form-textarea[readonly], .apply--view .form-input:disabled {
  background: #fafafa; border-color: var(--gray-300, #D2D2D7); color: var(--black, #1d1d1f); cursor: default; box-shadow: none;
}
.apply--view .segment-opt { cursor: default; }
.apply--view .segment-opt:not(.is-selected) { opacity: 0.55; }
.sch-state-view { margin: 12px 0 0; font-size: 0.95rem; }
.sch-state-view a { color: var(--cardinal, #580018); }

/* Printing the application: the browser's print of this page is the applicant's copy. No separate
   layout — the chrome goes, the disclosure is fully open, and the controls print as plain boxes. */
@media print {
  .site-header, .site-footer, .sch-state-panel .btn, .sch-state-actions, .sch-state-view, #turnstile-widget, .apply-actions, .welcome-toast, .field-checking-spinner { display: none !important; }
  .apply-disclosure { grid-template-rows: 1fr !important; }
  .apply-disclosure-inner { overflow: visible !important; }
  .apply--view .form-textarea, .apply--view .form-input { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; }
  .apply--view .segment-opt:not(.is-selected) { display: none; }
  a[href]::after { content: none !important; }
}
