/* ============================================================
   SHARED FORM STYLES
   Themes: mentor (poppy/earth) · youth (sunflower/amber)
   Font: Chillax (Fontshare)
   ============================================================ */

@font-face {
  font-family: "Chillax";
  src: url("/assets/Chillax-Variable-82b990fa.woff2") format("woff2-variations"),
       url("/assets/Chillax-Variable-079d7302.woff") format("woff");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --maf-text:         #fdf8f5;
  --maf-muted:        rgba(255, 255, 255, 0.60);
  --maf-input-bg:     rgba(0, 0, 0, 0.22);
  --maf-input-border: rgba(255, 255, 255, 0.18);
  --maf-input-focus:  rgba(255, 255, 255, 0.48);
  --maf-radius:       8px;

}

/* ── MENTOR THEME · poppies — deep earth brown + poppy red ── */
[data-theme="mentor"] {
  --maf-bg:      #2d1a10;
  --maf-primary: #c94840;
}
[data-theme="mentor"] .maf-photo { background-color: #1e1008; }

/* ── YOUTH GROUP THEME · autumn boardwalk — dark bark + amber leaf ── */
[data-theme="youth-group"] {
  --maf-bg:      #1e1608;
  --maf-primary: #c07830;
}
[data-theme="youth-group"] .maf-photo { background-color: #140f05; }

/* ── YOUTH THEME · dandelions — deep forest green + golden hour ── */
[data-theme="youth"] {
  --maf-bg:      #1a2018;
  --maf-primary: #d4a030;
}
[data-theme="youth"] .maf-photo { background-color: #111510; }

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

body {
  font-family: "Chillax", system-ui, sans-serif;
  background: #1a1008;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body:has([data-theme="mentor"]) { background: #2d1a10; }
body:has([data-theme="youth"])        { background: #1a2018; }
body:has([data-theme="youth-group"])  { background: #1e1608; }

/* ── SPLIT LAYOUT ─────────────────────────────────────────── */

.maf-wrap {
  display: flex;
  min-height: 100vh;
}

.maf-photo {
  width: 38%;
  min-width: 260px;
  background-size: cover;
  background-position: center;
  background-color: #1a1008;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.maf-panel {
  flex: 1;
  background: var(--maf-bg);
  color: var(--maf-text);
  display: flex;
  flex-direction: column;
}

/* ── PROGRESS BAR ─────────────────────────────────────────── */

.maf-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.maf-progress__fill {
  height: 100%;
  width: 100%;
  background: var(--maf-primary);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.35s ease;
}

/* ── BACK BUTTON ──────────────────────────────────────────── */

.maf-back {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--maf-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.15s;
  line-height: 1;
  margin-bottom: 2rem;
}
.maf-back:hover          { opacity: 1; }
.maf-back:focus-visible  { opacity: 1; outline: 2px solid rgba(255,255,255,0.6); outline-offset: 4px; border-radius: 4px; }

/* ── STEP CONTENT ─────────────────────────────────────────── */

.maf-intro-title {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.1;
  margin-bottom: 2rem;
}

.maf-intro-body {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--maf-muted);
  margin-bottom: 1.5rem;
}

.maf-intro-body + .maf-intro-body {
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.maf-step {
  padding: 2.5rem 3.5rem 2rem;
  max-width: 680px;
  width: 100%;
}

.maf-section-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1.2;
  margin-bottom: 2.25rem;
}

/* ── FIELDS ───────────────────────────────────────────────── */

.maf-field {
  margin-bottom: 1.625rem;
}

.maf-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.45rem;
  color: var(--maf-text);
}

.maf-label .req {
  color: var(--maf-primary);
  margin-left: 2px;
}

.maf-input,
.maf-textarea,
.maf-select {
  display: block;
  width: 100%;
  background: var(--maf-input-bg);
  border: 1px solid var(--maf-input-border);
  border-radius: var(--maf-radius);
  color: var(--maf-text);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.72rem 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
}

.maf-input::placeholder,
.maf-textarea::placeholder { color: var(--maf-muted); }

.maf-input:focus,
.maf-textarea:focus,
.maf-select:focus { border-color: var(--maf-input-focus); outline: none; }

.maf-input:focus-visible,
.maf-textarea:focus-visible,
.maf-select:focus-visible { outline: 2px solid var(--maf-primary); outline-offset: 2px; }

.maf-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.5)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.maf-select option { background: var(--maf-bg); color: var(--maf-text); background-color: var(--maf-bg); }

.maf-textarea { resize: vertical; min-height: 110px; }

/* Input with leading icon */
.maf-input-wrap { position: relative; }
.maf-input-wrap .maf-input { padding-left: 2.25rem; }
.maf-input-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--maf-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

/* ── LAYOUT HELPERS ───────────────────────────────────────── */

.maf-row {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.625rem;
}
.maf-row-2 { grid-template-columns: 1fr 1fr; }
.maf-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.maf-row .maf-field { margin-bottom: 0; }

.maf-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  margin: 2rem 0;
}

/* ── RADIO PILLS ──────────────────────────────────────────── */

.maf-radio-group { display: flex; flex-direction: column; gap: 0.6rem; }

.maf-radio-opt {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.72rem 1.125rem;
  border: 1px solid var(--maf-input-border);
  border-radius: var(--maf-radius);
  cursor: pointer;
  transition: border-color 0.2s;
  user-select: none;
}
.maf-radio-opt:hover,
.maf-radio-opt:focus-within { border-color: rgba(255, 255, 255, 0.4); outline: 2px solid var(--maf-primary); outline-offset: 2px; }
.maf-radio-opt:has(input:checked) { border-color: var(--maf-primary); }

.maf-radio-opt input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s;
}
.maf-radio-opt input[type="radio"]:checked { border-color: var(--maf-primary); }
.maf-radio-opt input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--maf-primary);
}

