/* Kalpasar Department website: widgets. GIL chatbot service panel, voice-search dialog, accessible captcha, search results
   and advanced search. Colours come only from tokens.css, so every rule holds in light, dark and high contrast and follows the
   shape language (radius, border width) of the active option. */

/* ---- Shared: question chips used as buttons ---- */
.chip-ask { cursor: pointer; background: var(--color-card); color: var(--color-primary-text); border: 1px solid var(--color-primary-text); font: inherit; font-size: 0.86em; font-weight: 600; padding: 0.3em 0.8em; min-height: 32px; display: inline-flex; align-items: center; gap: 0.35em; text-decoration: none; }
.chip-ask:hover { background: var(--color-surface-alt); color: var(--color-primary-text); }
.chip-ask svg { width: 1em; height: 1em; flex: none; }

/* ---- Chatbot launcher ---- */
.kal-chat { position: fixed; right: 16px; bottom: 16px; z-index: 60; font-size: calc(16px * var(--font-scale)); }
.chat-launch { display: inline-flex; align-items: center; gap: 0.6em; min-height: 52px; padding: 0.45em 1.1em 0.45em 0.8em; border: 2px solid var(--color-on-primary); border-radius: 999px;
  background: var(--color-primary); color: var(--color-on-primary); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); cursor: pointer; font: inherit; text-align: left; }
.chat-launch > svg { width: 1.6em; height: 1.6em; flex: none; }
.chat-launch .cl-text { display: flex; flex-direction: column; line-height: 1.2; }
.chat-launch strong { font-size: 0.98em; }
.chat-launch small { font-size: 0.74em; opacity: 0.95; }
.chat-launch:hover { background: var(--color-link-hover); }
.chat-launch:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
[data-design="khambhat"] .chat-launch { border-radius: var(--radius-md); }
[data-design="bhadbhut"] .chat-launch { border-radius: var(--radius-sm); }
.kal-chat.is-open .chat-launch { display: none; }
/* Round 6 (14-10-2026): from tablet to large desktop the launcher is a compact icon centred in the margin beside the page column
   (--cl-g is the margin from the screen edge to the column), so it never covers a service tile, card or caption; its name
   'Ask the Department, GIL chatbot service' stays in the button for screen readers and shows on hover and keyboard focus.
   Wider screens, where the margin holds the full label, keep the labelled button. */
@media (min-width: 761px) and (max-width: 1799px) {
  .kal-chat { --cl-g: calc((100vw - var(--max-w, 1200px)) / 2 + var(--gap, 16px)); --cl-s: clamp(40px, calc(var(--cl-g) - 12px), 56px);
    right: max(0px, calc((var(--cl-g) - var(--cl-s)) / 2)); bottom: 20px; }
  .chat-launch { width: var(--cl-s); height: var(--cl-s); min-height: 0; padding: 0; gap: 0; justify-content: center; }
  .chat-launch .cl-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .chat-launch:hover, .chat-launch:focus-visible { width: auto; height: auto; min-height: 52px; padding: 0.45em 1.1em 0.45em 0.8em; gap: 0.6em; justify-content: flex-start; }
  .chat-launch:hover .cl-text, .chat-launch:focus-visible .cl-text { position: static; width: auto; height: auto; clip: auto; overflow: visible; white-space: normal; }
}
/* The wide template keeps a narrow margin up to 1400 px: there the icon becomes a tab on the screen edge, clear of the column. */
@media (min-width: 761px) and (max-width: 1399px) {
  [data-design="bhadbhut"] .kal-chat { right: 0; }
  [data-design="bhadbhut"] .chat-launch { width: 38px; height: 60px; border-right-width: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
  [data-design="bhadbhut"] .chat-launch:hover, [data-design="bhadbhut"] .chat-launch:focus-visible { width: auto; height: auto; border-right-width: 2px; }
}

/* ---- Chatbot panel ---- */
.chat-panel { position: fixed; right: 16px; bottom: 16px; width: min(410px, calc(100vw - 24px)); height: min(640px, calc(100vh - 32px)); display: flex; flex-direction: column;
  background: var(--color-card); color: var(--color-text); border: var(--border-w) solid var(--color-border-ui); border-radius: var(--radius-lg); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3); overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6em; padding: 0.7em 0.9em; background: var(--color-header-bg); color: var(--color-header-text); }
