/**
 * "Question & Answer" expand / collapse blocks inside topic content.
 *
 * One stylesheet, loaded everywhere the content can appear: the reader page,
 * the admin content view, and the TinyMCE editing iframes (through
 * `content_css`) — so what the writer sees while writing is what the reader
 * gets.
 *
 * The markup comes from static/js/qa_toggle.js:
 *
 *   <details class="qa-toggle">
 *     <summary class="qa-toggle-summary">
 *       <span class="qa-toggle-question">Question text</span>
 *     </summary>
 *     <div class="qa-toggle-answer"><p>Answer text</p></div>
 *   </details>
 *
 * The chevron is drawn with ::after below rather than a real element —
 * TinyMCE's serializer drops empty inline elements on save, so an icon
 * <span> with no text would vanish the moment the content was saved.
 *
 * <details>/<summary> are plain HTML5: clicking the question toggles the
 * answer open or closed in every modern browser with no extra JavaScript on
 * the reader page. This file only supplies the look.
 */

.qa-toggle {
    display: block;
    width: 100%;
    margin: 1.1rem 0;
    border: 1px solid rgba(93, 64, 55, 0.16);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(45, 27, 20, 0.04);
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.qa-toggle:hover {
    border-color: rgba(244, 123, 32, 0.45);
}

.qa-toggle[open] {
    border-color: #F47B20;
    box-shadow: 0 6px 18px rgba(93, 64, 55, 0.1);
}

/* ── The clickable question row ─────────────────────────────────────────── */
.qa-toggle-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    list-style: none;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    color: #1A4FA3;
    -webkit-tap-highlight-color: transparent;
}

/* Changing `display` away from the default `list-item` already drops the
   native triangle in current browsers; these two rules are just belt and
   braces for engines that still render one. */
.qa-toggle-summary::-webkit-details-marker {
    display: none;
}

.qa-toggle-summary::marker {
    content: '';
}

.qa-toggle-summary:focus-visible {
    outline: 2px solid #F47B20;
    outline-offset: -2px;
}

.qa-toggle-question {
    flex: 1 1 auto;
    min-width: 0;
}

/* Custom chevron — rotates in place instead of the browser's default marker,
   so it matches the rest of the site's icon style. A pseudo-element, not a
   real node, so there is nothing for TinyMCE to strip as "empty" on save. */
.qa-toggle-summary::after {
    content: '';
    flex: 0 0 auto;
    width: 0.6rem;
    height: 0.6rem;
    margin-left: 0.75rem;
    margin-top: -0.2rem;
    border-right: 2px solid #F47B20;
    border-bottom: 2px solid #F47B20;
    transform: rotate(45deg);
    transition: transform 0.2s ease, margin-top 0.2s ease;
}

.qa-toggle[open] > .qa-toggle-summary::after {
    transform: rotate(-135deg);
    margin-top: 0.25rem;
}

/* ── The answer panel ──────────────────────────────────────────────────── */
.qa-toggle-answer {
    padding: 0.85rem 1.1rem 1.1rem;
    border-top: 1px solid rgba(93, 64, 55, 0.1);
    color: #2d1b14;
    line-height: 1.65;
}

.qa-toggle-answer > p {
    margin: 0 0 0.75rem;
}

.qa-toggle-answer > p:last-child {
    margin-bottom: 0;
}

/* Editor-only edit/remove controls — stripped before save, never shown to
   readers (mirrors .content-file-remove in content-file.css). */
.qa-toggle-controls {
    display: none;
}

.mce-content-body .qa-toggle-controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    margin-left: auto;
}

.mce-content-body .qa-toggle-edit,
.mce-content-body .qa-toggle-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    border: 1px solid rgba(93, 64, 55, 0.16);
    background: #fff;
    color: #7a6a63;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.mce-content-body .qa-toggle-edit:hover {
    background: #1A4FA3;
    border-color: #1A4FA3;
    color: #fff;
}

.mce-content-body .qa-toggle-remove:hover {
    background: #e5484d;
    border-color: #e5484d;
    color: #fff;
}

@media (max-width: 30rem) {
    .qa-toggle-summary {
        padding: 0.75rem 0.9rem;
        font-size: 0.95rem;
    }
    .qa-toggle-answer {
        padding: 0 0.9rem 0.9rem;
        padding-top: 0.75rem;
    }
}
