/* SentinelWeb fields (DESIGN.md → Field, Submit button, Password). Works on the existing markup
   (`.form-label` followed by `.form-input`) in the site, the admin panel and the Community panel.
   A wrapper opts in with `.sw-field` (+ `.is-float` for text-like inputs and textareas): sw-forms.js
   adds both in the site and admin; the panel templates carry them in the HTML.
   Without JavaScript (the panel runs script-src 'none') labels, focus glow, error and valid states
   still work; sw-forms.js adds live validation, the password eye, caps-lock hint, strength meter
   and the submit spinner. transform/opacity only; colour transitions stay under reduced motion. */

.sw-field{position:relative}

/* Floating label: sits inside the field, floats up on focus or when the field has a value. */
.sw-field.is-float > .form-label{
  position:absolute;inset-inline-start:.9rem;top:.42rem;margin:0;z-index:1;pointer-events:none;
  font-size:.74rem;font-weight:600;color:var(--muted);line-height:1.4;max-width:calc(100% - 2.6rem);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  transform-origin:var(--sw-label-origin,left) top;
  transition:transform var(--sw-dur-fast) var(--sw-ease-out),color var(--sw-dur-fast) var(--sw-ease-out)
}
[dir="rtl"]{--sw-label-origin:right}
.sw-field.is-float > :is(input,textarea).form-input{
  padding-top:1.55rem;padding-bottom:.5rem;min-height:3.35rem
}
/* Resting position: only for fields whose placeholder is the blank " " marker (no real hint text). */
.sw-field.is-float:has(> .form-input[placeholder=" "]:placeholder-shown:not(:focus):not(:autofill)) > .form-label{
  transform:translateY(.62rem) scale(1.22);color:var(--muted)
}
.sw-field:has(> .form-input:focus) > .form-label{color:var(--neon)}

/* Field box: soft focus glow, never a hard jump. */
.form-input{
  background:var(--sw-field-bg);border:1px solid var(--sw-field-line);color:var(--text);border-radius:var(--sw-r-field);
  transition:border-color var(--sw-dur-fast) var(--sw-ease-out),box-shadow var(--sw-dur-base) var(--sw-ease-out),background-color var(--sw-dur-fast)
}
.form-input:hover{border-color:color-mix(in oklab,var(--neon) 40%,transparent)}
.form-input:focus,.form-input:focus-visible{border-color:var(--neon);box-shadow:var(--sw-glow);outline:2px solid transparent}
.form-input::placeholder{color:color-mix(in oklab,var(--muted) 70%,transparent)}
.form-input[placeholder=" "]::placeholder{color:transparent}
.form-input:disabled{opacity:.55;cursor:not-allowed}

