/* ── Forms ─────────────────────────────────────────────────────
   Comfortable, legible authoring - long writing forms (Markdown
   bodies, mentoring requests) get the same care as reading mode.
   Labels use --type-label, helper text and validation use --type-small.
*/
.form-group {
    margin-bottom: var(--space-5);
}

.form-group label {
    display: block;
    font-size: var(--type-label-size);
    font-weight: var(--type-label-weight);
    letter-spacing: var(--type-label-letter-spacing);
    margin-bottom: var(--space-2);
    color: var(--color-heading);
}

.form-help {
    display: block;
    font-size: var(--type-small-size);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

/* Kept on Brand color deliberately (Issue 45 revision; Red as of
   Issue 45 v2) - a single-character, single-purpose attention mark,
   the same "small and selective" category as .eyebrow, not the broad
   "any interactive element" pattern the revision narrows away from. */
.form-required::after {
    content: " *";
    color: var(--color-primary);
}

/* ── Inputs ────────────────────────────────────────────────── */
.form-input, .form-textarea, .form-select,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="date"], select, textarea {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: var(--type-body-size);
    color: var(--color-text);
    background: var(--color-surface-muted);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

textarea {
    resize: vertical;
    min-height: 6rem;
}

/* Neutralizes the browser's own saved-credential autofill tint
   (blue/yellow depending on browser) back to the input's own resting
   background - without this, an autofilled field (e.g. Studio login)
   visibly breaks from every other input's neutral surface. The long
   transition-delay is the standard trick for suppressing Chromium's
   forced autofill background: it cannot be overridden directly, only
   deferred past any realistic view of the field. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--color-text);
    -webkit-box-shadow: 0 0 0 1000px var(--color-surface-muted) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* ── Password field ─────────────────────────────────────────────
   Shared show/hide toggle for every password input in the Studio -
   Login today; Registration, Change Password, Reset Password, User
   Management tomorrow. See ../../templates/design_system/_password_field.html
   and password-toggle.js for the markup contract and behavior. The
   wrapper only adds positioning for the icon button; the input
   itself still uses the shared input rule above. */
.password-field {
    position: relative;
}

.password-field .password-field-input,
.password-field input[type="password"],
.password-field input[type="text"] {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: var(--space-2);
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--color-interactive);
    background: var(--color-interactive-light);
}

.password-toggle:focus-visible {
    outline: none;
    color: var(--color-interactive);
    box-shadow: 0 0 0 3px var(--color-interactive-light);
}

.password-toggle-icon {
    display: block;
}

/* Author-stylesheet rules always win over the UA stylesheet's
   `[hidden] { display: none; }`, regardless of specificity - without
   this override, the rule above would make both the show and hide
   icon render at once instead of only the one password-toggle.js
   currently un-hides. */
.password-toggle-icon[hidden] {
    display: none;
}

/* ── Content Editor ────────────────────────────────────────────
   The shared authoring component for every long-form Markdown
   field (Profile Sections, Articles, Projects, Offerings, and
   future long-form content types). See ../../README.md - "The
   Content Editor" - for the full component contract. */
.content-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.content-editor-toolbar button {
    display: inline-block;
    font: var(--type-label-weight) var(--type-caption-size) / 1 var(--font-sans);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.content-editor-toolbar button:hover {
    background: var(--color-interactive-light);
    color: var(--color-interactive);
    border-color: var(--color-interactive);
}

/* The color control (a <select>, not a <button> - see
   content-editor.js's buildColorSelect) needs its own rule: the
   generic `select` rule above (full width, form-field sized) would
   otherwise stretch it far past the other toolbar controls. */
.content-editor-toolbar select {
    width: auto;
    display: inline-block;
    font: var(--type-label-weight) var(--type-caption-size) / 1 var(--font-sans);
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.content-editor-toolbar select:hover {
    border-color: var(--color-interactive);
}

.content-editor-textarea {
    width: 100%;
    min-height: 24rem;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: var(--type-small-size);
    line-height: var(--type-body-line-height);
}

.content-editor-preview {
    margin-top: var(--space-5);
    padding: var(--space-5);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.content-editor-preview-label {
    font-size: var(--type-caption-size);
    font-weight: var(--type-caption-weight);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-3);
}

.content-editor-preview-body :first-child {
    margin-top: 0;
}

/* ── Rendered Markdown output ──────────────────────────────────
   Shared styling hook for anywhere Markdown-derived HTML lands -
   the Content Editor's live preview and every public long-form
   page (`{{ object.body|markdown }}`). `layouts/page.css` resets
   `ul, ol { list-style: none; }` globally for site navigation;
   this opts rendered Markdown lists back in, the same way
   `.field-errors` already does above. */
.markdown-content ul,
.markdown-content ol {
    padding-left: var(--space-5);
    margin: var(--space-4) 0;
}

.markdown-content ul {
    list-style: disc;
}

.markdown-content ol {
    list-style: decimal;
}

.markdown-content li + li {
    margin-top: var(--space-1);
}

/* Interactive-token focus state (Brand red, blue retired), white
   background - overrides base.css's generic focus outline for form
   fields specifically, per the design spec - focus is "you're here,"
   the same role as every other focus/hover state in the system. */
.form-input:focus-visible, .form-textarea:focus-visible, .form-select:focus-visible,
input[type="text"]:focus-visible, input[type="email"]:focus-visible, input[type="password"]:focus-visible,
input[type="number"]:focus-visible, input[type="url"]:focus-visible, input[type="date"]:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: none;
    background: var(--color-surface);
    border-color: var(--color-interactive);
    box-shadow: 0 0 0 3px var(--color-interactive-light);
}

/* ── Validation ────────────────────────────────────────────── */
.field-errors {
    color: var(--status-danger-text);
    font-size: var(--type-small-size);
    margin-top: var(--space-2);
    padding-left: var(--space-4);
    list-style: disc;
}

.form-group:has(.field-errors) .form-input,
.form-group:has(.field-errors) .form-textarea,
.form-group:has(.field-errors) .form-select {
    border-color: var(--status-danger-border);
}

/* ── Filter bar - compact GET-form row above a Studio list table. ──── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 10rem;
}

/* ── Row pairing - short, compatible fields (e.g. full name + email)
   sharing one line instead of each claiming a full line to itself.
   Long-text/select fields simply aren't wrapped in this. */
.form-row {
    display: grid;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}

.form-row .form-group {
    margin-bottom: 0;
}

@media (min-width: 480px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Section grouping - long forms broken into named blocks. ──── */
.form-section {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--color-border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    font-size: var(--type-heading-l-size);
    margin-bottom: var(--space-4);
}
