/* Search window (core/search_window.html, static/js/search-window.js) and the understood
 * request on search pages (core/_search_understanding.html); documentation 06, Search Window.
 * Desktops: a centred panel. Phones (up to 768 px): a bottom sheet whose top and height follow
 * the visible viewport (--sw-top / --sw-height, set by the script), 44 px touch targets and a
 * 16 px input so the browser does not zoom. The monkey (core/_search_monkey.html) is drawn and
 * animated by static/css/makakita-search.css; here it only gets its place: 96 px wide, height
 * from the viewBox, so no generic svg rule can shrink it. */

.sw-root { position: fixed; inset: 0; z-index: 60; }
.sw-root[hidden] { display: none; }
.sw-backdrop { position: absolute; inset: 0; background: rgb(2 44 34 / .35); }
.sw-panel { position: absolute; left: 50%; top: 6vh; transform: translateX(-50%); display: flex; flex-direction: column; width: min(680px, calc(100vw - 32px)); max-height: 88vh; max-height: 88dvh; background: #fff; border: 1px solid rgb(2 44 34 / .15); border-radius: 16px; box-shadow: 0 25px 50px -12px rgb(0 0 0 / .3); overflow: hidden; color: #10231c; }
.sw-panel:focus { outline: none; }
.sw-header { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; background: #fffcf5; border-bottom: 1px solid rgb(2 44 34 / .1); }
.sw-title { flex: 1; margin: 0; font-size: 16px; font-weight: 700; }
.sw-new { min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 600; color: #145447; }
.sw-new:hover { background: rgb(6 78 59 / .08); }
.sw-close { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; line-height: 1; color: rgb(6 78 59 / .7); }
.sw-close:hover { background: rgb(6 78 59 / .1); color: #022c22; }
.sw-new:focus-visible, .sw-close:focus-visible, .sw-option:focus-visible, .sw-chip:focus-visible, .sw-retry:focus-visible { outline: 2px solid #065f46; outline-offset: 2px; }
.sw-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 16px; }

.sw-stage { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.sw-stage .mk-search-monkey { flex: none; width: 96px; max-width: none; height: auto; aspect-ratio: 280 / 256; }
.sw-status { margin: 0; font-size: 15px; font-weight: 600; }

.sw-understood, .search-understood-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 14px; }
.sw-understood-label, .search-understood-label { color: #4c6158; font-weight: 600; }
.sw-chip, .search-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 10px; border-radius: 100px; background: #eef5ef; border: 1px solid #d7e3d3; color: #145447; font-size: 13px; font-weight: 600; text-decoration: none; }
.sw-chip-subject, .search-chip-subject { background: #145447; border-color: #145447; color: #fff; }
button.sw-chip:hover, a.search-chip:hover { background: #e1eee3; }

.sw-question, .search-question { margin: 14px 0 0; padding: 12px; border-radius: 12px; background: #fffcf5; border: 1px solid #efe3c8; }
.sw-question-text, .search-question-text { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.sw-options, .search-question-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.sw-option, .search-option { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid #145447; color: #145447; background: #fff; font-size: 14px; font-weight: 600; text-decoration: none; }
.sw-option:hover, .search-option:hover { background: #145447; color: #fff; }
.sw-option:disabled { opacity: .5; cursor: wait; }
.sw-answer { display: flex; gap: 8px; margin-top: 10px; }
.sw-answer[hidden] { display: none; }
.sw-answer input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid #d4d4d4; border-radius: 12px; }

.sw-notes { margin-top: 10px; }
.sw-note { margin: 6px 0 0; font-size: 13px; color: #6b5a2e; }
.sw-section { margin-top: 16px; }
.sw-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.sw-section-title { margin: 0; font-size: 14px; font-weight: 700; }
.sw-section-more { font-size: 13px; font-weight: 600; color: #145447; }
.sw-section-extra .sw-section-title { color: #6b5a2e; }
.sw-cards { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sw-card { display: block; padding: 10px 12px; border-radius: 12px; border: 1px solid #e3e9e4; color: inherit; text-decoration: none; }
.sw-card:hover { border-color: #145447; }
.sw-card-kind { display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6c7d74; }
.sw-card-title { display: block; margin-top: 2px; font-size: 15px; font-weight: 650; }
.sw-card-meta { display: block; margin-top: 2px; font-size: 13px; color: #4c6158; }
.sw-card-price { font-weight: 700; color: #10231c; }
.sw-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sw-retry, .sw-see-all { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 12px; background: #145447; color: #fff; font-size: 14px; font-weight: 650; text-decoration: none; }
.sw-retry[hidden], .sw-see-all[hidden] { display: none; }

.sw-form { flex: none; display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e5e5e5; background: #fff; }
.sw-input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; font-size: 16px; border: 1px solid #d4d4d4; border-radius: 12px; }
.sw-input:focus { outline: none; border-color: #145447; box-shadow: 0 0 0 1px #145447; }
.sw-send { flex: none; min-height: 44px; padding: 0 16px; border-radius: 12px; background: #171717; color: #fff; font-weight: 650; }
.sw-send:disabled, .sw-input:disabled { opacity: .5; cursor: wait; }

.search-understood { margin: 0 0 16px; }

html.sw-open, html.sw-open body { overflow: hidden; }

@media (max-width: 768px) {
  .sw-panel { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: var(--sw-height, 92vh); border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sw-body { padding: 10px 12px 12px; }
}

/* A segment that moves along a track while the answer is awaited: no percentage, because the time of
   the reading is not known. */
.sw-progress { position: relative; flex: 1 1 100%; height: 4px; margin-top: 4px; border-radius: 2px; background: rgb(20 84 71 / .12); overflow: hidden; opacity: 0; transition: opacity .15s; }
.sw-stage { flex-wrap: wrap; }
.sw-stage[data-state="searching"] .sw-progress, .sw-stage[data-state="resuming"] .sw-progress { opacity: 1; }
.sw-segment { position: absolute; top: 0; bottom: 0; left: 0; width: 34%; border-radius: 2px; background: #145447; animation: sw-slide 1.3s ease-in-out infinite; }
@keyframes sw-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .sw-segment { animation: none; transform: translateX(95%); } }

.sw-examples-title { margin: 14px 0 8px; font-size: 14px; color: #55645f; }
.sw-example { height: auto; padding-top: 8px; padding-bottom: 8px; line-height: 1.3; text-align: left; }