/* Invalid: colour + one gentle shake (also on first paint when the server returned an error). */
.form-input[aria-invalid="true"],.form-input.is-invalid{border-color:var(--sw-danger)}
.form-input[aria-invalid="true"]:focus,.form-input.is-invalid:focus{box-shadow:var(--sw-danger-glow)}
.sw-field:has(> .form-input[aria-invalid="true"]) > .form-label{color:var(--sw-danger)}
.form-input[aria-invalid="true"],.sw-shake{animation:sw-shake 320ms var(--sw-ease-out) 1}
@keyframes sw-shake{
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(calc(var(--sw-shake) * -1))}40%{transform:translateX(var(--sw-shake))}
  60%{transform:translateX(calc(var(--sw-shake) * -.6))}80%{transform:translateX(calc(var(--sw-shake) * .6))}
}
.error,.sw-msg{display:flex;gap:.4rem;align-items:flex-start;margin-top:.4rem;font-size:.82rem;line-height:1.6;color:var(--sw-danger)}
.error::before,.sw-msg.is-error::before{content:"";flex:0 0 auto;width:.95rem;height:.95rem;margin-top:.2rem;background:currentColor;
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 2a8 8 0 100 16 8 8 0 000-16zm-.9 4h1.8v5.2H9.1zm0 6.6h1.8v1.8H9.1z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 2a8 8 0 100 16 8 8 0 000-16zm-.9 4h1.8v5.2H9.1zm0 6.6h1.8v1.8H9.1z'/%3E%3C/svg%3E") center/contain no-repeat}
.sw-msg.is-hint{color:var(--muted)}
.sw-msg.is-warn{color:var(--sw-warning)}
.sw-msg:empty{display:none}

/* Valid: a small check that draws in from the reading start. sw-forms.js sets .is-valid on the site
   and in the admin; the Community panel (no JavaScript) gets it from :user-valid on fields with a rule. */
.sw-field.is-valid::after,
body.x .sw-field:has(> .form-input:is([pattern],[type=tel],[type=email],[type=url],[minlength],[inputmode=numeric]):user-valid:not(:placeholder-shown))::after{
  content:"";position:absolute;inset-inline-end:.85rem;top:1.05rem;width:1.15rem;height:1.15rem;background:var(--sw-success);pointer-events:none;
  -webkit-mask: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='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: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='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E") center/contain no-repeat;
  animation:sw-check-in var(--sw-dur-base) var(--sw-ease-out) both
}
.sw-field.is-valid > .form-input,
body.x .sw-field > .form-input:is([pattern],[type=tel],[type=email],[type=url],[minlength],[inputmode=numeric]):user-valid:not(:placeholder-shown){padding-inline-end:2.6rem}
.sw-field.has-eye.is-valid::after{inset-inline-end:3rem}
@keyframes sw-check-in{from{clip-path:inset(0 100% 0 0);opacity:.4}to{clip-path:inset(0 0 0 0);opacity:1}}
[dir="rtl"] .sw-field.is-valid::after{animation-name:sw-check-in-rtl}
@keyframes sw-check-in-rtl{from{clip-path:inset(0 0 0 100%);opacity:.4}to{clip-path:inset(0 0 0 0);opacity:1}}

/* Password: eye toggle (icon morph), caps-lock hint, strength meter. */
.sw-field.has-eye > .form-input{padding-inline-end:3rem}
.sw-eye{position:absolute;inset-inline-end:.35rem;top:.42rem;width:2.5rem;height:2.5rem;display:grid;place-items:center;border:0;border-radius:10px;
  background:transparent;color:var(--muted);cursor:pointer;transition:color var(--sw-dur-fast),background-color var(--sw-dur-fast)}
.sw-eye:hover{color:var(--neon);background:var(--sw-accent-soft)}
.sw-eye:focus-visible{outline:2px solid var(--neon);outline-offset:1px}
.sw-eye svg{width:1.25rem;height:1.25rem}
.sw-eye .sw-eye-slash{stroke-dasharray:24;stroke-dashoffset:24;transition:stroke-dashoffset var(--sw-dur-base) var(--sw-ease-out)}
.sw-eye[aria-pressed="true"] .sw-eye-slash{stroke-dashoffset:0}
.sw-eye .sw-eye-lid{transform-origin:12px 12px;transition:transform var(--sw-dur-base) var(--sw-ease-out)}
.sw-eye[aria-pressed="true"] .sw-eye-lid{transform:scaleY(calc(1 - .35 * var(--sw-move)))}
.sw-meter{display:grid;grid-template-columns:repeat(4,1fr);gap:.3rem;margin-top:.55rem}
.sw-meter i{height:.3rem;border-radius:99px;background:color-mix(in oklab,var(--muted) 25%,transparent);overflow:hidden;position:relative}
.sw-meter i::after{content:"";position:absolute;inset:0;background:var(--sw-meter,var(--sw-danger));transform:scaleX(0);transform-origin:var(--sw-label-origin,left);
  transition:transform var(--sw-dur-base) var(--sw-ease-out),background-color var(--sw-dur-base)}
.sw-meter[data-score="1"]{--sw-meter:var(--sw-danger)}.sw-meter[data-score="2"]{--sw-meter:var(--sw-warning)}
.sw-meter[data-score="3"],.sw-meter[data-score="4"]{--sw-meter:var(--sw-success)}
.sw-meter[data-score="1"] i:nth-child(-n+1)::after,.sw-meter[data-score="2"] i:nth-child(-n+2)::after,
.sw-meter[data-score="3"] i:nth-child(-n+3)::after,.sw-meter[data-score="4"] i::after{transform:scaleX(1)}

/* Submit: spinner inside the button while the request runs; the label stays, no width jump. */
.btn-primary[aria-busy="true"],.btn-secondary[aria-busy="true"]{pointer-events:none;cursor:progress}
.btn-primary[aria-busy="true"]::before,.btn-secondary[aria-busy="true"]::before{
  content:"";width:1.05rem;height:1.05rem;flex:0 0 auto;border-radius:50%;
  border:2px solid currentColor;border-inline-end-color:transparent;animation:sw-spin .7s linear infinite
}
@keyframes sw-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){
  .btn-primary[aria-busy="true"]::before,.btn-secondary[aria-busy="true"]::before{animation-duration:2.4s}
  .form-input[aria-invalid="true"],.sw-shake{animation:none}
  .sw-field > .form-label{transition:color var(--sw-dur-fast)}
}
/* Panel: real checkboxes keep the native control, tinted. */
.form-check input,input[type="checkbox"].form-input{accent-color:var(--neon)}
