/* ==========================================================
   ask-modal.css — the "ถามก่อนตัดสินใจ" dialog.
   ----------------------------------------------------------
   Loaded by training/ and coaching/, which have very different
   palettes, so this file defines its OWN tokens under
   .ask-overlay and never reads the host page's variables.
   Everything is scoped under .ask-* — nothing leaks out.

   The restraint is deliberate: the pages that use this sell
   the ability to build software, so the dialog has to feel
   engineered rather than decorated. One transition, one
   accent, no bounce.
   ========================================================== */

.ask-overlay {
    --ask-navy:   #0B1426;
    --ask-navy-2: #111D33;
    --ask-line:   rgba(255, 255, 255, 0.10);
    --ask-gold:   #E8B54B;
    --ask-gold-d: #C8962E;
    --ask-ink:    #F1F5F9;
    --ask-mute:   rgba(226, 232, 240, 0.70);
    --ask-radius: 16px;

    position: fixed;
    inset: 0;
    z-index: 100000;           /* above the site navbar (--z-nav 1000) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    font-family: 'Sarabun', 'Prompt', system-ui, sans-serif;
}
.ask-overlay[hidden] { display: none; }

.ask-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 17, 0.72);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.ask-dialog {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: min(88vh, 780px);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--ask-navy-2) 0%, var(--ask-navy) 100%);
    border: 1px solid var(--ask-line);
    border-radius: var(--ask-radius);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    color: var(--ask-ink);
    overflow: hidden;
    /* One entrance. No bounce — this is a tool, not a toy. */
    animation: ask-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes ask-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ask-dialog { animation: none; }
}

/* ── Header ─────────────────────────────────────────────── */
.ask-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--ask-line);
    flex-shrink: 0;
}
.ask-kicker {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--ask-gold);
    margin-bottom: 6px;
}
.ask-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.35;
    color: var(--ask-ink);
    font-family: inherit;
}
.ask-subject {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--ask-mute);
}
.ask-x {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--ask-line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ask-mute);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.18s ease, color 0.18s ease;
}
.ask-x:hover { background: rgba(255, 255, 255, 0.10); color: var(--ask-ink); }

/* ── Panels ─────────────────────────────────────────────── */
.ask-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 22px 22px;
}
.ask-panel[hidden] { display: none; }

/* ── Search ─────────────────────────────────────────────── */
.ask-search {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 14px;
}
.ask-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ask-mute);
    font-size: 0.9rem;
    pointer-events: none;
}
.ask-search input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border-radius: 10px;
    border: 1px solid var(--ask-line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--ask-ink);
    font-family: inherit;
    font-size: 0.94rem;
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease;
}
.ask-search input::placeholder { color: rgba(226, 232, 240, 0.42); }
.ask-search input:focus {
    border-color: rgba(232, 181, 75, 0.55);
    background: rgba(255, 255, 255, 0.08);
}
/* Kill the WebKit clear button — it collides with the custom styling. */
.ask-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ── Q&A list ───────────────────────────────────────────── */
.ask-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    flex: 1 1 auto;
}
.ask-item {
    border-bottom: 1px solid var(--ask-line);
}
.ask-item[hidden] { display: none; }
.ask-item:last-child { border-bottom: none; }

.ask-q {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 2px;
    background: none;
    border: 0;
    color: var(--ask-ink);
    font-family: inherit;
    font-size: 0.96rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: left;
    cursor: pointer;
    transition: color 0.18s ease;
}
.ask-q:hover { color: var(--ask-gold); }
.ask-chev {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--ask-mute);
    transition: transform 0.2s ease;
}
.ask-q[aria-expanded="true"] .ask-chev { transform: rotate(180deg); }
.ask-q[aria-expanded="true"] { color: var(--ask-gold); }

.ask-a {
    padding: 0 2px 16px;
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--ask-mute);
}
.ask-a[hidden] { display: none; }

