/* =========================================================
   SOVA Foundation — Grant Application form
   Shared tokens/header/footer come from ../styles.css
   ========================================================= */
.af-hero { padding-bottom: clamp(1.5rem, 3vw, 2.5rem); }
.af-hero__title { margin-bottom: 0; }
.af-section { padding-top: clamp(1rem, 2vw, 1.5rem); }
.af-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Progress — stepper */
.af-prog { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: clamp(1.6rem, 3.5vw, 2.4rem); counter-reset: none; }
.af-prog__item { position: relative; display: flex; flex-direction: column; align-items: center; gap: .7rem; text-align: center; padding: 0 .4rem; color: var(--ink-faint); font-size: .82rem; font-weight: 600; line-height: 1.3; }
.af-prog__item::before { content: ""; position: absolute; top: 24px; left: -50%; right: 50%; height: 2px; background: var(--line); z-index: 0; transition: background .5s var(--ease); }
.af-prog__item:first-child::before { display: none; }
.af-prog__item.is-done::before, .af-prog__item.is-current::before { background: var(--teal); }
.af-prog__dot { position: relative; z-index: 1; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 2px solid var(--line); color: var(--ink-soft); font-family: var(--serif); font-size: 1.3rem; transition: background .4s var(--ease), border-color .4s var(--ease), color .4s var(--ease), box-shadow .4s var(--ease); }
.af-prog__name { max-width: 14ch; }
.af-prog__item.is-current { color: var(--teal); }
.af-prog__item.is-current .af-prog__dot { background: var(--lime); border-color: var(--teal); color: var(--teal-900); box-shadow: 0 0 0 6px rgba(221,224,140,.35); }
.af-prog__item.is-done { color: var(--ink); }
.af-prog__item.is-done .af-prog__dot { background: var(--teal); border-color: var(--teal); color: transparent; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dde08c' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l4 4L19 6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: center; background-size: 22px; }

/* Form card */
.af { padding: clamp(1.4rem, 3.5vw, 2.6rem); border-radius: var(--radius); background: var(--card); border: 1px solid var(--line-2); }
.af-step__title { font-family: var(--serif); font-weight: 500; font-size: clamp(1.8rem, 3.2vw, 2.6rem); line-height: 1.1; color: var(--ink); margin-bottom: clamp(1.2rem, 2.6vw, 1.8rem); outline: none; }
.af-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.3rem 1.6rem; }
.af-field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; border: 0; padding: 0; margin: 0; }
.af-field--wide { grid-column: 1 / -1; }
.af-label { font-weight: 600; font-size: .95rem; color: var(--ink); line-height: 1.4; padding: 0; }
.af-req { color: #b0466b; margin-left: .15rem; }
.af-hint { font-size: .84rem; color: var(--ink-soft); line-height: 1.45; }
.af-input { width: 100%; padding: .85rem 1rem; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 1rem; transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease); }
.af-input::placeholder { color: var(--ink-faint); opacity: 1; font-size: .92rem; }
.af-select:invalid, .af-select option[value=""] { color: var(--ink-faint); }
.af-input:hover { border-color: rgba(14,92,79,.35); }
.af-input:focus { outline: none; border-color: var(--teal); background: var(--card); box-shadow: 0 0 0 4px rgba(14,92,79,.12); }
.af-textarea { resize: vertical; min-height: 7.5rem; line-height: 1.5; }
.af-select { appearance: none; -webkit-appearance: none; padding-right: 2.6rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230e5c4f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 18px; }
.af-multi { min-height: 11rem; padding: .5rem; }
.af-multi option { padding: .35rem .6rem; border-radius: 8px; }
.af-multi option:checked { background: var(--teal) linear-gradient(var(--teal), var(--teal)); color: var(--cream); }
.af-count { align-self: flex-end; font-size: .78rem; color: var(--ink-faint); }
.af-count.is-over { color: #b0466b; font-weight: 700; }
.af-error { min-height: 0; font-size: .82rem; color: #b0466b; font-weight: 600; }
.af-error:empty { display: none; }
.af-field.is-invalid .af-input, .af-field.is-invalid .af-file { border-color: #b0466b; }

/* Chips (radio / checkbox options) */
.af-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .2rem; }
.af-chip { position: relative; cursor: pointer; }
.af-chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.af-chip span { display: inline-flex; align-items: center; padding: .65rem 1.05rem; border-radius: 100px; border: 1.5px solid var(--line); background: var(--bg); font-size: .9rem; font-weight: 600; color: var(--ink-soft); transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease); }
.af-chip:hover span { border-color: rgba(14,92,79,.4); color: var(--ink); }
.af-chip input:checked + span { background: var(--teal); border-color: var(--teal); color: var(--cream); }
.af-chip input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 3px; }

