/*
 * Form contrast.
 *
 * ─────────────────────────────────────────────────────────────────────────
 * The bug this file exists to fix.
 *
 * The theme was forked from a dark skin, where every form field was white ink
 * on a dark card. Three of those rules survived the palette flip and, on a
 * white ground, made typed text invisible:
 *
 *   main.css:1690  .form--control:focus { color: hsl(var(--white)) }
 *                  The resting colour had been corrected, but not the focused
 *                  one — so text was legible until you clicked into the field
 *                  and vanished exactly while you were typing into it.
 *
 *   main.css:1791  input:-webkit-autofill {
 *                      -webkit-text-fill-color: hsl(var(--white)) !important
 *                  }
 *                  -webkit-text-fill-color outranks `color` outright in
 *                  Chrome and Edge, so a remembered email stayed invisible no
 *                  matter what colour was set.
 *
 *   main.css:1792  caret-color: hsl(var(--white))
 *                  White caret on white — no visible cursor either.
 *
 * Two declarations below carry !important. That is not a preference: you
 * cannot override an !important declaration without one, and main.css:1791
 * is !important. They are the only two in this file.
 * ─────────────────────────────────────────────────────────────────────────
 *
 * Colours come from the theme's own tokens, so this follows color.php and a
 * re-themed site rather than pinning a literal.
 */

:root {
    /* One ink for everything a person types, one for hints. */
    --cf-field-ink: hsl(var(--heading-color));
    --cf-field-hint: hsl(var(--body-color) / 0.7);
    --cf-field-bg: hsl(var(--white));
    --cf-field-line: hsl(var(--border-color));
}

/* ========================= Typed value, every state ====================== */

.form--control,
.form-control,
input.form--control,
textarea.form--control,
select.form--control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    color: var(--cf-field-ink);
    caret-color: hsl(var(--base));
}

/*
 | The focused state is the whole bug. It is restated for every field type
 | rather than only .form--control, because the dark skin set white ink in
 | several places and a field that is legible until you use it is worse than
 | one that is plainly wrong.
 */
.form--control:focus,
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    color: var(--cf-field-ink);
    background-color: var(--cf-field-bg);
    border-color: hsl(var(--base));
    caret-color: hsl(var(--base));
}

/* Password fields were dimmed to half-transparent white by the dark skin. */
.form--control[type="password"],
.form--control[type="password"]:focus,
input[type="password"],
input[type="password"]:focus {
    color: var(--cf-field-ink);
    -webkit-text-security: disc;
}

/* ============================== Placeholders ============================= */

.form--control::-webkit-input-placeholder,
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder { color: var(--cf-field-hint); opacity: 1; }

.form--control::-moz-placeholder,
input::-moz-placeholder,
textarea::-moz-placeholder { color: var(--cf-field-hint); opacity: 1; }

.form--control:-ms-input-placeholder,
input:-ms-input-placeholder,
textarea:-ms-input-placeholder { color: var(--cf-field-hint); }

.form--control::placeholder,
input::placeholder,
textarea::placeholder { color: var(--cf-field-hint); opacity: 1; }

/* ================================ Autofill =============================== */

/*
 | Chrome and Edge paint autofilled fields themselves. -webkit-text-fill-color
 | is what actually decides the glyph colour there, and the rule it replaces
 | is !important, so this one has to be too.
 |
 | The inset box-shadow is the standard way to repaint the background: the
 | UA's own background cannot be overridden directly, but a 1000px inset
 | shadow covers it.
 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--cf-field-ink) !important;

    /* The skin's caret rule is not !important, so this does not need to be. */
    caret-color: hsl(var(--base));

    -webkit-box-shadow: 0 0 0 1000px var(--cf-field-bg) inset;
    box-shadow: 0 0 0 1000px var(--cf-field-bg) inset;

    /*
     | The long transition is inherited from the original rule and is the
     | usual trick for stopping the yellow flash: the background is animated
     | so slowly it never visibly arrives.
     */
    -webkit-transition: background-color 5000s ease-in-out 0s;
    transition: background-color 5000s ease-in-out 0s;
}

/* Firefox, which uses the standard selector and its own background. */
input:autofill,
textarea:autofill,
select:autofill {
    color: var(--cf-field-ink);
    background-color: var(--cf-field-bg);
}

/*
 | Inside an input group the field is transparent so the group draws the
 | border, and an opaque autofill background would break the rounded corner.
 */
.input-group input:-webkit-autofill,
.input-group input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px transparent inset;
    box-shadow: 0 0 0 1000px transparent inset;
}

/* ========================== Disabled and readonly ======================== */

/*
 | Still readable. A disabled field is often showing a value the person needs
 | to check — an account number, an amount — and greying it into illegibility
 | hides information rather than communicating that it cannot be edited.
 */
.form--control:disabled,
.form--control[readonly],
input:disabled,
input[readonly],
textarea:disabled,
textarea[readonly],
select:disabled {
    color: var(--cf-field-ink);
    -webkit-text-fill-color: var(--cf-field-ink);
    opacity: 1;
    cursor: not-allowed;
}

/* ============================== Focus visibility ========================= */

/*
 | A visible focus ring for keyboard users, on top of the border colour change
 | — a border that changes hue alone is not enough to locate the cursor.
 */
.form--control:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.form-check-input:focus-visible {
    outline: 2px solid hsl(var(--base));
    outline-offset: 2px;
}

/* ============================ Checks and selects ========================= */

.form-check-input:checked {
    background-color: hsl(var(--base));
    border-color: hsl(var(--base));
}

.form-check-label,
.form--label,
label {
    color: var(--cf-field-ink);
}

/* Select2 renders its own field; it needs the same ink as everything else. */
.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--multiple .select2-selection__choice,
.select2-search__field,
.select2-results__option {
    color: var(--cf-field-ink) !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--cf-field-hint);
}

/* ============================= Native pickers ============================ */

/*
 | The calendar and reveal glyphs are drawn by the browser in its own colour,
 | which on a light field can come out near-invisible. Forcing them to the
 | field ink keeps them findable.
 */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(0.45);
    cursor: pointer;
}

/* The password-reveal eye HYIPLAB renders next to password fields. */
.password-show-hide {
    color: hsl(var(--body-color));
}

/* ===================== Account shell, single column ====================== */

/*
 | Login and register use the two-column account shell: a picture on the left,
 | the form on the right. The three password-recovery pages did not — they were
 | a plain Bootstrap card — so the auth flow changed appearance halfway
 | through, which reads as having been dropped onto a different site at exactly
 | the moment a nervous user is recovering an account.
 |
 | They use the same shell now, in a single-column variant. .account-form is
 | half-width by design, so without this modifier the form would sit in the
 | left half of a wide panel with nothing beside it.
 |
 | Presentation only. Every form action, method, field name and hidden input on
 | those pages is unchanged.
 */

.account--solo {
    max-width: 34rem;
    margin-inline: auto;
}

.account--solo .account-form {
    width: 100%;
}

/*
 | The verification-code inputs come from a shared partial and centre
 | themselves; inside the narrower panel they need the panel to stop fighting
 | them for width.
 */
.account--solo .verification-code-wrapper {
    width: 100%;
}

.account-form__back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--cf-field-ink, hsl(var(--body-color)));
    text-decoration: none;
}

.account-form__back:hover {
    color: hsl(var(--base));
}
