/* ==========================================================================
   /add_question/ — the question submission form
   ==========================================================================

   Separate from qa.css (2,700 lines) because this page is a composition surface, not a
   reading one, and only this page loads it.

   Layout decisions worth knowing:

   - The tips card is FIRST in the DOM and moves into the right rail with `order` on desktop.
     Measured at 390px, the previous markup put it at y=1686 — 550px BELOW the submit button —
     so "how to write a good question" arrived after the question had been sent.

   - The reading/writing column is capped rather than filling the 1536px Tailwind container.
     The old textarea ran 802px wide, i.e. ~100 characters per line of prose, against the
     50–75 the theme already targets elsewhere for body copy.
   ========================================================================== */

.ask {
    padding: var(--space-2xl) 0 var(--space-3xl);
}

.ask__head {
    max-width: 60ch;
    margin: 0 0 var(--space-xl);
}

.ask__title {
    margin: var(--space-sm) 0 var(--space-sm);
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;
    color: var(--color-ink);
}

.ask__lede {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--color-ink-light);
}

/* ==========================================================================
   Notices
   ========================================================================== */

.ask__notice {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    max-width: 820px;
    margin: 0 0 var(--space-xl);
    padding: 0.9rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    line-height: 1.55;
}

.ask__notice svg {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.ask__notice--error {
    background: #FDF0ED;
    border-color: rgba(200, 85, 61, 0.25);
    color: #8C2F1C;
}

.ask__notice--ok {
    background: #EDF7F1;
    border-color: rgba(45, 106, 79, 0.22);
    color: #1F4D39;
}

/* ==========================================================================
   Grid
   ========================================================================== */

.ask__main {
    display: grid;
    /* 660px of writing column ≈ 70 characters at this type size, inside the 50–75 range. */
    grid-template-columns: minmax(0, 660px) minmax(0, 300px);
    align-items: start;
    gap: var(--space-xl) var(--space-2xl);
}

/* On desktop the tips move into the rail beside the form; on mobile they stay where the DOM
   puts them, which is above it. */
.ask__tips { grid-column: 2; grid-row: 1; }
.ask__form { grid-column: 1; grid-row: 1; }
.qa-next   { grid-column: 1; grid-row: 2; }

/* ==========================================================================
   Tips
   ========================================================================== */

.ask__tips {
    position: sticky;
    top: calc(var(--header-height, 64px) + var(--space-lg));
    padding: var(--space-lg);
    background: var(--color-bg-warm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.ask__tips-title {
    margin: 0 0 var(--space-md);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-ink-light);
}

.ask__tips-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ask__tips-list li {
    padding-left: var(--space-md);
    border-left: 2px solid var(--color-accent);
}

.ask__tips-list strong {
    display: block;
    margin-bottom: 0.2rem;
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-ink);
}

.ask__tips-list span {
    display: block;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--color-ink-light);
}

/* ==========================================================================
   Form
   ========================================================================== */

.ask__form {
    padding: var(--space-xl);
    background: var(--color-bg-card, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

/* --- who this gets signed by --- */
.ask__identity {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0 0 var(--space-xl);
    padding: 0.75rem 0.9rem;
    background: var(--color-bg-warm);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-ink-light);
}

.ask__identity strong {
    color: var(--color-ink);
}

.ask__identity-avatar {
    flex-shrink: 0;
    border-radius: 50%;
}

.ask__identity--guest svg {
    flex-shrink: 0;
    color: var(--color-ink-muted);
}

/* --- fields --- */
.ask__field {
    margin: 0 0 var(--space-lg);
}

.ask__field label {
    display: block;
    margin: 0 0 0.4rem;
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-ink);
}

.ask__req {
    color: var(--color-accent);
}

.ask__field input[type="text"],
.ask__field select,
.ask__field textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-ink);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.ask__field textarea {
    min-height: 150px;
    resize: vertical;
    /* JS grows this with the content; the cap keeps a long question from pushing the submit
       button off the screen entirely. */
    max-height: 640px;
}

.ask__field input:focus,
.ask__field select:focus,
.ask__field textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(200, 85, 61, 0.12);
}

