/* Form controls kit (agency-7-frontend). Every field, dropdown, checkbox, radio, file input and
   date or time picker drawn to the brand, for any form marked class="fc" (or any wrapper of forms).
   Copy this file into site/ unchanged and load it after the site's own stylesheet. It carries NO
   colours or fonts of its own: the site maps its brand tokens onto the --fc-* variables (see
   references/form-controls.md), and a missing one shows up as a broken control, never as a default.

   What draws what:
   - fields, selects (closed), checkboxes, radios: CSS below, every browser
   - the open dropdown list: CSS below (appearance: base-select), Chrome and Edge 135+. Safari and
     Firefox open their own list, themed light or dark by color-scheme
   - file inputs: form-controls.js wraps each in a drop zone; without JS the button is still styled
   - date, time and datetime-local: form-controls.js swaps the browser's popup for the branded one
     below, because no browser lets CSS style its own calendar popup */

.fc {
  /* Required, set by the site (no fallbacks on purpose):
     --fc-font --fc-ink --fc-muted --fc-line --fc-field --fc-card
     --fc-accent --fc-on-accent --fc-hover --fc-radius --fc-radius-pop */
  --fc-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --fc-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E");
  --fc-cal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  --fc-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E");
  --fc-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15V4M7.5 8.5 12 4l4.5 4.5M4 15v3.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V15'/%3E%3C/svg%3E");
}

/* ---------- text fields, selects, textareas ---------- */
.fc :is(input:not([type=checkbox],[type=radio],[type=file],[type=range],[type=color],[type=submit],[type=button],[type=reset],[type=hidden],[type=image]), select, textarea) {
  box-sizing: border-box; display: block; width: 100%; min-height: 46px; margin: 0;
  padding: 10px 14px; border: 1.5px solid var(--fc-line); border-radius: var(--fc-radius);
  background-color: var(--fc-field); color: var(--fc-ink); font: 400 1rem/1.4 var(--fc-font);
  caret-color: var(--fc-accent); transition: border-color .15s, box-shadow .15s;
}
.fc textarea { min-height: 110px; resize: vertical; }
.fc :is(input, textarea)::placeholder { color: var(--fc-muted); opacity: 1; }
.fc :is(input, select, textarea):hover { border-color: var(--fc-muted); }
.fc :is(input, select, textarea):focus-visible,
.fc :is(input, select, textarea):focus { outline: none; border-color: var(--fc-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc-accent) 30%, transparent); }
.fc :is(input, select, textarea):is(:autofill, :-webkit-autofill) { -webkit-text-fill-color: var(--fc-ink); box-shadow: 0 0 0 100px var(--fc-field) inset; }
.fc :is(input, select, textarea)[aria-invalid=true] { border-color: var(--fc-accent); }

/* selects: the closed field, every browser */
.fc select:not([multiple]):not([size]) {
  appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer;
  background-image: none;
}
.fc .fc-select { position: relative; display: block; }
.fc select option { background-color: var(--fc-card); color: var(--fc-ink); }
/* the chevron, drawn as a mask so it takes the accent colour (a background image can't read a variable) */
.fc label:has(> select:not([multiple]):not([size])),
.fc .fc-has-select { position: relative; }
@supports not (appearance: base-select) {
  .fc :is(label, .fc-has-select):has(> select:not([multiple]):not([size]))::after {
    content: ''; position: absolute; right: 14px; bottom: 14px; width: 18px; height: 18px; pointer-events: none;
    background: var(--fc-accent); -webkit-mask: var(--fc-chevron) center / contain no-repeat; mask: var(--fc-chevron) center / contain no-repeat;
  }
}

/* selects: the open list, where the browser lets CSS draw it (Chrome and Edge 135+) */
@supports (appearance: base-select) {
  .fc select:not([multiple]):not([size]),
  .fc select:not([multiple]):not([size])::picker(select) { appearance: base-select; }
  .fc select:not([multiple]):not([size]) { display: flex; align-items: center; gap: 12px; padding-right: 14px; text-align: start; }
  .fc select:not([multiple]):not([size])::picker-icon {
    content: ''; flex: none; width: 18px; height: 18px; margin-inline-start: auto;
    background-color: var(--fc-accent); -webkit-mask: var(--fc-chevron) center / contain no-repeat; mask: var(--fc-chevron) center / contain no-repeat;
    transition: rotate .2s ease;
  }
  .fc select:open::picker-icon { rotate: 180deg; }
  .fc select::picker(select) {
    box-sizing: border-box; margin-block: 6px; padding: 6px; border: 1.5px solid var(--fc-line);
    border-radius: var(--fc-radius-pop); background: var(--fc-card); color: var(--fc-ink);
    box-shadow: 0 12px 32px -12px color-mix(in srgb, var(--fc-ink) 35%, transparent);
    font: 400 1rem/1.35 var(--fc-font); scrollbar-width: thin;
    opacity: 0; translate: 0 -4px;
    transition: opacity .15s, translate .2s ease, overlay .2s allow-discrete, display .2s allow-discrete;
  }
  .fc select:open::picker(select) { opacity: 1; translate: 0 0; }
  @starting-style { .fc select:open::picker(select) { opacity: 0; translate: 0 -4px; } }
  .fc select option {
    display: flex; align-items: center; gap: 12px; box-sizing: border-box; min-height: 42px;
    padding: 8px 12px; border-radius: calc(var(--fc-radius) - 2px); background: transparent; color: var(--fc-ink);
    cursor: pointer; transition: background-color .12s;
  }
  .fc select option:is(:hover, :focus-visible) { background: var(--fc-hover); outline: none; }
  .fc select option:checked { font-weight: 600; }
  .fc select option:disabled { color: var(--fc-muted); cursor: default; background: none; }
  .fc select option[value='']:disabled { display: none; }
  .fc select option::checkmark {
    content: ''; order: 1; flex: none; width: 18px; height: 18px; margin-inline-start: auto;
    background-color: var(--fc-accent); -webkit-mask: var(--fc-tick) center / contain no-repeat; mask: var(--fc-tick) center / contain no-repeat;
  }
  .fc select option:not(:checked)::checkmark { visibility: hidden; }
}

