/* =========================================================
   HND FAQ – Front-end styles
   All colours / radii / typography use CSS custom properties
   that are overridden by hnd_faq_inject_css_vars() in PHP.
   ========================================================= */

:root {
    --hnd-faq-accent:          #007cba;
    --hnd-faq-accent-bg:       #e8f4ff;
    --hnd-faq-head-bg:         #f8f8f8;
    --hnd-faq-head-hover-bg:   #f0f0f0;
    --hnd-faq-border-color:    #dddddd;
    --hnd-faq-border-radius:   8px;
    --hnd-faq-heading-size:    1.05rem;
    --hnd-faq-heading-weight:  600;
    --hnd-faq-body-color:      #444444;
    --hnd-faq-shadow:          0 2px 6px rgba(0, 0, 0, .07);
    --hnd-faq-answer-bg:       #ffffff;
    --hnd-faq-max-width:       100%;
    --hnd-faq-item-gap:        0px;
    --hnd-faq-cat-gap:         32px;
    --hnd-faq-head-pad-y:      1rem;
    --hnd-faq-body-pad-y:      0.75rem;

    /* ToC */
    --hnd-faq-toc-bg:          var(--hnd-faq-head-bg);
    --hnd-faq-toc-border:      var(--hnd-faq-border-color);
    --hnd-faq-toc-link:        var(--hnd-faq-accent);
    --hnd-faq-toc-link-active: var(--hnd-faq-accent);
    --hnd-faq-toc-font-size:   0.9rem;
    --hnd-faq-toc-top:         2rem;
}

/* ── Wrapper ─────────────────────────────────────────────── */

.hnd-faq-wrapper {
    margin: 2rem auto;
    max-width: var(--hnd-faq-max-width);
    width: 100%;
    box-sizing: border-box;
}

.hnd-faq-empty {
    color: #888;
    font-style: italic;
}

/* WooCommerce section title follows wrapper max-width */
.hnd-faq-woo-title {
    max-width: var(--hnd-faq-max-width);
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* ── Category group ──────────────────────────────────────── */

.hnd-faq-group {
    margin-bottom: var(--hnd-faq-cat-gap);
}

.hnd-faq-group__title {
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1a1a;
}

/* ── Accordion container ─────────────────────────────────── */

.hnd-faq-accordion {
    display: flex;
    flex-direction: column;
    gap: var(--hnd-faq-item-gap);
    border: 1px solid var(--hnd-faq-border-color);
    border-radius: var(--hnd-faq-border-radius);
    overflow: hidden;
    box-shadow: var(--hnd-faq-shadow);
    background: #fff;
}

/* ── Single item ─────────────────────────────────────────── */

.hnd-faq-item {
    border-top: 1px solid var(--hnd-faq-border-color);
    background: #fff;
    transition: background 0.3s ease;
}


.hnd-faq-item:first-child {
    border-top: none;
}

/* ── Head (clickable row) ────────────────────────────────── */

.hnd-faq-item__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--hnd-faq-head-pad-y) 1.5rem;
    cursor: pointer;
    background-color: var(--hnd-faq-head-bg);
    border-left: 4px solid transparent;
    transition: background 0.25s ease, border-color 0.25s ease;
    user-select: none;
}

.hnd-faq-item__head:hover {
    background-color: var(--hnd-faq-head-hover-bg);
}

/* Keyboard focus */
.hnd-faq-item__head:focus-visible {
    outline: 2px solid var(--hnd-faq-accent);
    outline-offset: -2px;
}

.hnd-faq-item.open .hnd-faq-item__head {
    background-color: var(--hnd-faq-accent-bg);
    border-left-color: var(--hnd-faq-accent);
}

/* ── Heading text ────────────────────────────────────────── */

.hnd-faq-item__heading-wrap {
    flex: 1;
    padding-right: 1rem;
}

.hnd-faq-item__heading {
    margin: 0;
    padding: 0;
    font-size: var(--hnd-faq-heading-size);
    font-weight: var(--hnd-faq-heading-weight);
    color: #1a1a1a;
    line-height: 1.4;
}

/* ── Icon ────────────────────────────────────────────────── */

.hnd-faq-item__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--hnd-faq-accent);
}

/* Plus/minus icon */
.hnd-faq-icon--plus .hnd-faq-icon__collapse {
    display: none;
}

