/* =============================================================
   VEEDAY CONSULTANTS — forms.css
   Shared form design system for requirement.html and resume.html.
   Loaded AFTER veeday.css (tokens, buttons) and pages.css (.hidden, .flex).

   Markup cheat-sheet
   ------------------
   <section class="form-shell">                      sand ground
     <div class="wrap">
       <div class="form-card">                       paper card, max 860px
         <form class="form">
           <div class="form-banner hidden">…</div>   error banner (script removes .hidden)
           <section class="form-section">
             <header class="form-section__head">
               <h2 class="form-section__title">Title</h2>
             </header>
             <div class="form-grid">
               <label class="field [field--full]">   wrap input/textarea in the label
                 <span class="label">Name <span class="req">*</span> <span class="opt">(optional)</span></span>
                 <input class="input"> | <textarea class="textarea">
               </label>
               <div class="field">                   selects / custom widgets: use a div, NOT a wrapping
                 <label class="label" for="id">…</label>   label (a wrapping label re-clicks the hidden
                 <select class="select">…</select>          select and closes the cs dropdown)
                 <div class="field__other hidden"><input class="input"></div>
               </div>
               <div class="field field--full">
                 <span class="label">…</span>
                 <div class="choices"> <label class="choice"><input type="radio|checkbox"><span>…</span></label> … </div>
                 <p class="field-msg field-msg--error hidden">…</p>
               </div>
             </div>
           </section>
           <div class="form-consent"> <label class="consent"><input type="checkbox"><span>…</span></label> </div>
           <button class="btn btn--red btn--lg form-submit"><svg class="spin hidden">…</svg><span>…</span></button>
           <p class="form-note">…</p>
   ============================================================= */

:root {
  --form-red-tint: rgba(200, 32, 26, .07);
  --form-red-ring: rgba(200, 32, 26, .18);
  --form-control-h: 48px;
  --form-radius: 6px;
  --form-ph: rgba(17, 17, 17, .5);
}

/* ── Shell and card ── */
.form-shell { background: var(--sand); padding: clamp(28px, 6vw, 88px) 0 clamp(56px, 8vw, 112px); }
.form-card {
  max-width: 860px; margin: 0 auto;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 30px 60px -44px rgba(18, 16, 15, .45);
  /* no overflow:hidden here: the custom select / date panels must be able to overhang */
}
.form { padding: clamp(22px, 5vw, 56px); }
.form-shell__foot { max-width: 860px; margin: 22px auto 0; text-align: center; font-size: 12.5px; letter-spacing: .04em; color: var(--mute); }

/* ── Numbered section header: red number, serif title, hairline ── */
.form-section { padding-bottom: clamp(30px, 4.5vw, 46px); margin-bottom: clamp(30px, 4.5vw, 46px); border-bottom: 1px solid var(--line); }
.form-section__head { display: flex; align-items: baseline; gap: 14px; margin-bottom: clamp(20px, 3vw, 30px); }
.form-section__title { font-family: var(--serif); font-weight: 400; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.18; letter-spacing: -.015em; color: var(--ink); }
.form-section__title em { font-style: italic; color: var(--red); }
.form-section__hint { margin: -10px 0 22px; font-size: 14px; line-height: 1.6; color: var(--mute); }

/* ── Field grid: one column on phones, two from 700px ── */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.field { display: block; min-width: 0; }
@media (min-width: 700px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 20px; }
  .form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field--full { grid-column: 1 / -1; }
}

/* ── Labels ── */
.label { display: block; margin-bottom: 8px; font-size: 13.5px; font-weight: 500; line-height: 1.4; color: var(--ink); }
.req { color: var(--red); font-weight: 600; }
.opt { font-size: 12.5px; font-weight: 400; color: var(--mute); }

/* ── Text inputs, textarea, native select (touch phones, and the fallback when JS is off) ── */
.input, .textarea, .select {
  display: block; width: 100%; max-width: 100%; min-width: 0;
  min-height: var(--form-control-h); padding: 11px 14px;
  font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--ink);
  background-color: #fff;
  border: 1px solid var(--line); border-radius: var(--form-radius);
  -webkit-appearance: none; appearance: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input { height: var(--form-control-h); }
