/* SI4.me Ask area and FAQ (v48, tidied: the v39-v47 additions are merged into their own rules).
   The mode is set by /si/js/ask.js as data-ask-mode on #ask:
   0 off, 2 email, 4 input, 6 capture, 9 full AI. Without JavaScript the page shows the classic form (like mode 2).
   In mode 9 ask.js moves #ask above #stats and adds the class ask-top. */

/* ---- Free-standing question box with a glow behind it ---- */
.ask-x { position: relative; max-width: 860px; padding: 0; border: 0; background: none; gap: 0; }
.ask-x::before { display: none; }
.ask-x .zone { padding-block: 0; border-block-end: 0; }
.ask-glow { position: absolute; z-index: -1; left: 50%; top: -40px; width: min(150%, 100vw); height: 260px; translate: -50% 0; pointer-events: none; border-radius: 50%; background: radial-gradient(closest-side, rgba(46, 242, 176, .38), rgba(122, 134, 255, .26) 52%, rgba(166, 227, 255, .08) 78%, transparent); filter: blur(34px); opacity: .85; transition: opacity .6s var(--ease); animation: ask-breathe 7s ease-in-out infinite alternate; }
.ask-x:focus-within .ask-glow { opacity: 1; }
html[data-theme="light"] .ask-glow { opacity: .55; }
html[data-theme="light"] .ask-x:focus-within .ask-glow { opacity: .85; }
html.lite .ask-glow { filter: none; animation: none; opacity: .35; }
@keyframes ask-breathe { from { scale: .94 .9; } to { scale: 1.05 1.08; } }