/* Search highlight */
.ask-hit {
    background: rgba(232, 181, 75, 0.28);
    color: var(--ask-ink);
    border-radius: 3px;
    padding: 0 1px;
}

.ask-empty {
    margin: 0 0 16px;
    padding: 18px 2px;
    text-align: center;
    color: var(--ask-mute);
    font-size: 0.92rem;
}
.ask-empty[hidden] { display: none; }

/* ── Buttons ────────────────────────────────────────────── */
.ask-foot {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--ask-line);
}
.ask-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.ask-btn-primary {
    flex: 1 1 auto;
    background: linear-gradient(135deg, var(--ask-gold) 0%, var(--ask-gold-d) 100%);
    color: #241B06;
}
.ask-btn-primary:hover { filter: brightness(1.07); }
.ask-btn-primary:disabled { opacity: 0.65; cursor: default; filter: none; }
.ask-btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--ask-line);
    color: var(--ask-ink);
}
.ask-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(232, 181, 75, 0.40);
}

.ask-back {
    align-self: flex-start;
    margin-bottom: 14px;
    padding: 0;
    background: none;
    border: 0;
    color: var(--ask-mute);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: color 0.18s ease;
}
.ask-back:hover { color: var(--ask-gold); }

/* ── Form ───────────────────────────────────────────────── */
.ask-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.ask-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 520px) {
    .ask-row { grid-template-columns: 1fr; }
}
.ask-field {
    display: block;
    margin-bottom: 12px;
}
.ask-field > span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ask-mute);
}
.ask-field > span em { font-style: normal; opacity: 0.7; font-weight: 400; }
.ask-field input,
.ask-field textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--ask-line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--ask-ink);
    font-family: inherit;
    font-size: 0.94rem;
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease;
}
.ask-field textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.ask-field input::placeholder,
.ask-field textarea::placeholder { color: rgba(226, 232, 240, 0.38); }
.ask-field input:focus,
.ask-field textarea:focus {
    border-color: rgba(232, 181, 75, 0.55);
    background: rgba(255, 255, 255, 0.08);
}
.ask-field input.ask-invalid,
.ask-field textarea.ask-invalid {
    border-color: rgba(248, 113, 113, 0.70);
}

.ask-msg {
    margin: 4px 0 12px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.6;
}
.ask-msg[hidden] { display: none; }
.ask-msg.err {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #FCA5A5;
}

.ask-submit { width: 100%; }
.ask-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(36, 27, 6, 0.30);
    border-top-color: #241B06;
    border-radius: 50%;
    display: inline-block;
    animation: ask-spin 0.7s linear infinite;
}
@keyframes ask-spin { to { transform: rotate(360deg); } }
.ask-submit-loading { display: inline-flex; align-items: center; gap: 8px; }
.ask-submit-loading[hidden],
.ask-submit-label[hidden] { display: none; }

.ask-note {
    margin: 12px 0 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--ask-mute);
}

/* ── Done ───────────────────────────────────────────────── */
.ask-done {
    text-align: center;
    padding: 26px 0 12px;
}
.ask-done-mark {
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    color: #241B06;
    background: linear-gradient(135deg, var(--ask-gold) 0%, var(--ask-gold-d) 100%);
}
.ask-done h3 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ask-ink);
    font-family: inherit;
}
.ask-done p {
    margin: 0 0 22px;
    font-size: 0.92rem;
    color: var(--ask-mute);
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 560px) {
    .ask-overlay { padding: 0; align-items: flex-end; }
    .ask-dialog {
        max-width: none;
        max-height: 92vh;
        border-radius: var(--ask-radius) var(--ask-radius) 0 0;
        border-bottom: 0;
    }
    .ask-head { padding: 18px 18px 14px; }
    .ask-panel { padding: 16px 18px 20px; }
    .ask-title { font-size: 1.08rem; }
    .ask-foot { flex-direction: column; }
    .ask-btn { width: 100%; }
}