.textarea { min-height: 112px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--form-ph); opacity: 1; }
.input:hover, .textarea:hover, .select:hover { border-color: rgba(17, 17, 17, .3); }
.input:focus, .textarea:focus, .select:focus,
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--form-red-ring);
}
.input[type="number"] { -moz-appearance: textfield; }
.select {
  height: var(--form-control-h); padding-right: 42px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23C8201A' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
/* native selects stay visible on touch phones (the page scripts only build the custom dropdown for fine pointers):
   show the empty "Select …" choice in placeholder grey, like the inputs */
.select:has(option[value=""]:checked) { color: var(--form-ph); }
.select option { color: var(--ink); }
/* free-text box revealed under a select when "Other" is chosen */
.field__other { margin-top: 10px; }

/* ── Native date input (fallback; resume.html swaps it for the cd-* picker) ── */
.input[type="date"] { cursor: pointer; }
.input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .8; filter: invert(20%) sepia(90%) saturate(2500%) hue-rotate(346deg) brightness(85%); }

/* ── Custom select (built by the page script around every <select>) ── */
.cs-wrap, .cd-wrap { position: relative; width: 100%; }
.cs-trigger, .cd-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: var(--form-control-h); padding: 11px 14px;
  font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--form-radius);
  cursor: pointer; -webkit-user-select: none; user-select: none;
  transition: border-color .2s, box-shadow .2s;
}
.cs-trigger:hover, .cd-trigger:hover { border-color: rgba(17, 17, 17, .3); }
.cs-trigger:focus, .cd-trigger:focus,
.cs-wrap.cs-open .cs-trigger, .cd-wrap.cd-open .cd-trigger {
  outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--form-red-ring);
}
.cs-value, .cd-display { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-value.cs-placeholder, .cd-display.cd-placeholder { color: var(--form-ph); }
.cs-arrow { flex: none; transition: transform .25s var(--ease); }
.cs-wrap.cs-open .cs-arrow { transform: rotate(180deg); }
.cs-wrap.cs-open, .cd-wrap.cd-open { z-index: 60; }
.cs-dropdown, .cd-panel {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: var(--form-radius);
  box-shadow: 0 24px 48px -20px rgba(18, 16, 15, .38), 0 2px 8px rgba(18, 16, 15, .06);
}
.cs-dropdown { max-height: 280px; overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.cs-wrap.cs-open .cs-dropdown, .cd-wrap.cd-open .cd-panel { display: block; animation: csIn .18s ease; }
@keyframes csIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cs-dropdown::-webkit-scrollbar { width: 4px; }
.cs-dropdown::-webkit-scrollbar-thumb { background: rgba(200, 32, 26, .35); border-radius: 4px; }
.cs-option {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 9px 12px;
  font-size: 15px; line-height: 1.35; color: var(--ink); border-radius: 4px; cursor: pointer;
  transition: background .12s, color .12s;
}
.cs-option:hover { background: var(--form-red-tint); color: var(--red); }
.cs-option.cs-active { background: var(--form-red-tint); color: var(--red); font-weight: 600; }
.cs-option.cs-active::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.cs-option.cs-placeholder-opt {
  min-height: 0; padding: 8px 12px 9px; margin-bottom: 4px; border-radius: 0; border-bottom: 1px solid var(--line);
  font-size: 10.5px; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; color: var(--mute); cursor: default;
}
.cs-option.cs-placeholder-opt:hover { background: transparent; color: var(--mute); }

/* ── Custom date picker (cd-*, built by the resume page script around input[type=date]) ── */
.cd-trigger svg { flex: none; }
.cd-panel { max-width: 340px; padding-bottom: 4px; }
.cd-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.cd-nav { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--form-radius); background: #fff; color: var(--red); cursor: pointer; transition: background .15s, border-color .15s; }
.cd-nav:hover:not(:disabled) { background: var(--form-red-tint); border-color: var(--red); }
.cd-nav:disabled { opacity: .3; cursor: not-allowed; }
/* month + year jump selects between the arrows (native selects: phones get their own picker) */
.cd-selects { display: flex; flex: 1; min-width: 0; justify-content: center; gap: 6px; margin: 0 8px; }
.cd-header select {
  min-width: 0; height: 44px; min-height: 44px; padding: 0 26px 0 10px;
  font-family: var(--sans); font-size: 16px; line-height: 1.2; color: var(--ink);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23C8201A' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 9px center;
  border: 1px solid var(--line); border-radius: var(--form-radius); cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.cd-header select:focus-visible { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--form-red-ring); }
.cd-dow, .cd-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 0 10px; }
.cd-grid { padding-bottom: 10px; }
.cd-dow span { padding: 6px 0; text-align: center; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.cd-day { display: flex; align-items: center; justify-content: center; min-height: 44px; font-size: 14px; line-height: 1; color: var(--ink); border: 1px solid transparent; border-radius: 4px; }
.cd-day:not(.cd-empty):not(.cd-disabled) { cursor: pointer; transition: background .12s, color .12s; }
.cd-day:not(.cd-empty):not(.cd-disabled):hover { background: var(--form-red-tint); color: var(--red); }
.cd-today { border-color: rgba(200, 32, 26, .35); color: var(--red); font-weight: 600; }
.cd-selected { background: var(--red) !important; color: var(--paper) !important; border-color: transparent !important; font-weight: 600; }
.cd-disabled { color: rgba(17, 17, 17, .28); }
.cd-empty { cursor: default; }

/* ── Radio / checkbox options as tappable pills (.choices) or full rows (.choices--rows) ── */
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choices--rows { flex-direction: column; flex-wrap: nowrap; }
.choices--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.choice {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 10px 18px 10px 14px;
  font-size: 15px; line-height: 1.35; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.choices--rows .choice, .choices--grid .choice { display: flex; border-radius: var(--form-radius); }
.choice:hover { border-color: rgba(17, 17, 17, .34); }
.choice:has(input:checked) { border-color: var(--red); background: var(--form-red-tint); }
.choice:has(input:focus-visible) { border-color: var(--red); box-shadow: 0 0 0 3px var(--form-red-ring); }
.choice input, .consent input {
  flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--red); cursor: pointer;
}
.choice input:focus-visible { outline: none; }

/* ── Consent row: checkbox + long wording ── */
.form-consent { margin-bottom: clamp(22px, 3vw, 30px); }
.form-consent + .form-consent { margin-top: -8px; }
.consent {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px; min-height: 48px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--form-radius);
  font-size: 14.5px; line-height: 1.65; color: var(--mute); cursor: pointer;
  transition: border-color .2s;
}
.consent:hover { border-color: rgba(17, 17, 17, .3); }
.consent:has(input:checked) { border-color: rgba(200, 32, 26, .55); }
.consent input { margin-top: 3px; }
.consent a, .form a.form-link { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }
.consent a:hover, .form a.form-link:hover { color: var(--red-deep); }

/* ── Help and error text under a field ── */
.field-msg { margin-top: 8px; font-size: 13px; line-height: 1.5; color: var(--mute); }
.field-msg--error { color: var(--red-deep); font-weight: 500; }
.form-consent .field-msg { margin-left: 2px; }

/* ── Invalid control (class added by the script) ── */
.field-error,
.cs-trigger.field-error, .cd-trigger.field-error {
  border-color: var(--red) !important; background-color: #FDF3F2 !important;
  box-shadow: 0 0 0 3px rgba(200, 32, 26, .14) !important;
}

/* ── Error banner at the top of the form ── */
.form-banner {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 26px; padding: 14px 16px;
  font-size: 14.5px; line-height: 1.55; font-weight: 500; color: var(--red-deep);
  background: #FBECEA; border: 1px solid rgba(200, 32, 26, .32); border-left: 3px solid var(--red); border-radius: var(--form-radius);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.form-banner svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }

/* ── File upload drop area ──
   <label class="form-drop"><input type="file" …><span class="form-drop__title">…</span><span class="form-drop__hint">…</span></label>
   plus .form-drop.is-drag / .form-drop.has-file states and a .form-file row for the chosen file */
.form-drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 132px; padding: 22px 18px; text-align: center;
  background: #fff; border: 1px dashed rgba(17, 17, 17, .32); border-radius: var(--form-radius);
  cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s;
}
.form-drop:hover, .form-drop.is-drag, .form-drop.dragover { border-color: var(--red); background: var(--form-red-tint); }
.form-drop:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--form-red-ring); }
.form-drop.has-file { border-style: solid; border-color: rgba(200, 32, 26, .55); }
.form-drop.field-error { border-style: solid; }
.form-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.form-drop__icon { width: 26px; height: 26px; color: var(--red); }
.form-drop__title { font-size: 15px; font-weight: 500; color: var(--ink); }
.form-drop__title b { color: var(--red); font-weight: 600; }
.form-drop__hint { font-size: 13px; color: var(--mute); }
.form-file { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; font-size: 14px; color: var(--ink); background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--form-radius); word-break: break-all; }
/* plain visible file input, if a page prefers it */
.input[type="file"] { height: auto; padding: 10px 12px; font-size: 14.5px; cursor: pointer; }
.input[type="file"]::file-selector-button { margin-right: 12px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 500; color: var(--paper); background: var(--ink); border: 0; border-radius: 999px; cursor: pointer; }