/* ---------- checkboxes and radios ---------- */
.fc :is(input[type=checkbox], input[type=radio]) {
  appearance: none; -webkit-appearance: none; flex: none; box-sizing: border-box;
  width: 20px; height: 20px; margin: 2px 0 0; padding: 0; vertical-align: -4px;
  border: 1.5px solid var(--fc-muted); border-radius: 6px; background: var(--fc-field) no-repeat center;
  cursor: pointer; transition: border-color .15s, background-color .15s;
}
.fc input[type=radio] { border-radius: 50%; }
.fc :is(input[type=checkbox], input[type=radio]):hover { border-color: var(--fc-accent); }
.fc :is(input[type=checkbox], input[type=radio]):focus-visible { outline: 3px solid color-mix(in srgb, var(--fc-accent) 45%, transparent); outline-offset: 2px; }
.fc :is(input[type=checkbox], input[type=radio]):checked { border-color: var(--fc-accent); background-color: var(--fc-accent); }
.fc input[type=checkbox]:checked { position: relative; }
.fc input[type=checkbox]:checked::after {
  content: ''; position: absolute; inset: 1px; background: var(--fc-on-accent);
  -webkit-mask: var(--fc-tick) center / 15px no-repeat; mask: var(--fc-tick) center / 15px no-repeat;
}
.fc input[type=radio]:checked { box-shadow: inset 0 0 0 4px var(--fc-accent), inset 0 0 0 10px var(--fc-on-accent); }
.fc :is(input[type=checkbox], input[type=radio]):disabled { opacity: .45; cursor: not-allowed; }

/* ---------- file inputs ---------- */
/* Without JS: the native button, styled */
.fc input[type=file] { font: 400 .95rem var(--fc-font); color: var(--fc-muted); max-width: 100%; }
.fc input[type=file]::file-selector-button {
  margin-right: 12px; min-height: 40px; padding: 0 16px; border: 1.5px solid var(--fc-accent);
  border-radius: 999px; background: transparent; color: var(--fc-ink); font: 500 .95rem var(--fc-font); cursor: pointer;
  transition: background-color .15s;
}
.fc input[type=file]::file-selector-button:hover { background: var(--fc-hover); }
/* With JS: a drop zone (form-controls.js builds .fc-file around the input) */
.fc .fc-file {
  position: relative; display: flex; align-items: center; gap: 14px; box-sizing: border-box; width: 100%;
  padding: 14px 16px; border: 1.5px dashed var(--fc-line); border-radius: var(--fc-radius);
  background: var(--fc-field); color: var(--fc-ink); font: 400 .95rem/1.35 var(--fc-font); cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.fc .fc-file:hover, .fc .fc-file.is-over { border-color: var(--fc-accent); background: var(--fc-hover); }
.fc .fc-file:focus-within { border-style: solid; border-color: var(--fc-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc-accent) 30%, transparent); }
.fc .fc-file input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.fc .fc-file-ico {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: color-mix(in srgb, var(--fc-accent) 16%, transparent);
}
.fc .fc-file-ico::before { content: ''; width: 20px; height: 20px; background: var(--fc-accent); -webkit-mask: var(--fc-upload) center / contain no-repeat; mask: var(--fc-upload) center / contain no-repeat; }
.fc .fc-file-text { display: grid; gap: 2px; min-width: 0; }
.fc .fc-file-text b { font-weight: 600; }
.fc .fc-file-text small { color: var(--fc-muted); font-size: .85rem; }
.fc .fc-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc .fc-file-clear {
  position: relative; z-index: 1; flex: none; margin-left: auto; border: 0; background: none; color: var(--fc-muted);
  font: 500 .85rem var(--fc-font); text-decoration: underline; cursor: pointer; padding: 6px;
}
.fc .fc-file-clear:hover { color: var(--fc-ink); }