.ask-q { display: grid; gap: 8px; }
/* The question heading is hidden on screen but still read by screen readers and AI */
.ask-q-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ask-privacy { justify-self: center; margin: -2px 0 0; text-align: center; font-size: 12.5px; opacity: .6; }
.ask-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Above the box: "Language" on the left; happiness hearts, the kindness face and the character count on the right */
.ask-meter { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: 6px 10px; margin-block-end: -2px; padding-inline: 6px; }
.ask-meter .ask-lead { margin: 0 auto 0 0; align-self: center; justify-content: flex-start; gap: 8px; font-size: .98rem; max-width: none; }
.ask-meter .lang-inline { width: 30px; height: 30px; }
.ask-meter .lang-inline .ico { width: 18px; height: 18px; }
.ask-meter-col { display: grid; justify-items: center; gap: 3px; }
.ask-meter .kind-wrap { margin: 0; }
#msg-count { font: 10.5px/1 var(--mono); color: var(--muted); letter-spacing: .02em; }
.ask-happy { display: flex; gap: 3px; padding-block-end: 2px; }
.ask-happy i { font-style: normal; font-size: 12px; line-height: 1; color: var(--line); opacity: .9; transition: color .4s, transform .4s var(--ease); }
.ask-happy i::before { content: "\2665"; }
html[data-theme="dark"] .ask-happy i, html:not([data-theme]) .ask-happy i { color: rgba(255, 255, 255, .14); }
.ask-happy[data-level="1"] i:nth-child(-n+1), .ask-happy[data-level="2"] i:nth-child(-n+2), .ask-happy[data-level="3"] i:nth-child(-n+3),
.ask-happy[data-level="4"] i:nth-child(-n+4), .ask-happy[data-level="5"] i { color: var(--signal); transform: scale(1.15); }
.ask-happy[data-level="4"] i:nth-child(-n+4), .ask-happy[data-level="5"] i { color: #FF6F9C; }
.ask-happy i.pop { animation: kpop .5s var(--ease); }

.ask-x textarea { min-height: 0; padding: 18px 48px 18px 20px; font-size: 17px; line-height: 1.55; border-radius: 18px; background: color-mix(in srgb, var(--surface-solid) 86%, transparent); border: 1px solid color-mix(in srgb, var(--signal) 26%, var(--line)); box-shadow: 0 10px 40px -18px rgba(0, 0, 0, .6); transition: border-color .3s, box-shadow .3s; }
.ask-x textarea:focus { border-color: var(--signal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 14%, transparent), 0 10px 40px -18px rgba(0, 0, 0, .6); outline: none; }
.ask-x textarea::placeholder { color: var(--muted); opacity: .85; }

/* ---- Topics (left 65%) and the Send button (right 35%) ---- */
.ask-actions { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; margin-block-start: 16px; }
.ask-go-wrap { display: none; }
#ask[data-ask-mode="4"] .ask-actions, #ask[data-ask-mode="6"] .ask-actions, #ask[data-ask-mode="9"] .ask-actions { grid-template-columns: 65fr 35fr; }
#ask[data-ask-mode="4"] .ask-go-wrap, #ask[data-ask-mode="6"] .ask-go-wrap, #ask[data-ask-mode="9"] .ask-go-wrap { display: block; }
.ask-go { width: 100%; min-height: 54px; justify-content: center; }
.ask-go[disabled] { opacity: .45; filter: grayscale(1); cursor: progress; box-shadow: none; }
@media (max-width: 600px) { #ask[data-ask-mode] .ask-actions { grid-template-columns: 1fr; } }

/* ---- Pretend-thinking loader ---- */
.ask-loader { display: grid; justify-items: center; gap: 10px; margin-block-start: 24px; }
.ask-loader[hidden] { display: none; }
.ask-loader-bar { width: min(320px, 80%); height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ask-loader-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-3, #7A86FF), var(--signal)); }
.ask-loader.is-on .ask-loader-bar i { animation: ask-fill var(--ask-wait, 2.4s) cubic-bezier(.3, .6, .4, 1) forwards; }
.ask-loader-text { font: 12.5px/1.4 var(--mono); color: var(--muted); transition: opacity .25s; }
.ask-loader-text.fade { opacity: 0; }
@keyframes ask-fill { to { width: 100%; } }

/* ---- Email step: open in mode 2 (and without JavaScript), slides out after "Send" in modes 4, 6, 9 ---- */
.ask-more { display: grid; grid-template-rows: 1fr; margin-block-start: 22px; transition: grid-template-rows .7s var(--ease), opacity .6s, margin .7s, visibility 0s; }
.ask-more-in { min-height: 0; overflow: hidden; }
.ask-more-card { padding: clamp(18px, 3.5vw, 30px); border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }
.ask-more-card .step-label { margin-block-end: 12px; font-weight: 500; line-height: 1.45; }
.ask-more-card .submit-row { padding-block-start: 20px; }
#ask[data-ask-mode="4"] .ask-more:not(.is-open), #ask[data-ask-mode="6"] .ask-more:not(.is-open), #ask[data-ask-mode="9"] .ask-more:not(.is-open) { grid-template-rows: 0fr; opacity: 0; margin-block-start: 0; visibility: hidden; transition: grid-template-rows .5s var(--ease), opacity .3s, margin .5s, visibility 0s .5s; }

/* ---- AI chat (mode 9) ---- */
.ask-chat { display: grid; gap: 12px; margin-block-start: 22px; padding: 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }
.ask-chat[hidden] { display: none; }
.ask-chat-log { display: grid; gap: 10px; max-height: 440px; overflow-y: auto; padding: 2px; }
.ask-msg { max-width: 86%; padding: 11px 14px; border-radius: 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; animation: ask-in .35s var(--ease); }
.ask-msg.is-user { justify-self: end; background: color-mix(in srgb, var(--accent-2) 18%, transparent); border-end-end-radius: 6px; }
.ask-msg.is-si { justify-self: start; background: color-mix(in srgb, var(--signal) 10%, transparent); border: 1px solid color-mix(in srgb, var(--signal) 22%, transparent); border-end-start-radius: 6px; }
.ask-typing { display: inline-flex; gap: 4px; }
.ask-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: ask-dot 1s infinite ease-in-out; }
.ask-typing i:nth-child(2) { animation-delay: .15s; } .ask-typing i:nth-child(3) { animation-delay: .3s; }
.ask-chat-in { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.ask-chat-in textarea { min-height: 46px; padding: 11px 14px; font-size: 15px; border-radius: 14px; resize: none; }
.ask-chat-send { width: 46px; height: 46px; padding: 0; justify-content: center; }
.ask-chat-mail { margin: 0; text-align: center; }
@keyframes ask-in { from { opacity: 0; translate: 0 6px; } }
@keyframes ask-dot { 0%, 80%, 100% { opacity: .25; scale: .8; } 40% { opacity: 1; scale: 1; } }

/* ---- Mode 0: upgrade notice over a faded picture of the Ask box ---- */
.ask-off { position: relative; isolation: isolate; overflow: hidden; display: grid; place-items: center; min-height: 260px; max-width: 860px; margin-inline: auto; padding: 32px 24px; border-radius: 22px; border: 1px solid var(--line); text-align: center; }
.ask-off[hidden] { display: none; }
.ask-off::before { content: ""; position: absolute; inset: 0; z-index: -1; background: url(/si/images/ask-preview.png) center / cover no-repeat; opacity: .2; filter: grayscale(.35) blur(1.5px); }
.ask-off-msg { margin: 0; max-width: 100%; font-size: clamp(1.2rem, 2.6vw, 1.6rem); font-weight: 300; line-height: 1.5; color: var(--text); text-wrap: pretty; }
#ask[data-ask-mode="0"] .ask-x, #ask[data-ask-mode="0"] .ask-lead, #ask[data-ask-mode="0"] .ask-humour { display: none; }

/* ---- Mode 9: the Ask area sits above the numbers, so less space above and more below ---- */
#ask.ask-top { padding-block: 8px clamp(150px, 24vh, 240px); }
body:has(#ask.ask-top) .intro { min-height: 80svh; padding-block-end: 56px; }
body:has(#ask.ask-top) .scroll-cue { display: none; }

/* ---- Switching modes ---- */
.ask-x.is-switching { animation: ask-swap .5s var(--ease); }
@keyframes ask-swap { from { opacity: .2; translate: 0 8px; } }

/* ---- FAQ ("We're interested"), between #ask and #not-for-you ---- */
#faq .sec-head { justify-items: center; text-align: center; }
.faq-list { max-width: 860px; margin-inline: auto; display: grid; gap: 10px; }
.faq-q { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); transition: border-color .3s, background-color .3s; }
.faq-q:hover { border-color: color-mix(in srgb, var(--signal) 22%, var(--line)); }
.faq-q[open] { border-color: color-mix(in srgb, var(--signal) 38%, var(--line)); }
.faq-q summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; font-size: 1.02rem; font-weight: 500; color: var(--text); border-radius: 16px; }
.faq-q summary::-webkit-details-marker { display: none; }
.faq-q summary::after { content: ""; flex: none; width: 12px; height: 12px; color: var(--signal); background: linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat, linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat; transition: transform .3s var(--ease); }
.faq-q[open] summary::after { transform: rotate(45deg); }
.faq-q summary:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.faq-a { padding: 0 20px 18px; color: var(--text-2); line-height: 1.65; }
.faq-a p { margin: 0; max-width: 70ch; }
.faq-q[open] .faq-a { animation: faqIn .35s var(--ease); }
@keyframes faqIn { from { opacity: 0; transform: translateY(-4px); } }
.faq-bridge { margin: 48px 0 0; text-align: center; font-size: clamp(1.2rem, 2.6vw, 1.6rem); font-weight: 300; color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .ask-glow, .ask-x.is-switching, .ask-msg, .ask-typing i, .ask-happy i.pop, .faq-q[open] .faq-a { animation: none; }
  .ask-more, #ask .ask-more:not(.is-open), .faq-q summary::after { transition: none; }
}