/* State comes from the JS, NOT from :invalid/:user-invalid — the rules differ from the
   browser's (the server measures wp_strip_all_tags() output) and the field must be able to
   show a neutral "not finished yet" state that CSS pseudo-classes cannot express. */
.ask__field.is-error input,
.ask__field.is-error select,
.ask__field.is-error textarea {
    border-color: var(--color-accent);
    background: #FDF6F4;
}

.ask__field.is-ok input,
.ask__field.is-ok select,
.ask__field.is-ok textarea {
    border-color: rgba(45, 106, 79, 0.45);
}

.ask__hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--color-ink-muted);
}

/* Live counter / validation result. Empty until there is something to say, so an untouched
   field shows no state at all. */
.ask__msg {
    display: block;
    min-height: 1.2em;
    margin-top: 0.3rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-ink-muted);
}

.ask__msg.is-error { color: #8C2F1C; }

/* Positive confirmation, which Baymard found "added a sense of accomplishment and progression
   to the whole typing experience" and lets people stop re-reading the form before submitting. */
.ask__msg.is-ok {
    color: #1F4D39;
}

.ask__msg.is-ok::before {
    content: "✓ ";
    font-weight: 700;
}

/* --- actions --- */
.ask__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

/* Shared by the <button> and the <a> beside it, so both must be measured the same way:
   a 1px TRANSPARENT border (not `none`) to match the secondary's border box, and an explicit
   line-height because a <button> defaults to `normal` while an <a> inherits the body's 1.6.
   Without both, the link renders 7px taller than the button and the pair looks misaligned. */
.ask__submit {
    padding: 0.9rem 1.75rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--color-btn);
    color: #fff;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.ask__submit:hover {
    background: var(--color-btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(204, 76, 76, 0.28);
}

.ask__submit:focus-visible {
    outline: 2px solid var(--color-ink);
    outline-offset: 2px;
}

/* The "Am deja cont" half of the pair. An <a> in the markup, so it needs the inline-flex +
   centring an <a> does not get for free from the button rules above. */
.ask__submit--secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-ink);
    text-decoration: none;
}

.ask__submit--secondary:hover {
    background: var(--color-bg-warm);
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: none;
}

/* Draft indicator. Fades rather than disappearing, so it reads as a passing confirmation and
   not as a control. */
.ask__draft {
    font-size: 0.8125rem;
    color: var(--color-ink-muted);
    opacity: 0;
    transition: opacity var(--transition);
}

.ask__draft.is-on { opacity: 1; }

.ask__draft::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: var(--color-emerald, #2D6A4F);
    vertical-align: middle;
}

.ask__reassure {
    margin: var(--space-md) 0 0;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--color-ink-light);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .ask__main {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Single column: DOM order takes over, so the tips land above the form — which is when
       they are useful. The sticky rail is dropped with it. */
    .ask__tips,
    .ask__form,
    .qa-next {
        grid-column: 1;
        grid-row: auto;
    }

    .ask__tips {
        position: static;
    }
}

@media (max-width: 640px) {
    .ask__form {
        padding: var(--space-lg);
    }

    .ask__actions {
        flex-direction: column;
        align-items: stretch;
    }

    /* Full width and 48px tall — the old button was a 185px chip. */
    .ask__submit {
        width: 100%;
        min-height: 48px;
    }

    .ask__draft {
        text-align: center;
    }
}

/* 16px, so iOS does not zoom the viewport when the field takes focus. Moved out of the 640px
   block above: a phone in landscape is ~930px wide and zooms just the same, as does an iPad. */
@media (pointer: coarse) {
    .ask__field input[type="text"],
    .ask__field select,
    .ask__field textarea {
        font-size: 1rem;
    }

    /* Clicking a label focuses its field, so it is a target too — 22px here. WCAG 2.2 would
       excuse it because the field below does the same job at full size; two pixels is cheaper
       than relying on that. */
    .ask__field label {
        min-height: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ask__submit,
    .ask__draft {
        transition: none;
    }

    .ask__submit:hover {
        transform: none;
    }
}
