/* =========================================================================
   LAVACASCADE — css/components/forms.css
   Fields are recessed dark wells with a lava focus glow (panel style).
   Errors show under the field AND turn its border red, so state never
   relies on color alone. Also: the status message line every form uses.
   ========================================================================= */

/* =========================================
   FIELD LAYOUT
   ========================================= */
.form {
    display: grid;
    gap: var(--space-5);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5);
}

.form-grid .field--full {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
}

.field label,
.field .label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-strong);
}

.field .req {
    color: var(--lava-300);
}

.field__hint {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* =========================================
   INPUTS
   ========================================= */
.input,
.select,
.textarea {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 0.95rem;
    font-size: var(--fs-body);   /* 16px stops iOS zooming on focus */
    color: var(--text-strong);
    background: var(--night-900);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-faint);
}

.input:hover,
.select:hover,
.textarea:hover {
    border-color: #4A3E5C;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--lava-400);
    box-shadow: 0 0 0 3px rgba(255, 133, 64, 0.22);
}

.textarea {
    min-height: 130px;
    resize: vertical;
    line-height: 1.55;
}

/* native select with our own chevron */
.select {
    padding-right: 2.6rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B3A9C2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 18px;
}

.select option {
    background: var(--night-800);
    color: var(--text-strong);
}

.select option:disabled {
    color: var(--text-faint);
}

/* =========================================
   ERRORS (js sets aria-invalid="true" on the input)
   ========================================= */
.field__error {
    display: none;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--bad);
}

.field:has([aria-invalid="true"]) .field__error {
    display: block;
}

[aria-invalid="true"] {
    border-color: var(--bad) !important;
}

/* gentle shake when an empty required field blocks an action */
.is-shaking {
    animation: field-shake 0.4s var(--ease);
}

@keyframes field-shake {
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* =========================================
   CHECKBOX ROW
   ========================================= */
.check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-sm);
    color: var(--text-soft);
}

.check input {
    width: 18px;
    height: 18px;
    flex: none;
    accent-color: var(--lava-500);
}

/* label text that can wrap to two lines: box lines up with the first one */
.check--top {
    align-items: flex-start;
    line-height: 1.45;
}

.check--top input {
    margin-top: 0.12em;
}

/* =========================================
   HONEYPOT (hidden from people, visible to bots)
   ========================================= */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* =========================================
   STATUS MESSAGE under a form / button
   data-kind = ok | bad | info  (set by setStatus() in js/helper.js)
   ========================================= */
.form-status {
    min-height: 1.5em;
    font-size: var(--fs-sm);
    color: var(--text-soft);
}

.form-status:empty {
    min-height: 0;
}

.form-status[data-kind="ok"]   { color: var(--ok); }
.form-status[data-kind="bad"]  { color: var(--bad); }
.form-status[data-kind="info"] { color: var(--text-soft); }

/* a boxed notice, for longer messages */
.notice {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    font-size: var(--fs-sm);
    color: var(--text);
    background: var(--fill-info);
    border: 1px solid rgba(147, 197, 253, 0.25);
    border-radius: var(--radius);
}

.notice svg {
    width: 18px;
    height: 18px;
    flex: none;
    margin-top: 0.2em;
    color: var(--info);
}

.notice--warn {
    background: var(--fill-warn);
    border-color: rgba(250, 204, 21, 0.3);
}

.notice--warn svg { color: var(--warn); }

.notice--bad {
    background: var(--fill-bad);
    border-color: rgba(248, 113, 113, 0.3);
}

.notice--bad svg { color: var(--bad); }

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}
