/* Form controls and the sign-in page layout, shared by the storefront, account and admin forms
   (DESIGN.md sections 6 and 7: 44px controls, 10px radius, labels above, errors under the field). */

.form { display: flex; flex-direction: column; gap: var(--s-3); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 14px; font-weight: 500; }
fieldset.field { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.field > legend { padding: 0; margin-block-end: var(--s-1); }

.field input:not([type="checkbox"], [type="radio"], [type="file"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-3);
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 16px;
}

.field textarea { padding-block: 10px; resize: vertical; min-height: 88px; }
.field .invalid { border-color: var(--danger-ink); }
.field .hint { font-size: 13px; color: var(--ink-3); }

.validation-message, .error { color: var(--danger-ink); font-size: 14px; }

/* File uploads: the native control in a dashed box, its "Choose file" button drawn like a secondary button. The
   button's label comes from the browser, in the browser's language. */
input[type="file"] {
  max-width: 100%;
  min-height: 44px;
  padding: 4px;
  padding-inline-end: var(--s-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

input[type="file"]:hover { border-color: var(--ink-3); }
input[type="file"]:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
input[type="file"]:user-invalid { border-color: var(--danger-ink); }
.field input[type="file"] { width: 100%; }

input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-inline-end: var(--s-3);
  padding-inline: var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-row);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

input[type="file"]:hover::file-selector-button { border-color: var(--ink-3); }




.check { display: flex; align-items: flex-start; gap: var(--s-2); font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: 0 0 auto; }

/* Two fields side by side (first and last name). */
.field-row { display: flex; gap: var(--s-2); }
.field-row > .field { flex: 1; }
.field-optional { margin-inline-start: 0.35em; color: var(--ink-3); font-weight: 400; }

/* Cloudflare Turnstile: usually invisible; when it asks, the check box sits above the submit button. */
.turnstile:empty { display: none; }
.turnstile { min-height: 0; }

/* English placeholders in Arabic (right-to-left) fields keep their own reading order. */
[dir="rtl"] input::placeholder,
[dir="rtl"] textarea::placeholder,
input[dir="rtl"]::placeholder,
textarea[dir="rtl"]::placeholder { unicode-bidi: plaintext; }

/* ---- Search select (Components/UI/SearchSelect, js/search-select.js) ----
   Before scripting, the native select is the control; with scripting, the combobox replaces it (the select stays in the
   form, hidden, and holds the value). Height follows --ss-height so toolbars and inline forms can make it compact. */
.search-select { --ss-height: 44px; position: relative; min-width: 0; }
.search-select .ss-combo { display: none; }

@media (scripting: enabled) {
  .search-select .ss-combo { display: block; }
  .search-select > .ss-native, .search-select > .ss-fallback { display: none; }
}

.ss-field { position: relative; }
.ss-control { position: relative; display: flex; align-items: center; }
.ss-control .ss-icon { position: absolute; inset-inline-start: var(--s-3); color: var(--ink-3); pointer-events: none; }

.search-select .ss-control > input.ss-input {
  width: 100%;
  min-height: var(--ss-height);
  padding-block: 0;
  padding-inline: calc(var(--s-3) + 26px) calc(var(--s-3) + 28px);
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  text-overflow: ellipsis;
}

.search-select .ss-control > input.ss-input:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
.search-select .ss-control > input.ss-input[aria-invalid="true"] { border-color: var(--danger-ink); }
.search-select .ss-control > input.ss-input:disabled { background: var(--raised); color: var(--ink-2); }

/* The × on the clear button and on each chip, drawn with two lines (no icon markup to build in script). */
.ss-clear, .ss-chip-remove {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.ss-clear::before, .ss-clear::after, .ss-chip-remove::before, .ss-chip-remove::after {
  content: "";
  grid-area: 1 / 1;
  width: 11px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
  rotate: 45deg;
}

.ss-clear::after, .ss-chip-remove::after { rotate: -45deg; }
.ss-clear:hover, .ss-chip-remove:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
.ss-clear:focus-visible, .ss-chip-remove:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
.ss-clear { position: absolute; inset-inline-end: var(--s-2); width: 28px; height: 28px; }
.ss-clear[hidden] { display: none; }

/* Working: a small spinner where the clear button sits, after the shared 150ms wait (set by the script). */
.ss-busy { display: none; position: absolute; inset-inline-end: var(--s-3); width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-block-start-color: var(--ink-2); }
.search-select[aria-busy="true"] .ss-busy { display: block; animation: busy-spin 0.8s linear infinite; }
.search-select[aria-busy="true"] .ss-clear { visibility: hidden; }

.ss-list {
  position: absolute;
  inset-inline: 0;
  inset-block-start: calc(100% + 4px);
  z-index: 30;
  margin: 0;
  padding: var(--s-1);
  list-style: none;
  max-height: min(360px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-float);
}

.ss-list[hidden] { display: none; }
.ss-option { position: relative; display: flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 6px var(--s-2); border-radius: var(--r-row); font-size: 15px; cursor: pointer; }
.ss-option:hover { background: var(--raised); }
.ss-option.is-active { background: var(--raised); }
.ss-option.is-active::before { content: ""; position: absolute; inset-block: 8px; inset-inline-start: 0; width: 2px; border-radius: 1px; background: var(--ink-2); }
.ss-option.is-context { color: var(--ink-2); }
.ss-option.depth-1 { padding-inline-start: calc(var(--s-2) + 20px); }
.ss-option.depth-2 { padding-inline-start: calc(var(--s-2) + 40px); }
.ss-option.depth-3 { padding-inline-start: calc(var(--s-2) + 60px); }
.ss-option.depth-4 { padding-inline-start: calc(var(--s-2) + 80px); }
.ss-check { flex: 0 0 16px; height: 16px; display: grid; place-items: center; }
.ss-option[aria-selected="true"] .ss-check::after { content: ""; width: 9px; height: 5px; margin-block-end: 3px; border-inline-start: 2px solid var(--accent); border-block-end: 2px solid var(--accent); rotate: -45deg; }
.ss-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ss-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-option[aria-selected="true"] .ss-label { font-weight: 500; }
.ss-hint { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-tag { flex: 0 0 auto; padding: 1px 6px; border-radius: var(--r-tag); background: var(--raised); color: var(--ink-2); font-size: 12px; }
.ss-count { flex: 0 0 auto; color: var(--ink-3); font-size: 13px; }
.ss-note { padding: var(--s-2) var(--s-3); color: var(--ink-3); font-size: 14px; }

/* Chosen items of a multiple field, under the box. */
.ss-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0 0; padding: 0; list-style: none; }
.ss-chips[hidden] { display: none; }
.ss-chip { display: inline-flex; align-items: center; gap: var(--s-1); max-width: 100%; padding-block: 3px; padding-inline: var(--s-3) 3px; border-radius: 999px; background: var(--accent-soft); font-size: 14px; }
.ss-chip > bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-chip-note { color: var(--ink-3); font-size: 12px; }
.ss-chip-remove { width: 26px; height: 26px; }

/* ---- Word list (js/word-list.js): chips and a text box in one field-like box, the chips styled like the search
   select's. Before script it is the plain textarea. ---- */
.word-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px var(--s-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  cursor: text;
}

.word-list:focus-within { outline: var(--focus-ring); outline-offset: 1px; }
.word-list:has(.wl-input:disabled) { background: var(--raised); cursor: default; }
.wl-chips { display: contents; }
.wl-chips[hidden] { display: none; }

.word-list > input.wl-input {
  flex: 1 1 10em;
  min-width: 10em;
  min-height: 32px;
  padding: 0 var(--s-1);
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}

/* Compact in toolbars, inline forms and row forms. */
.toolbar .search-select, .inline-form .search-select, .row-form .search-select { --ss-height: 40px; flex: 1 1 220px; }
.toolbar .search-select .ss-control > input.ss-input,
.inline-form .search-select .ss-control > input.ss-input { font-size: 14px; }

/* ---- Reveal: part of a form that opens while a choice is picked ----
   <div class="reveal-group"> holds the choices; the one marked data-reveal opens the group's .reveal (a new address
   at checkout, choosing the home page categories). It slides open and closed, and while closed its fields can't be
   reached with Tab. Pure CSS, so it works before script. */
.reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows 320ms cubic-bezier(0.2, 0, 0, 1), opacity 180ms, visibility 0s 320ms;
}

/* The negative margin keeps focus rings and shadows inside the clipped area visible. */
.reveal-inner { min-height: 0; overflow: hidden; margin: -4px; padding: 4px; }

.reveal-group:has([data-reveal]:checked) .reveal {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition: grid-template-rows 320ms cubic-bezier(0.2, 0, 0, 1), opacity 240ms 80ms, visibility 0s;
}

/* Once open, nothing is clipped, so a search select's list can drop below the panel. It stays clipped while it slides
   open (the animation holds overflow: hidden) and from the moment it starts closing. */
.reveal-group:has([data-reveal]:checked) .reveal-inner { overflow: visible; animation: reveal-clip 320ms; }

@keyframes reveal-clip { from, to { overflow: hidden; } }

/* A one-time code: large, spaced digits that read well and are easy to check. */
.field input.code-input { max-width: 12ch; font-size: 22px; letter-spacing: 0.3em; text-align: center; }

/* ---- Staff sign-in: passkeys, Google, authenticator apps (AdminSignIn…, AdminSecurity, PasskeyForm) ---- */
.sign-in-options { display: flex; flex-direction: column; gap: var(--s-2); }

/* Nothing to offer here (no passkey support in this browser, no Google): no empty box and no "or" line under it. */
.sign-in-options:not(:has(> :not([hidden]))),
.sign-in-options:not(:has(> :not([hidden]))) + .or-line { display: none; }

.or-line { display: flex; align-items: center; gap: var(--s-3); font-size: 13px; color: var(--ink-3); }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.passkey-form { display: flex; flex-direction: column; gap: var(--s-2); }
.passkey-form[hidden] { display: none; }
.passkey-button, .google-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); }
.google-mark { flex: none; }