/* ---------- date and time pickers ---------- */
/* Without JS the browser's own field is used; at least its icon takes the accent. */
.fc input:is([type=date],[type=time],[type=datetime-local],[type=month])::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .75; }
.fc .fc-pick { position: relative; display: block; }
.fc .fc-pick > input.fc-pick-field { padding-right: 44px; cursor: pointer; }
.fc .fc-pick > input.fc-pick-field[aria-expanded=true] { border-color: var(--fc-accent); }
.fc .fc-pick::after {
  content: ''; position: absolute; right: 14px; top: 50%; width: 18px; height: 18px; translate: 0 -50%; pointer-events: none;
  background: var(--fc-accent); -webkit-mask: var(--fc-cal) center / contain no-repeat; mask: var(--fc-cal) center / contain no-repeat;
}
.fc .fc-pick[data-kind=time]::after { -webkit-mask-image: var(--fc-clock); mask-image: var(--fc-clock); }

.fc-pop {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; box-sizing: border-box;
  width: max-content; min-width: 100%; padding: 12px; border: 1.5px solid var(--fc-line); border-radius: var(--fc-radius-pop);
  background: var(--fc-card); color: var(--fc-ink); font: 400 .95rem/1.3 var(--fc-font);
  box-shadow: 0 16px 40px -14px color-mix(in srgb, var(--fc-ink) 40%, transparent);
  display: flex; gap: 12px; opacity: 0; translate: 0 -4px; transition: opacity .15s, translate .2s ease;
}
.fc-pop.is-open { opacity: 1; translate: 0 0; }
.fc-pop.is-up { top: auto; bottom: calc(100% + 6px); }
.fc-pop[hidden] { display: none; }
.fc-cal { width: 272px; }
.fc-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fc-cal-title { font-weight: 600; font-size: 1rem; }
.fc-nav {
  display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: none; color: var(--fc-ink); cursor: pointer; font: inherit;
}
.fc-nav:hover { background: var(--fc-hover); }
.fc-nav:focus-visible { outline: 2px solid var(--fc-accent); }
.fc-nav::before { content: ''; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--fc-chevron) center / contain no-repeat; mask: var(--fc-chevron) center / contain no-repeat; rotate: 90deg; }
.fc-nav[data-step='1']::before { rotate: -90deg; }
.fc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.fc-wd { text-align: center; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fc-muted); padding: 4px 0; }
.fc-day {
  aspect-ratio: 1; display: grid; place-items: center; border: 0; border-radius: 50%; background: none;
  color: var(--fc-ink); font: inherit; cursor: pointer; transition: background-color .12s;
}
.fc-day:hover { background: var(--fc-hover); }
.fc-day:focus-visible { outline: 2px solid var(--fc-accent); outline-offset: -2px; }
.fc-day.is-out { color: var(--fc-muted); opacity: .55; }
.fc-day.is-today { box-shadow: inset 0 0 0 1.5px var(--fc-accent); }
.fc-day[aria-selected=true] { background: var(--fc-accent); color: var(--fc-on-accent); font-weight: 600; }
.fc-day:disabled { opacity: .3; cursor: default; background: none; text-decoration: line-through; }
.fc-cal-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.fc-link { border: 0; background: none; padding: 6px 4px; color: var(--fc-ink); font: 500 .85rem var(--fc-font); text-decoration: underline; text-decoration-color: var(--fc-accent); text-underline-offset: 3px; cursor: pointer; }
.fc-times { display: grid; align-content: start; gap: 2px; max-height: 300px; min-width: 110px; overflow-y: auto; scrollbar-width: thin; padding-right: 2px; }
/* a time-only picker: the list fills the popup */
.fc-pop > .fc-times:only-child { flex: 1; }
.fc-cal + .fc-times { border-left: 1px solid var(--fc-line); padding-left: 12px; }
.fc-time {
  border: 0; border-radius: calc(var(--fc-radius) - 2px); background: none; color: var(--fc-ink);
  padding: 9px 12px; text-align: left; font: inherit; cursor: pointer; white-space: nowrap;
}
.fc-time:hover { background: var(--fc-hover); }
.fc-time:focus-visible { outline: 2px solid var(--fc-accent); outline-offset: -2px; }
.fc-time[aria-selected=true] { background: var(--fc-accent); color: var(--fc-on-accent); font-weight: 600; }

/* phones: the picker is a sheet along the bottom of the screen */
@media (max-width: 520px) {
  .fc-pop { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto; min-width: 0; flex-direction: column;
    border-radius: var(--fc-radius-pop) var(--fc-radius-pop) 0 0; border-bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); translate: 0 16px; }
  .fc-pop.is-up { bottom: 0; }
  .fc-cal { width: 100%; }
  .fc-cal + .fc-times { border-left: 0; padding-left: 0; border-top: 1px solid var(--fc-line); padding-top: 10px; max-height: 180px; }
  .fc-times { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); max-height: 260px; }
}