.chat-head h2 { margin: 0; font-size: 1.08em; line-height: 1.3; color: var(--color-header-text); }
.chat-sub { margin: 0.1em 0 0; font-size: 0.8em; color: var(--color-header-muted); }
.chat-x { background: transparent; border: 1px solid transparent; color: var(--color-header-text); min-width: 40px; min-height: 40px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.chat-x:hover { border-color: var(--color-header-text); }
.chat-head :focus-visible { outline: 3px solid var(--color-focus-header); outline-offset: 1px; }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5em; padding: 0.45em 0.7em; border-bottom: 1px solid var(--color-border-soft); flex-wrap: wrap; }
.chat-langs { display: inline-flex; border: 1px solid var(--color-border-ui); border-radius: 999px; overflow: hidden; }
.chat-langs button { font: inherit; font-size: 0.82em; border: 0; background: transparent; color: var(--color-text); padding: 0.25em 0.75em; min-height: 32px; cursor: pointer; }
.chat-langs button[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); font-weight: 700; }
.chat-reset { font: inherit; font-size: 0.82em; background: transparent; border: 0; color: var(--color-link); text-decoration: underline; cursor: pointer; min-height: 32px; }
.chat-log { flex: 1 1 auto; overflow-y: auto; padding: 0.8em; background: var(--color-surface-alt); display: flex; flex-direction: column; gap: 0.7em; }
.chat-log:focus-visible { outline: 3px solid var(--color-focus); outline-offset: -3px; }
.msg { max-width: 92%; }
.msg p { margin: 0 0 0.4em; line-height: 1.5; }
.msg-bot { align-self: flex-start; background: var(--color-card); border: 1px solid var(--color-border-soft); border-radius: var(--radius-md); padding: 0.6em 0.75em; }
.msg-user { align-self: flex-end; background: var(--color-primary); color: var(--color-on-primary); border-radius: var(--radius-md); padding: 0.45em 0.75em; }
.msg-user p { margin: 0; }
.msg-voice svg { width: 0.95em; height: 0.95em; vertical-align: -0.12em; }
.msg-note { color: var(--color-text-muted); font-size: 0.82em; }
.msg-links { list-style: none; margin: 0.3em 0; padding: 0; display: flex; flex-direction: column; gap: 0.2em; }
.msg-links a { color: var(--color-link); font-weight: 600; text-decoration: underline; display: inline-flex; align-items: center; gap: 0.3em; min-height: 28px; }
.msg-links a svg { width: 0.9em; height: 0.9em; flex: none; }
.msg-tools { display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
.msg-tts { font: inherit; font-size: 0.8em; display: inline-flex; align-items: center; gap: 0.3em; background: transparent; color: var(--color-link); border: 1px solid var(--color-border-ui); border-radius: 999px; padding: 0.15em 0.65em; min-height: 28px; cursor: pointer; }
.msg-tts svg { width: 0.9em; height: 0.9em; }
.msg-tts[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.msg-opts { display: flex; flex-wrap: wrap; gap: 0.35em; margin-top: 0.45em; }
.chat-voice { padding: 0.5em 0.8em; border-top: 1px solid var(--color-border-soft); background: var(--color-card); }
.chat-voice p { margin: 0 0 0.35em; }
.chat-input { display: flex; gap: 0.35em; padding: 0.55em 0.6em; border-top: 1px solid var(--color-border-soft); background: var(--color-card); }
.chat-input input { flex: 1; min-width: 0; min-height: 44px; padding: 0.4em 0.65em; font: inherit; border: var(--border-w) solid var(--color-border-ui); border-radius: var(--radius-sm); background: var(--color-card); color: var(--color-text); }
.chat-input button { min-width: 44px; min-height: 44px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.chat-mic { background: transparent; color: var(--color-primary-text); border: var(--border-w) solid var(--color-border-ui); }
.chat-mic[aria-pressed="true"] { background: var(--color-accent); color: var(--color-on-accent); border-color: var(--color-accent); }
.chat-send { background: var(--color-primary); color: var(--color-on-primary); border: var(--border-w) solid var(--color-primary); }
.chat-foot { margin: 0; padding: 0.45em 0.8em 0.6em; font-size: 0.74em; line-height: 1.45; color: var(--color-text-muted); background: var(--color-card); }
@media (max-width: 600px) {
  .kal-chat { right: 10px; bottom: 10px; }
  .chat-launch small { display: none; }
  .chat-launch { min-height: 48px; padding: 0.35em 0.9em 0.35em 0.7em; }
  .chat-panel { right: 0; bottom: 0; width: 100vw; height: min(88vh, 100dvh); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ---- Voice search dialog ---- */
.voice-dlg { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.vd-box { width: min(460px, 100%); background: var(--color-card); color: var(--color-text); border: var(--border-w) solid var(--color-border-ui); border-radius: var(--radius-lg); padding: 1em 1.1em 1.1em; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35); text-align: center; }
.vd-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5em; text-align: left; }
.vd-top h2 { margin: 0; display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
.vd-close { background: transparent; border: 1px solid var(--color-border-ui); color: var(--color-text); min-width: 40px; min-height: 40px; border-radius: var(--radius-sm); cursor: pointer; }
.vd-mic { width: 84px; height: 84px; margin: 0.8em auto 0.4em; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--color-primary); color: var(--color-on-primary); }
.vd-mic svg { width: 40px; height: 40px; }
.voice-dlg.is-listening .vd-mic, .chat-mic.is-listening { animation: kal-pulse 1.4s ease-in-out infinite; }
@keyframes kal-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--color-accent); } 50% { box-shadow: 0 0 0 10px transparent; } }
.vd-status { font-weight: 600; margin: 0.3em 0; }
.vd-said { min-height: 1.6em; font-size: 1.15em; color: var(--color-primary-text); margin: 0.2em 0 0.6em; }
.vd-lab { font-size: 0.88em; color: var(--color-text-muted); margin: 0.4em 0 0.3em; }
.vd-phrases { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4em; margin-bottom: 0.6em; }
@media (prefers-reduced-motion: reduce) { .voice-dlg.is-listening .vd-mic, .chat-mic.is-listening { animation: none; outline: 3px solid var(--color-accent); } }

/* ---- Accessible captcha ---- */
.kal-captcha { border: var(--border-w) solid var(--color-border-soft); border-radius: var(--radius-md); padding: 0.7em 0.9em 0.8em; margin: 0 0 1em; min-width: 0; }
.kal-captcha legend { font-weight: 600; padding: 0 0.3em; }
.cap-modes { display: flex; flex-wrap: wrap; gap: 0.4em; margin-bottom: 0.6em; }
.cap-mode { display: inline-flex; align-items: center; gap: 0.35em; border: 1px solid var(--color-border-ui); border-radius: 999px; padding: 0.2em 0.8em 0.2em 0.55em; min-height: 36px; cursor: pointer; font-weight: 600; font-size: 0.9em; }
.cap-mode:has(input:checked) { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.captcha .cap-mode input { width: 1.1em; height: 1.1em; min-height: 0; margin: 0; letter-spacing: normal; accent-color: var(--color-accent); }
.cap-stage { min-height: 52px; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5em; margin-bottom: 0.4em; }
.cap-question { font-size: 1.15em; font-weight: 700; margin: 0; }
.kal-captcha > label { display: block; font-weight: 600; margin-bottom: 0.3em; }
.kal-captcha .cap-row { display: flex; flex-wrap: wrap; gap: 0.5em; align-items: center; }
.kal-captcha .cap-row input { flex: 0 1 12em; min-height: 44px; padding: 0.45em 0.65em; border: var(--border-w) solid var(--color-border-ui); border-radius: var(--radius-sm); background: var(--color-card); color: var(--color-text); font: inherit; text-transform: none; letter-spacing: normal; }
.kal-captcha .cap-row input.cap-code { text-transform: uppercase; letter-spacing: 0.2em; font-family: var(--font-mono); }
.kal-captcha .hint, .kal-captcha .error { display: block; margin-top: 0.3em; }

/* ---- Search results ---- */
.search-help p { margin: 0.35em 0; }
.search-help .chip { text-decoration: none; }
.understood h2 { display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
.u-chips { display: flex; flex-wrap: wrap; gap: 0.35em; }
.search-also .chip, .u-chips .chip { font-weight: 600; }
.note-partial { border-left: 4px solid var(--color-accent); padding: 0.3em 0.7em; background: var(--color-surface-alt); }
.kind-tabs .n { display: inline-block; min-width: 1.6em; margin-left: 0.35em; padding: 0 0.4em; border-radius: 999px; background: var(--color-surface-alt); color: var(--color-text); font-size: 0.85em; text-align: center; }
.kind-tabs .chip.is-on { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.kind-tabs .chip.is-on .n { background: var(--color-on-primary); color: var(--color-primary); }
.search-refine { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.3em 1em; margin: 0.6em 0 0.4em; }
.search-refine .field { margin-bottom: 0; min-width: 11em; }
.search-refine .actions { margin: 0; display: flex; gap: 0.5em; align-items: center; }
.search-results { list-style-position: outside; }
.search-results li { padding: 0.7em 0; }
.search-results .r-head { margin: 0; font-size: 1.05em; font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.45em; }
.search-results .r-meta { margin: 0.15em 0 0; display: flex; flex-wrap: wrap; gap: 0.4em; align-items: center; }
.search-results .r-meta .mono { font-family: var(--font-mono); font-size: 0.92em; overflow-wrap: anywhere; }
.search-results .r-meta svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.search-results .snippet { margin: 0.3em 0 0; color: var(--color-text); max-width: 72ch; }
.search-results .in-doc { font-weight: 700; color: var(--color-secondary-text); }
.search-results mark, .snippet mark { background: var(--color-accent); color: var(--color-on-accent); padding: 0 0.1em; border-radius: 2px; }

/* ---- Advanced search ---- */
.adv-search fieldset { border: var(--border-w) solid var(--color-border-soft); border-radius: var(--radius-md); padding: 0.6em 0.9em 0.3em; margin: 0 0 1em; min-width: 0; }
.adv-search legend { font-weight: 700; padding: 0 0.3em; }
.adv-grid { display: grid; gap: 0 1em; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12em), 1fr)); }
.adv-search .check { display: flex; align-items: flex-start; gap: 0.5em; margin: 0.4em 0 0.7em; }
.adv-search .check input { width: 1.2em; height: 1.2em; margin-top: 0.2em; flex: none; accent-color: var(--color-primary); }
.adv-search { max-width: 760px; }

/* ---- High contrast and print ---- */
[data-theme="hc"] .chat-launch, [data-theme="hc"] .chat-panel, [data-theme="hc"] .vd-box { box-shadow: none; }
[data-theme="hc"] .chat-launch { border-color: var(--color-on-primary); outline: 2px solid var(--color-text); }
@media print { .kal-chat, .voice-dlg { display: none !important; } }

/* Option 3 sets chips in a monospace face; question chips carry Gujarati and Hindi, so they keep the text face. */
[data-design="bhadbhut"] .kal-chat .chip, [data-design="bhadbhut"] .chip.chip-ask, [data-design="bhadbhut"] .search-page .chip, [data-design="bhadbhut"] .voice-dlg .chip { font-family: inherit; font-size: 0.86em; letter-spacing: normal; }

/* Search: a match inside a file keeps its "Open the file at page" link on one line (13-10-2026). */
.snippet-file .file-at { white-space: nowrap; }