/* ── CHECKBOXES ───────────────────────────────────────────── */

.maf-check-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 520px) {
  .maf-check-grid { grid-template-columns: 1fr; }
}

.maf-check-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.72rem 1.125rem;
  border: 1px solid var(--maf-input-border);
  border-radius: var(--maf-radius);
  cursor: pointer;
  transition: border-color 0.2s;
  user-select: none;
}
.maf-check-opt:hover,
.maf-check-opt:focus-within { border-color: rgba(255, 255, 255, 0.4); outline: 2px solid var(--maf-primary); outline-offset: 2px; }
.maf-check-opt:has(input:checked) { border-color: var(--maf-primary); }

.maf-check-opt input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.maf-check-opt input[type="checkbox"]:checked {
  background: var(--maf-primary);
  border-color: var(--maf-primary);
}
.maf-check-opt input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ── CONDITIONAL REVEAL ───────────────────────────────────── */

.maf-conditional { margin-top: 1rem; }

/* ── REFERENCE BLOCK ──────────────────────────────────────── */

.maf-ref-block {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--maf-radius);
  padding: 1.5rem 1.5rem 0.25rem;
  margin-bottom: 1.5rem;
}
.maf-ref-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--maf-primary);
  margin-bottom: 1.25rem;
}

/* ── HELPER TEXT ──────────────────────────────────────────── */

.maf-helper {
  font-size: 0.8rem;
  color: var(--maf-muted);
  margin-top: 0.35rem;
  line-height: 1.5;
}

/* ── NAVIGATION ───────────────────────────────────────────── */

.maf-nav {
  margin-top: 2.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.maf-btn {
  background: var(--maf-primary);
  color: #fff;
  border: none;
  border-radius: var(--maf-radius);
  padding: 0.825rem 2.25rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s ease-out;
}
.maf-btn:hover          { opacity: 0.88; }
.maf-btn:active         { transform: translateY(-1px); }
.maf-btn:focus-visible  { opacity: 0.88; outline: 2px solid rgba(255,255,255,0.6); outline-offset: 2px; }

.maf-step-hint {
  font-size: 0.8rem;
  color: var(--maf-muted);
}

/* ── SUCCESS ──────────────────────────────────────────────── */

.maf-success {
  padding: 4rem 3.5rem;
  max-width: 560px;
}
.maf-success__check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--maf-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.75rem;
}
.maf-success__check svg { width: 32px; height: 32px; }
.maf-success__title {
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}
.maf-success__body { color: var(--maf-muted); line-height: 1.7; font-size: 1rem; }

/* ── ERRORS ───────────────────────────────────────────────── */

/* Highlight inputs that Rails marked as invalid */
.field_with_errors input,
.field_with_errors select,
.field_with_errors textarea {
  border-color: rgba(220, 60, 60, 0.7) !important;
  background-color: rgba(255, 80, 80, 0.04);
}

/* Error summary panel — stays visible above the active step */
.maf-error-summary {
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(220, 60, 60, 0.35);
  border-radius: var(--maf-radius);
  padding: 1rem 1.25rem;
  margin: 1rem 3.5rem 0;
  font-size: 0.875rem;
}

.maf-error-summary__title {
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: rgba(255, 200, 200, 0.95);
}

.maf-error-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.75rem;
}

.maf-error-item {
  background: none;
  border: none;
  padding: 0.15rem 0;
  text-align: left;
  cursor: pointer;
  color: rgba(255, 180, 180, 0.9);
  font-size: 0.875rem;
  font-family: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 180, 180, 0.35);
  text-underline-offset: 2px;
  line-height: 1.5;
}

.maf-error-item:hover {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.6);
}

/* Per-field inline errors (rendered by the form-steps Stimulus controller) */
.maf-field--invalid input,
.maf-field--invalid select,
.maf-field--invalid textarea {
  border-color: rgba(220, 60, 60, 0.7);
  background-color: rgba(255, 80, 80, 0.04);
}

.maf-inline-error {
  margin: 0.35rem 0 0;
  color: rgba(255, 160, 160, 0.9);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ── MOBILE ───────────────────────────────────────────────── */

@media (max-width: 780px) {
  .maf-wrap { flex-direction: column; }

  .maf-photo {
    width: 100%;
    height: 220px;
    position: static;
  }

  .maf-step { padding: 2rem 1.25rem 2.5rem; }
  .maf-error-summary { margin: 0.75rem 1.25rem 0; }

  .maf-row-2,
  .maf-row-3 { grid-template-columns: 1fr; }

  .maf-section-title { font-size: 1.4rem; }
}