.setup-choices { display: flex; flex-direction: column; gap: var(--s-3); }
.setup-choice { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.setup-choice h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0; font-size: 17px; }
.setup-choice p { margin: 0; }

/* The authenticator steps open from a button; once open, the button has done its job. */
.setup-details > summary { list-style: none; }
.setup-details > summary::-webkit-details-marker { display: none; }
.setup-details[open] > summary { display: none; }

/* A code sent by email (EmailCodePanel): the field, then "Send a new code" under it. */
.email-code { display: flex; flex-direction: column; gap: var(--s-3); }
.email-code > p { margin: 0; }

/* The emailed code on the verify page, folded away when a passkey or the app is set up too. */
.other-ways { border-block-start: 1px solid var(--line); padding-block-start: var(--s-3); }
.other-ways > summary { padding-block: var(--s-2); cursor: pointer; color: var(--ink-2); font-size: 14px; line-height: 24px; }
.other-ways > summary::marker { color: var(--ink-3); }
.other-ways[open] > summary { margin-block-end: var(--s-3); }

.setup-steps { display: flex; flex-direction: column; gap: var(--s-3); margin: 0 0 var(--s-3); padding-inline-start: 1.2em; line-height: 22px; }

/* Black on white whatever the theme, with a margin of white: what phone cameras read best. */
.qr-frame { width: 176px; margin-block: var(--s-2); padding: var(--s-2); background: #fff; border: 1px solid var(--line); border-radius: var(--r-control); }
.qr-code { display: block; width: 100%; height: auto; }
.setup-key { display: block; margin-block-start: var(--s-1); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: 0.04em; overflow-wrap: anywhere; user-select: all; }

/* The ways a staff member signs in, each with its remove button (AdminSecurity). */
.sign-in-steps { display: flex; flex-direction: column; margin: 0 0 var(--s-3); padding: 0; list-style: none; }
.sign-in-steps li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding-block: var(--s-3); border-block-end: 1px solid var(--line); }
.step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.step-name { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 500; }
