/* ==========================================================================
   Engagement FAQ (engagement.html #eng-faq) - live-chat style
   Left: the questions as cards ("Tap a question"). Right: a chat window where
   the tapped question is sent as the visitor's message, a typing indicator
   shows, and the NASR team's answer arrives as a reply.
   Without JavaScript the plain question/answer list (.efq-source) is shown.
   Script: assets/js/eng-faq.js. Everything is scoped to #eng-faq.
   ========================================================================== */

#eng-faq {
    --efq-gold: #C9A438;
    --efq-gold-hi: #E7CF86;
    --efq-gold-deep: #A7832A;
    --efq-navy: #111A2E;
    --efq-navy-2: #1B2A4A;
    --efq-ink: #111A2E;
    --efq-text: #475569;
    --efq-muted: #64748B;
    --efq-card: #FFFFFF;
    --efq-line: rgba(17, 26, 46, 0.08);
    --efq-chat-bg: #F6F4EE;
    --efq-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --efq-grad: linear-gradient(135deg, #E7CF86 0%, #C9A438 55%, #A7832A 100%);
}

html.dark-mode #eng-faq {
    --efq-ink: #F1F5F9;
    --efq-text: #C2CDDB;
    --efq-muted: #AAB8CA;
    --efq-card: #121D33;
    --efq-line: rgba(255, 255, 255, 0.08);
    --efq-chat-bg: #0D1628;
}

/* ---------- plain list (no JavaScript) ---------- */
#eng-faq .efq-source {
    display: grid;
    gap: 1rem;
    max-width: 860px;
    margin: 2.5rem auto 0;
}

#eng-faq .efq-pair {
    padding: 1.3rem 1.5rem;
    border-radius: 18px;
    border: 1px solid var(--efq-line);
    background: var(--efq-card);
}

#eng-faq .efq-pair dt {
    margin-bottom: 0.5rem;
    color: var(--efq-ink);
    font-family: var(--font-heading);
    font-weight: 700;
}

#eng-faq .efq-pair dd {
    margin: 0;
    color: var(--efq-text);
    line-height: 1.7;
}

#eng-faq .efq-pair dd p {
    margin: 0;
}

/* with the script: the chat replaces the list */
#eng-faq.efq-on .efq-source {
    display: none;
}

#eng-faq.efq-on .efq-layout[hidden] {
    display: grid;
}

/* ---------- layout ---------- */
#eng-faq .efq-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr);
    gap: clamp(1.25rem, 3vw, 2.5rem);
    align-items: stretch;
    max-width: 1180px;
    margin: clamp(2rem, 4vw, 3rem) auto 0;
    text-align: left;
}

/* ---------- question picker ---------- */
#eng-faq .efq-picker {
    display: flex;
    flex-direction: column;
}

#eng-faq .efq-picker-kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 0.35rem;
    color: var(--efq-gold-deep);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

#eng-faq .efq-pulse {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--efq-gold);
}

#eng-faq .efq-pulse::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--efq-gold);
    animation: efqPulse 1.8s ease-out infinite;
}

@keyframes efqPulse {
    from { transform: scale(0.6); opacity: 0.9; }
    to { transform: scale(1.8); opacity: 0; }
}

#eng-faq .efq-picker-title {
    margin: 0 0 1.1rem;
    color: var(--efq-ink);
    font-size: clamp(1.35rem, 2vw, 1.7rem);
}

#eng-faq .efq-qlist {
    display: grid;
    gap: 0.75rem;
}

#eng-faq .efq-q {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid var(--efq-line);
    border-radius: 16px;
    background: var(--efq-card);
    color: var(--efq-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(17, 26, 46, 0.04), 0 10px 24px -20px rgba(17, 26, 46, 0.4);
    transition: transform 0.4s var(--efq-ease), border-color 0.3s ease, box-shadow 0.4s var(--efq-ease), background 0.3s ease;
}

#eng-faq .efq-q:hover {
    transform: translateX(6px);
    border-color: rgba(201, 164, 56, 0.55);
    box-shadow: 0 2px 4px rgba(17, 26, 46, 0.05), 0 18px 34px -22px rgba(17, 26, 46, 0.5);
}

#eng-faq .efq-q:focus-visible {
    outline: 2px solid var(--efq-gold);
    outline-offset: 3px;
}