.af-sub { display: flex; flex-direction: column; gap: .4rem; margin-top: 1rem; }
.af-sub[hidden] { display: none; }
.af-note { margin-top: .6rem; padding: .9rem 1.1rem; border-radius: var(--radius-sm); background: rgba(221,224,140,.3); font-size: .9rem; color: var(--ink); }
.af-cond { display: flex; flex-direction: column; gap: .2rem; }
.af-cond__title { font-family: var(--serif); font-weight: 500; font-size: 1.4rem; color: var(--teal); margin-top: .4rem; }
.af-cond:not(:has(.af-sub:not([hidden]))) { display: none; }

/* File upload */
.af-file { position: relative; display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; border-radius: 14px; border: 1.5px dashed var(--line); background: var(--bg); cursor: pointer; transition: border-color .3s var(--ease), background .3s var(--ease); }
.af-file:hover { border-color: var(--teal); background: var(--card); }
.af-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.af-file:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(14,92,79,.12); }
.af-file__icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--teal); color: var(--lime); }
.af-file__icon svg { width: 20px; height: 20px; }
.af-file__name { font-size: .92rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.af-file.has-file { border-style: solid; border-color: var(--teal); }
.af-file.has-file .af-file__name { color: var(--ink); font-weight: 600; }

/* Declarations */
.af-decl { gap: .6rem; }
.af-check { display: flex; align-items: flex-start; gap: .8rem; padding: .85rem 1rem; border-radius: 14px; background: var(--bg); border: 1.5px solid var(--line-2); cursor: pointer; line-height: 1.45; font-size: .95rem; transition: border-color .3s var(--ease); }
.af-check:hover { border-color: rgba(14,92,79,.35); }
.af-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.af-check__box { flex: none; width: 22px; height: 22px; margin-top: .05rem; border-radius: 6px; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; transition: background .25s var(--ease), border-color .25s var(--ease); }
.af-check input:checked + .af-check__box { background: var(--teal); border-color: var(--teal); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dde08c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l4 4L19 6'/%3E%3C/svg%3E"); background-size: 14px; background-repeat: no-repeat; background-position: center; }
.af-check input:focus-visible + .af-check__box { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Nav */
.af-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: clamp(1.6rem, 3vw, 2.2rem); padding-top: 1.4rem; border-top: 1px solid var(--line); }
.af-nav__count { white-space: nowrap; font-family: var(--serif); font-style: italic; font-size: 1.15rem; color: var(--teal); margin-inline: auto; }
.af-prev, .af-next { width: 58px; height: 58px; padding: 0; justify-content: center; border-radius: 50%; }
.af-prev svg, .af-next svg { width: 20px; height: 20px; }
.af-prev[hidden], .af-next[hidden], .af-submit[hidden] { display: none; }

/* Done */
.af-done { max-width: 720px; margin: 0 auto; text-align: center; padding: clamp(2rem, 5vw, 3.5rem); border-radius: var(--radius); background: var(--teal-900); color: var(--cream); outline: none; }
.af-done[hidden] { display: none; }
.af-done__icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--lime); color: var(--teal-900); margin-bottom: 1.2rem; }
.af-done__icon svg { width: 30px; height: 30px; }
.af-done__title { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 4vw, 2.8rem); color: var(--lime); margin-bottom: .8rem; }
.af-done__text { color: rgba(251,247,236,.85); font-size: 1.05rem; }
.af-done__ref { margin-top: 1.4rem; display: inline-block; padding: .7rem 1.3rem; border-radius: 100px; background: rgba(251,247,236,.08); border: 1px solid var(--line-light); font-family: var(--serif); font-size: 1.35rem; color: var(--lime); letter-spacing: .04em; }
.af-done__ref:empty { display: none; }
.af-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.af-form-error { margin-top: 1.4rem; padding: .9rem 1.2rem; border-radius: 14px; background: rgba(176,70,107,.08); border: 1px solid rgba(176,70,107,.3); color: #b0466b; font-size: .92rem; font-weight: 600; line-height: 1.45; }
.af-submit.is-loading { opacity: .7; cursor: progress; }

@media (max-width: 980px) {
  .af-prog__name { display: none; }
  .af-prog__item::before { top: 20px; }
  .af-prog__dot { width: 42px; height: 42px; font-size: 1.15rem; }
}
@media (max-width: 680px) {
  .af-grid { grid-template-columns: minmax(0, 1fr); }
  .af { padding: 1.2rem; }
  .af-nav { gap: .6rem; }
  .af-chips { gap: .35rem; }
  .af-chip span { padding: .45rem .75rem; font-size: .8rem; line-height: 1.3; }
  .af-prev, .af-next { width: 48px; height: 48px; }
  .af-submit { padding: .8rem 1.3rem; font-size: .92rem; white-space: nowrap; }
  .af-nav__count { font-size: 1rem; }
  .af-prog__item::before { top: 17px; }
  .af-prog__dot { width: 36px; height: 36px; font-size: 1rem; }
  .af-prog__item.is-current .af-prog__dot { box-shadow: 0 0 0 4px rgba(221,224,140,.35); }
}
@media (prefers-reduced-motion: reduce) {
  .af-input, .af-chip span, .af-file, .af-check, .af-check__box, .af-prog__item { transition: none; }
}

/* ---------- Custom dropdown ---------- */
.dd__native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; }
.dd { position: relative; min-width: 0; }
.dd__btn { min-width: 0; width: 100%; }
.af-grid > .af-field { min-width: 0; }
.dd__btn { display: flex; align-items: center; justify-content: space-between; gap: .8rem; text-align: left; cursor: pointer; }
.dd__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd__value.is-placeholder { color: var(--ink-faint); font-size: .92rem; }
.dd__chev { flex: none; width: 18px; height: 18px; color: var(--teal); transition: transform .3s var(--ease); }
.dd.is-open .dd__chev { transform: rotate(180deg); }
.dd.is-open .dd__btn { border-color: var(--teal); background: var(--card); box-shadow: 0 0 0 4px rgba(14,92,79,.12); }
.dd__panel { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 30; padding: .4rem; border-radius: 16px; background: var(--card); border: 1px solid var(--line-2); box-shadow: 0 30px 60px -24px rgba(7,51,42,.35); opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .25s var(--ease), transform .25s var(--ease), visibility 0s .25s; }
.dd.is-open .dd__panel { opacity: 1; visibility: visible; transform: none; transition: opacity .25s var(--ease), transform .25s var(--ease); }
.dd__search { width: 100%; margin-bottom: .35rem; padding: .65rem .85rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); font: inherit; font-size: .92rem; color: var(--ink); }
.dd__search:focus { outline: none; border-color: var(--teal); }
.dd__list { list-style: none; max-height: 16rem; overflow-y: auto; overscroll-behavior: contain; }
.dd__opt { position: relative; padding: .65rem .85rem .65rem 2.1rem; border-radius: 10px; font-size: .95rem; color: var(--ink); cursor: pointer; line-height: 1.35; }
.dd__opt[hidden] { display: none; }
.dd__opt.is-active { background: var(--bg-2); }
.dd__opt.is-selected { background: var(--teal); color: var(--cream); }
.dd__opt.is-selected::before { content: ""; position: absolute; left: .75rem; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dde08c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l4 4L19 6'/%3E%3C/svg%3E") center / contain no-repeat; }
.dd--multi .dd__opt::after { content: ""; position: absolute; left: .7rem; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); border-radius: 5px; border: 1.5px solid var(--line); }
.dd--multi .dd__opt.is-selected::after { border-color: var(--lime); }
.af-field.is-invalid .dd__btn { border-color: #b0466b; }
@media (prefers-reduced-motion: reduce) { .dd__panel, .dd__chev { transition: none; } }

/* Row alignment: paired fields share label / hint / control / message rows */
@supports (grid-template-rows: subgrid) {
  .af-grid > div.af-field:not(.af-field--wide) { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: .4rem; align-content: start; }
  .af-grid > div.af-field:not(.af-field--wide) > .af-label { grid-row: 1; align-self: end; }
  .af-grid > div.af-field:not(.af-field--wide) > .af-hint { grid-row: 2; }
  .af-grid > div.af-field:not(.af-field--wide) > .af-input,
  .af-grid > div.af-field:not(.af-field--wide) > .dd,
  .af-grid > div.af-field:not(.af-field--wide) > .af-file { grid-row: 3; align-self: start; }
  .af-grid > div.af-field:not(.af-field--wide) > .af-error,
  .af-grid > div.af-field:not(.af-field--wide) > .af-count { grid-row: 4; }
  .af-grid { row-gap: 0; }
  .af-grid > div.af-field:not(.af-field--wide) { margin-bottom: 1.3rem; }
  .af-grid > .af-field--wide { margin-bottom: 1.3rem; }
}

.af-prog--clickable .af-prog__item { cursor: pointer; }
.af-prog--clickable .af-prog__item:hover .af-prog__dot { border-color: var(--teal); }

.af-decl > legend { margin-bottom: .9rem; }