/* ── Submit button (.btn .btn--red .btn--lg .form-submit) + spinner ── */
.form-submit { width: 100%; min-height: 56px; font-size: 16px; font-weight: 600; text-align: center; }
/* on a paper card the stock red→paper hover would vanish, so go to ink instead.
   Only on devices that really hover: a phone keeps :hover after a tap, which would leave the button ink/white. */
@media (hover: hover) {
  .form-card .btn--red:hover, .success-popup .btn--red:hover { --b-bg: var(--ink); --b-fg: var(--paper); --b-bd: var(--ink); }
}
@media (hover: none) {
  .form-card .btn--red:hover, .success-popup .btn--red:hover { --b-bg: var(--red); --b-fg: var(--paper); --b-bd: var(--red); }
}
.form-submit:disabled, .form-submit[disabled] { opacity: .6; cursor: not-allowed; --b-bg: var(--red); --b-fg: var(--paper); --b-bd: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { flex: none; width: 18px; height: 18px; animation: spin .7s linear infinite; }
.form-note { margin-top: 14px; text-align: center; font-size: 13px; line-height: 1.6; color: var(--mute); }

/* ── Small entrance used by scripts that add .fade-in ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .4s ease forwards; }

/* ── Success popup: ink card, paper panel ──
   <div id="successPopup" class="success-popup hidden">   script: remove .hidden, add .flex
     <div id="successPopupCard" class="success-popup__card">   script overwrites its inline style to animate
       <div class="success-popup__head"> <span class="success-popup__icon"><svg/></span> <p class="success-popup__eyebrow"> <h2 class="success-popup__title">
       <div class="success-popup__panel"> <p>… <button class="btn btn--red success-popup__btn"> <p class="success-popup__count"> */
.success-popup {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
  background: rgba(18, 16, 15, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.success-popup__card {
  position: relative; width: 100%; max-width: 440px; margin: auto;
  background: var(--ink); color: var(--paper);
  border: 1px solid rgba(250, 250, 248, .14); border-radius: 10px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7);
  padding: 8px;
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease;
}
.success-popup__head { padding: 26px 22px 24px; text-align: center; }
.success-popup__icon { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%; border: 1px solid rgba(250, 250, 248, .28); color: var(--paper); background: var(--red); }
.success-popup__icon svg { width: 26px; height: 26px; }
.success-popup__eyebrow { margin-bottom: 10px; font-size: 10.5px; font-weight: 600; letter-spacing: .17em; text-transform: uppercase; color: #F0554E; }
.success-popup__title { font-family: var(--serif); font-weight: 400; font-size: clamp(26px, 6vw, 32px); line-height: 1.12; letter-spacing: -.015em; color: var(--paper); }
.success-popup__title em { font-style: italic; color: #F0554E; }
.success-popup__panel { padding: 24px 22px 20px; text-align: center; background: var(--paper); color: var(--ink); border-radius: 6px; }
.success-popup__panel p { font-size: 15px; line-height: 1.65; color: rgba(17, 17, 17, .72); margin-bottom: 12px; }
.success-popup__panel strong { color: var(--ink); }
.success-popup__btn { width: 100%; min-height: 50px; margin-top: 10px; text-align: center; }
.success-popup__panel .success-popup__count { min-height: 1.3em; margin: 12px 0 0; font-size: 12.5px; color: rgba(17, 17, 17, .64); }

/* ── Phones ── */
@media (max-width: 520px) {
  .form-card { border-radius: 6px; }
  .choices:not(.choices--rows):not(.choices--grid) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices:not(.choices--rows):not(.choices--grid) .choice { border-radius: var(--form-radius); padding-right: 12px; padding-left: 12px; gap: 8px; }
  /* one card gutter instead of two stacked ones, so inputs and two-up pills get room ("WhatsApp" fits) */
  .form { padding: 22px 16px; }
  .cd-header { padding: 10px 10px 8px; }
  /* at 320px the month/year selects would clip ("Ja", "199"): slimmer arrows and select padding */
  .cd-header .cd-nav { width: 36px; }
  .cd-selects { gap: 4px; margin: 0 4px; }
  .cd-header select { padding: 0 22px 0 8px; background-position: right 6px center; }
  .consent { padding: 14px; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-wrap.cs-open .cs-dropdown, .cd-wrap.cd-open .cd-panel, .fade-in { animation: none; }
  .spin { animation-duration: 1.4s; }
}

@media (max-width: 700px) {
  .form-shell__foot { font-size: 13.5px; line-height: 1.6; }
}