#eng-faq .efq-q.is-current {
    border-color: var(--efq-gold);
    background:
        linear-gradient(90deg, rgba(201, 164, 56, 0.12), rgba(201, 164, 56, 0) 70%),
        var(--efq-card);
    box-shadow: 0 0 0 4px rgba(201, 164, 56, 0.12), 0 18px 34px -22px rgba(17, 26, 46, 0.5);
}

#eng-faq .efq-q-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(201, 164, 56, 0.12);
    color: var(--efq-gold-deep);
    transition: background 0.35s ease, color 0.35s ease, transform 0.45s var(--efq-ease);
}

#eng-faq .efq-q:hover .efq-q-icon,
#eng-faq .efq-q.is-current .efq-q-icon {
    background: var(--efq-grad);
    color: var(--efq-navy);
    transform: rotate(-8deg);
}

#eng-faq .efq-q svg,
#eng-faq .efq-compose svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#eng-faq .efq-q svg path,
#eng-faq .efq-q svg circle,
#eng-faq .efq-compose svg path {
    stroke: currentColor !important;
    fill: none;
}

#eng-faq .efq-q-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#eng-faq .efq-q-topic {
    color: var(--efq-gold-deep);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#eng-faq .efq-q-text {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
}

/* "asked" tick */
#eng-faq .efq-q-state {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px dashed rgba(201, 164, 56, 0.5);
    color: transparent;
    transition: background 0.35s ease, border-color 0.35s ease, color 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#eng-faq .efq-q-state svg {
    width: 14px;
    height: 14px;
    stroke-width: 3;
}

#eng-faq .efq-q.is-asked .efq-q-state {
    border: 0;
    background: var(--efq-grad);
    color: var(--efq-navy);
    transform: scale(1.08);
}

#eng-faq .efq-picker-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 1rem;
}

#eng-faq .efq-count {
    margin: 0;
    color: var(--efq-muted);
    font-size: 0.88rem;
}

#eng-faq .efq-count-num {
    color: var(--efq-gold-deep);
}

#eng-faq .efq-showall {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(201, 164, 56, 0.5);
    background: transparent;
    color: var(--efq-gold-deep);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease;
}

#eng-faq .efq-showall:hover {
    background: var(--efq-grad);
    color: var(--efq-navy);
}

#eng-faq .efq-showall:focus-visible {
    outline: 2px solid var(--efq-gold);
    outline-offset: 3px;
}

/* ---------- chat window ---------- */
#eng-faq .efq-chat {
    display: flex;
    flex-direction: column;
    min-height: 460px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--efq-line);
    background: var(--efq-chat-bg);
    box-shadow: 0 2px 4px rgba(17, 26, 46, 0.05), 0 34px 70px -36px rgba(17, 26, 46, 0.55);
}

#eng-faq .efq-chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--efq-navy) 0%, var(--efq-navy-2) 100%);
    color: #FFFFFF;
}

#eng-faq .efq-avatar {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--efq-grad);
    color: var(--efq-navy);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.05rem;
}

#eng-faq .efq-chat-who {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

#eng-faq .efq-chat-who b {
    color: #FFFFFF;
    font-size: 0.98rem;
}

#eng-faq .efq-chat-who small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.75rem;
}

#eng-faq .efq-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34D399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

/* message log */
#eng-faq .efq-log {
    position: relative;
    flex: 1 1 auto;
    height: 360px;
    padding: 18px 16px 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    background:
        radial-gradient(circle at 1px 1px, rgba(201, 164, 56, 0.16) 1px, transparent 1.5px) 0 0 / 18px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 164, 56, 0.5) transparent;
}

#eng-faq .efq-log:focus-visible {
    outline: 2px solid var(--efq-gold);
    outline-offset: -2px;
}

#eng-faq .efq-day {
    display: block;
    width: fit-content;
    margin: 0 auto 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(17, 26, 46, 0.06);
    color: var(--efq-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

html.dark-mode #eng-faq .efq-day {
    background: rgba(255, 255, 255, 0.06);
}

#eng-faq .efq-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
    animation: efqIn 0.45s var(--efq-ease) both;
}

@keyframes efqIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

#eng-faq .efq-msg.is-me {
    justify-content: flex-end;
}

#eng-faq .efq-msg-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--efq-grad);
    color: var(--efq-navy);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 800;
}

