/*
 * frontend/styles/product-qa.css
 *
 * Product Q&A (#1353).
 *
 * Follows the card language already used by the review section in product.css
 * — white surface, soft shadow, the same accent — so the two read as siblings
 * rather than as one feature bolted onto another. The dark-mode block mirrors
 * the treatment the other pages received in #1096/#1156.
 */

/* Visually hidden, still announced. The textareas carry placeholders, which
   are not labels: a screen reader user gets nothing once text is typed. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#product-qa h2 {
    margin-bottom: 6px;
}

.qa-intro {
    color: #6c757d;
    max-width: 62ch;
    margin: 0 0 22px;
}

/* ------------------------------------------------------------------
   Ask box
   ------------------------------------------------------------------ */

.qa-ask-form {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 30px;
}

.qa-ask-form textarea,
.qa-answer-form textarea {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid #d5d9dd;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #1d2b32;
    background: #fff;
    /* Vertical only: horizontal resize breaks the flex row on narrow
       viewports. */
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qa-ask-form textarea:focus,
.qa-answer-form textarea:focus {
    outline: none;
    border-color: #088178;
    box-shadow: 0 0 0 3px rgba(8, 129, 120, 0.15);
}

.qa-ask-form button,
.qa-answer-form button {
    background: #088178;
    color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.qa-ask-form button:hover,
.qa-answer-form button:hover {
    background: #066b64;
}

/* ------------------------------------------------------------------
   Questions
   ------------------------------------------------------------------ */

.qa-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.qa-empty,
.qa-unanswered {
    color: #6c757d;
    font-size: 14px;
    margin: 0;
}

.qa-empty {
    padding: 22px;
    background: #f8f9fa;
    border: 1px dashed #d5d9dd;
    border-radius: 12px;
}

.qa-question {
    background: #fff;
    border: 1px solid #e6e8eb;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

.qa-question-body {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: #1d2b32;
    line-height: 1.5;
    /* A long unbroken token would otherwise push the card wider than the page
       and scroll the body sideways. */
    overflow-wrap: anywhere;
}

.qa-q-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-right: 9px;
    border-radius: 50%;
    background: #088178;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    vertical-align: 1px;
}

.qa-question-meta,
.qa-answer-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12.5px;
    color: #8a9299;
}

.qa-author {
    font-weight: 600;
    color: #1d2b32;
}

/* ------------------------------------------------------------------
   Answers
   ------------------------------------------------------------------ */

.qa-answers {
    list-style: none;
    margin: 16px 0 0;
    padding: 0 0 0 18px;
    /* A rail rather than indentation alone, so the answer/question hierarchy
       survives on a narrow screen where the indent is small. */
    border-left: 2px solid #eceff1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qa-answer-body {
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 1.6;
    color: #35424a;
    overflow-wrap: anywhere;
}

/* The badge is the point of the whole ranking: an answer from someone holding
   the product must be visibly different from a guess. */
.qa-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.qa-badge-owner {
    background: rgba(8, 129, 120, 0.12);
    color: #066b64;
}

.qa-badge-seller {
    background: rgba(58, 90, 217, 0.12);
    color: #2f47ac;
}

.qa-answer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 9px;
}

.qa-helpful-btn,
.qa-report-btn {
    background: transparent;
    border: 1px solid #d5d9dd;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12.5px;
    font-family: inherit;
    color: #6c757d;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.qa-helpful-btn:hover {
    border-color: #088178;
    color: #088178;
}

/* Visual counterpart of aria-pressed. */
.qa-helpful-btn.is-active {
    border-color: #088178;
    background: rgba(8, 129, 120, 0.1);
    color: #088178;
    font-weight: 600;
}

.qa-report-btn:hover {
    border-color: #d64545;
    color: #d64545;
}

.qa-helpful-btn:focus-visible,
.qa-report-btn:focus-visible,
.qa-ask-form button:focus-visible,
.qa-answer-form button:focus-visible {
    outline: 2px solid #088178;
    outline-offset: 2px;
}

.qa-reported {
    font-size: 12.5px;
    color: #8a9299;
    font-style: italic;
}

.qa-answer-form {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #f0f2f4;
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 640px) {
    .qa-ask-form,
    .qa-answer-form {
        flex-direction: column;
    }

    .qa-ask-form button,
    .qa-answer-form button {
        width: 100%;
    }

    .qa-answers {
        padding-left: 12px;
    }
}

/* ------------------------------------------------------------------
   Dark mode
   ------------------------------------------------------------------ */

body.dark-mode .qa-question {
    background: #1e1e1e;
    border-color: #333;
}

body.dark-mode .qa-empty {
    background: #181818;
    border-color: #333;
}

body.dark-mode .qa-question-body,
body.dark-mode .qa-author {
    color: #e8e8e8;
}

body.dark-mode .qa-answer-body {
    color: #d0d0d0;
}

body.dark-mode .qa-intro,
body.dark-mode .qa-unanswered,
body.dark-mode .qa-reported {
    color: #a8a8a8;
}

body.dark-mode .qa-answers {
    border-left-color: #2f2f2f;
}

body.dark-mode .qa-answer-form {
    border-top-color: #2a2a2a;
}

body.dark-mode .qa-ask-form textarea,
body.dark-mode .qa-answer-form textarea,
body.dark-mode .qa-helpful-btn,
body.dark-mode .qa-report-btn {
    background: #262626;
    border-color: #3a3a3a;
    color: #e0e0e0;
}