.hnd-faq-item.open .hnd-faq-icon--plus .hnd-faq-icon__expand {
    display: none;
}

.hnd-faq-item.open .hnd-faq-icon--plus .hnd-faq-icon__collapse {
    display: block;
}

/* Chevron icon – rotates on open */
.hnd-faq-icon--chevron {
    transition: transform 0.25s ease;
    stroke: var(--hnd-faq-accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hnd-faq-item.open .hnd-faq-icon--chevron {
    transform: rotate(180deg);
}

/* Arrow icon – same rotation trick */
.hnd-faq-icon--arrow {
    transition: transform 0.25s ease;
    stroke: var(--hnd-faq-accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hnd-faq-item.open .hnd-faq-icon--arrow {
    transform: rotate(180deg);
}

/* SVG fill for plus icons */
.hnd-faq-icon__expand path,
.hnd-faq-icon__collapse path {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    fill: none;
}

/* ── Body (answer) ───────────────────────────────────────── */

.hnd-faq-item__body {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease;
}

/* When [hidden] attribute is removed by JS */
.hnd-faq-item__body:not([hidden]) {
    max-height: none;
}

.hnd-faq-item.open .hnd-faq-item__body {
    max-height: 9999px;
    opacity: 1;
}

.hnd-faq-item__body-inner {
    padding: var(--hnd-faq-body-pad-y) 1.5rem calc(var(--hnd-faq-body-pad-y) + 0.5rem);
    border-top: 1px solid var(--hnd-faq-border-color);
    background-color: var(--hnd-faq-answer-bg);
    color: var(--hnd-faq-body-color);
    font-size: 0.95rem;
    line-height: 1.65;
}

.hnd-faq-item__body-inner > *:first-child { margin-top: 0; }
.hnd-faq-item__body-inner > *:last-child  { margin-bottom: 0; }

/* ── Toolbar (expand all) ────────────────────────────────── */

.hnd-faq-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.hnd-faq-expand-all {
    background: none;
    border: 1px solid var(--hnd-faq-border-color);
    border-radius: 4px;
    color: var(--hnd-faq-accent);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 12px;
    transition: background 0.2s, border-color 0.2s;
}

.hnd-faq-expand-all:hover {
    background: var(--hnd-faq-accent-bg);
    border-color: var(--hnd-faq-accent);
}

/* Toggle label based on state */
.hnd-faq-expand-all[data-state="collapsed"] .hnd-faq-expand-all__close,
.hnd-faq-expand-all[data-state="expanded"]  .hnd-faq-expand-all__open {
    display: none;
}

/* ── Icon position: left ─────────────────────────────────── */

.hnd-faq-item__head.hnd-faq-icon-left {
    flex-direction: row;
    gap: 0.75rem;
}

.hnd-faq-item__head.hnd-faq-icon-left .hnd-faq-item__heading-wrap {
    padding-right: 0;
    flex: 1;
}

/* ── Copy link button ────────────────────────────────────── */

.hnd-faq-copy-link {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: none;
    border: none;
    color: var(--hnd-faq-border-color);
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}

.hnd-faq-copy-link:hover {
    color: var(--hnd-faq-accent);
    background: var(--hnd-faq-accent-bg);
}

.hnd-faq-copy-link__tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
}

.hnd-faq-copy-link.copied .hnd-faq-copy-link__tooltip {
    opacity: 1;
    transform: translateY(0);
}

/* ── Per-item colour override ────────────────────────────── */

/* When an item has --hnd-faq-accent set inline, it naturally
   cascades to all accent usages within that item via CSS vars.
   No extra rules needed – the inline style on the element handles it. */

.hnd-faq-item.has-custom-color .hnd-faq-item__head:focus-visible {
    outline-color: var(--hnd-faq-accent);
}

/* ── Print ───────────────────────────────────────────────── */

@media print {
    .hnd-faq-wrapper { margin: 0; max-width: 100%; }

    .hnd-faq-toolbar,
    .hnd-faq-copy-link,
    .hnd-faq-item__icon { display: none !important; }

    .hnd-faq-accordion {
        border: none;
        box-shadow: none;
        gap: 0;
    }

    .hnd-faq-item {
        break-inside: avoid;
        border-top: 1px solid #ccc;
    }

    .hnd-faq-item__head {
        background: none !important;
        border-left: none !important;
        padding: 0.4rem 0;
        cursor: default;
    }

    /* Force all answers visible regardless of JS/hidden state */
    .hnd-faq-item__body,
    .hnd-faq-item__body[hidden] {
        display: block !important;
        max-height: none !important;
        opacity: 1 !important;
    }

    .hnd-faq-item__body-inner {
        border-top: none;
        padding: 0.2rem 0 0.6rem;
        background: none !important;
    }

    .hnd-faq-group__title { break-after: avoid; }
}

/* ── Table of Contents ───────────────────────────────────── */

.hnd-faq-toc {
    margin-bottom: 1.25rem;
    background: var(--hnd-faq-toc-bg);
    border: 1px solid var(--hnd-faq-toc-border);
    border-radius: var(--hnd-faq-border-radius);
    padding: 0.75rem 1rem;
}

.hnd-faq-toc__label {
    margin: 0 0 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
}

.hnd-faq-toc__list {
    margin: 0;
    padding: 0 0 0 1.25rem;
    font-size: var(--hnd-faq-toc-font-size);
    line-height: 1.8;
}

.hnd-faq-toc[data-numbered="true"] .hnd-faq-toc__list {
    list-style: decimal;
}

.hnd-faq-toc__link {
    color: var(--hnd-faq-toc-link);
    text-decoration: none;
}

.hnd-faq-toc__link:hover {
    text-decoration: underline;
}

.hnd-faq-toc__link.is-active {
    color: var(--hnd-faq-toc-link-active);
    font-weight: 600;
}

/* Sidebar layout */
.hnd-faq-has-toc-sidebar {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.hnd-faq-has-toc-sidebar .hnd-faq-toc--sidebar {
    flex-shrink: 0;
    width: 220px;
    position: sticky;
    top: var(--hnd-faq-toc-top);
    margin-bottom: 0;
}

.hnd-faq-has-toc-sidebar .hnd-faq-toc-main {
    flex: 1;
    min-width: 0;
}

@media (max-width: 600px) {
    .hnd-faq-has-toc-sidebar {
        flex-direction: column;
    }
    .hnd-faq-has-toc-sidebar .hnd-faq-toc--sidebar {
        width: 100%;
        position: static;
    }
}

/* ── "Was this helpful?" widget ─────────────────────────── */

.hnd-faq-helpful {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--hnd-faq-border-color);
    font-size: 0.85rem;
    color: #888;
}

.hnd-faq-helpful__label { flex-shrink: 0; }

.hnd-faq-helpful__actions { display: flex; gap: 0.5rem; }

.hnd-faq-helpful__btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--hnd-faq-border-color);
    border-radius: 4px;
    cursor: pointer;
    color: #888;
    font-size: 0.8rem;
    padding: 3px 10px;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    line-height: 1.4;
}

.hnd-faq-helpful__btn:hover {
    color: var(--hnd-faq-accent);
    border-color: var(--hnd-faq-accent);
}

.hnd-faq-helpful__btn--yes.voted {
    color: var(--hnd-faq-accent);
    border-color: var(--hnd-faq-accent);
    background: var(--hnd-faq-accent-bg);
}

.hnd-faq-helpful__btn--no.voted {
    color: #d63638;
    border-color: #d63638;
    background: #fef2f2;
}

.hnd-faq-helpful[data-voted] .hnd-faq-helpful__btn:not(.voted) {
    opacity: 0.4;
    pointer-events: none;
}

.hnd-faq-helpful__thanks {
    font-size: 0.8rem;
    color: #4caf50;
}

/* ── RTL ─────────────────────────────────────────────────── */

[dir="rtl"] .hnd-faq-item__head {
    border-left: none;
    border-right: 4px solid transparent;
}

[dir="rtl"] .hnd-faq-item.open .hnd-faq-item__head {
    border-right-color: var(--hnd-faq-accent);
}

[dir="rtl"] .hnd-faq-item__heading-wrap {
    padding-right: 0;
    padding-left: 1rem;
}

[dir="rtl"] .hnd-faq-item__head.hnd-faq-icon-left {
    flex-direction: row-reverse;
}

[dir="rtl"] .hnd-faq-copy-link {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .hnd-faq-copy-link__tooltip {
    right: auto;
    left: 0;
}