#eng-faq .efq-bubble {
    position: relative;
    max-width: min(82%, 520px);
    padding: 11px 14px 8px;
    border-radius: 18px 18px 18px 6px;
    background: var(--efq-card);
    color: var(--efq-text);
    font-size: 0.93rem;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(17, 26, 46, 0.06), 0 8px 18px -14px rgba(17, 26, 46, 0.45);
}

#eng-faq .efq-bubble p {
    margin: 0;
}

#eng-faq .efq-msg.is-me .efq-bubble {
    border-radius: 18px 18px 6px 18px;
    background: var(--efq-grad);
    color: var(--efq-navy);
    font-weight: 600;
}

#eng-faq .efq-time {
    display: block;
    margin-top: 3px;
    color: var(--efq-muted);
    font-size: 0.66rem;
    text-align: right;
}

#eng-faq .efq-msg.is-me .efq-time {
    color: rgba(17, 26, 46, 0.6);
}

/* answer key facts */
#eng-faq .efq-hl {
    padding: 0 2px;
    border-radius: 3px;
    background: linear-gradient(transparent 58%, rgba(201, 164, 56, 0.38) 58%) no-repeat 0 0 / 0% 100%;
    color: var(--efq-ink);
    font-weight: 600;
    animation: efqMark 0.9s var(--efq-ease) 0.45s forwards;
}

@keyframes efqMark {
    to { background-size: 100% 100%; }
}

/* a message the visitor re-asked: a brief glow */
#eng-faq .efq-msg.is-flash .efq-bubble {
    animation: efqFlash 1.2s ease;
}

@keyframes efqFlash {
    0%, 100% { box-shadow: 0 1px 2px rgba(17, 26, 46, 0.06); }
    30% { box-shadow: 0 0 0 4px rgba(201, 164, 56, 0.45); }
}

/* typing indicator */
#eng-faq .efq-typing .efq-bubble {
    display: inline-flex;
    gap: 5px;
    padding: 14px 16px;
}

#eng-faq .efq-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--efq-gold);
    animation: efqType 1.1s ease-in-out infinite;
}

#eng-faq .efq-typing i:nth-child(2) { animation-delay: 0.15s; }
#eng-faq .efq-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes efqType {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* quick follow-up chips inside the chat */
#eng-faq .efq-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 2px 0 12px 36px;
    animation: efqIn 0.45s var(--efq-ease) both;
}

#eng-faq .efq-chip {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(201, 164, 56, 0.55);
    background: var(--efq-card);
    color: var(--efq-gold-deep);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, transform 0.3s var(--efq-ease);
}

#eng-faq .efq-chip:hover {
    background: var(--efq-grad);
    color: var(--efq-navy);
    transform: translateY(-2px);
}

#eng-faq .efq-chip:focus-visible {
    outline: 2px solid var(--efq-gold);
    outline-offset: 2px;
}

/* composer (link to the contact page) */
#eng-faq .efq-compose {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
    border-top: 1px solid var(--efq-line);
    background: var(--efq-card);
    text-decoration: none;
}

#eng-faq .efq-compose-field {
    flex: 1 1 auto;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--efq-line);
    background: var(--efq-chat-bg);
    color: var(--efq-muted);
    font-size: 0.88rem;
    transition: border-color 0.3s ease, color 0.3s ease;
}

#eng-faq .efq-compose-send {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--efq-grad);
    color: var(--efq-navy);
    box-shadow: 0 10px 20px -10px rgba(167, 131, 42, 0.9);
    transition: transform 0.35s var(--efq-ease);
}

#eng-faq .efq-compose:hover .efq-compose-field {
    border-color: rgba(201, 164, 56, 0.6);
    color: var(--efq-ink);
}

#eng-faq .efq-compose:hover .efq-compose-send {
    transform: translate(2px, -2px) rotate(-12deg);
}

#eng-faq .efq-compose:focus-visible {
    outline: 2px solid var(--efq-gold);
    outline-offset: -3px;
}

/* ---------- entrance ---------- */
#eng-faq.efq-on .efq-layout.efq-ready .efq-q,
#eng-faq.efq-on .efq-layout.efq-ready .efq-chat {
    opacity: 0;
    transform: translateY(18px);
}

#eng-faq.efq-on .efq-layout.efq-ready.is-in .efq-q,
#eng-faq.efq-on .efq-layout.efq-ready.is-in .efq-chat {
    opacity: 1;
    transform: none;
    transition: opacity 0.6s var(--efq-ease) calc(var(--i, 0) * 0.08s), transform 0.6s var(--efq-ease) calc(var(--i, 0) * 0.08s);
}

#eng-faq.efq-on .efq-layout.efq-ready.is-in .efq-chat {
    transition-delay: 0.15s;
}

#eng-faq.efq-on .efq-layout.efq-ready.is-in .efq-q:hover {
    transform: translateX(6px);
    transition: transform 0.4s var(--efq-ease), border-color 0.3s ease, box-shadow 0.4s var(--efq-ease);
}

/* ---------- tablets & phones ---------- */
@media (max-width: 900px) {
    #eng-faq .efq-layout {
        grid-template-columns: 1fr;
    }

    #eng-faq .efq-q:hover {
        transform: none;
    }
}

@media (max-width: 640px) {
    #eng-faq .efq-chat {
        min-height: 0;
    }

    #eng-faq .efq-log {
        height: 340px;
        padding: 14px 10px 6px;
    }

    #eng-faq .efq-bubble {
        max-width: 88%;
        font-size: 0.9rem;
    }

    #eng-faq .efq-chips {
        margin-left: 0;
    }
}

/* ---------- dark mode: the site theme forces light text colours; keep these exact ---------- */
html.dark-mode body.dark-mode #eng-faq .efq-q,
html.dark-mode body.dark-mode #eng-faq .efq-pair {
    background: linear-gradient(160deg, #15223B 0%, #0F192D 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode body.dark-mode #eng-faq .efq-q-text,
html.dark-mode body.dark-mode #eng-faq .efq-picker-title,
html.dark-mode body.dark-mode #eng-faq .efq-pair dt,
html.dark-mode body.dark-mode #eng-faq .efq-hl {
    color: #F1F5F9 !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-q-topic,
html.dark-mode body.dark-mode #eng-faq .efq-picker-kicker,
html.dark-mode body.dark-mode #eng-faq .efq-count-num,
html.dark-mode body.dark-mode #eng-faq .efq-showall,
html.dark-mode body.dark-mode #eng-faq .efq-chip {
    color: var(--efq-gold-hi) !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-q-icon {
    color: var(--efq-gold-hi) !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-q:hover .efq-q-icon,
html.dark-mode body.dark-mode #eng-faq .efq-q.is-current .efq-q-icon,
html.dark-mode body.dark-mode #eng-faq .efq-showall:hover,
html.dark-mode body.dark-mode #eng-faq .efq-chip:hover,
html.dark-mode body.dark-mode #eng-faq .efq-msg.is-me .efq-bubble,
html.dark-mode body.dark-mode #eng-faq .efq-msg.is-me .efq-bubble *,
html.dark-mode body.dark-mode #eng-faq .efq-avatar,
html.dark-mode body.dark-mode #eng-faq .efq-msg-avatar {
    color: var(--efq-navy) !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-bubble,
html.dark-mode body.dark-mode #eng-faq .efq-bubble p,
html.dark-mode body.dark-mode #eng-faq .efq-pair dd,
html.dark-mode body.dark-mode #eng-faq .efq-count,
html.dark-mode body.dark-mode #eng-faq .efq-compose-field {
    color: #C2CDDB !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-chat-who b {
    color: #FFFFFF !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-chat-who small {
    color: rgba(255, 255, 255, 0.72) !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-chip {
    background: #15223B;
}

/* "asked" tick: empty until the question is asked */
html.dark-mode body.dark-mode #eng-faq .efq-q-state {
    color: transparent !important;
}

html.dark-mode body.dark-mode #eng-faq .efq-q.is-asked .efq-q-state {
    color: var(--efq-navy) !important;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    #eng-faq *,
    #eng-faq *::before,
    #eng-faq *::after {
        animation: none !important;
        transition: none !important;
    }

    #eng-faq .efq-hl {
        background-size: 100% 100%;
    }

    #eng-faq.efq-on .efq-layout.efq-ready .efq-q,
    #eng-faq.efq-on .efq-layout.efq-ready .efq-chat {
        opacity: 1;
        transform: none;
    }
}

/* ---------- Dark mode colour restore ----------
   style.css forces every span in dark mode to grey with !important (weight 0,5,2),
   which made the send icon grey on its gold button. ":not(#efq-x)" only adds weight. */
html.dark-mode #eng-faq .efq-compose-send:not(#efq-x) { color: var(--efq-navy) !important; }
