/* =========================================================
   CURRENTS@CMFRI — search, record, ask and curator pages
   Builds on the tokens and components in style.css
   ========================================================= */
:root { --ml: "Noto Sans Malayalam", var(--sans); }
body { font-family: var(--sans), var(--ml); }
mark { background: #fff1c9; color: inherit; padding: 0 1px; border-radius: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; gap: 6px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.icon-btn:hover { border-color: var(--ocean); color: var(--ocean); }
.only-mobile { display: none !important; }

/* AI marker */
.ai-mark { display: inline-flex; align-items: center; gap: 2px; font-size: .66rem; font-weight: 700; letter-spacing: .04em;
  color: #6b4bb3; background: #f1ecfb; border: 1px solid #e0d6f5; border-radius: 999px; padding: 0 6px 0 4px; vertical-align: 1px; cursor: help; white-space: nowrap; }
.ai-mark .ic { width: .9em; height: .9em; }

/* ---------- compact header search (record page) ---------- */
.header-search { flex: 1; max-width: 360px; display: flex; align-items: center; gap: 8px; background: #f2f5f8; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; margin: 0 16px; }
.header-search input { border: 0; background: transparent; font: inherit; flex: 1; min-width: 0; outline: none; }
.header-search:focus-within { border-color: var(--cmfri-blue); background: #fff; }

/* ---------- search hero ---------- */
.search-hero { background: linear-gradient(160deg, var(--navy) 0%, var(--ocean) 100%); padding: 22px 0 26px; }
.search-panel.compact { margin: 0; max-width: none; }
.search-panel.compact .search-row { position: relative; }
.tab .tcount { margin-left: 6px; font-size: .72rem; font-weight: 600; color: var(--muted); background: #eef2f5; border-radius: 999px; padding: 0 7px; }
.tab .tcount:empty { display: none; }
.tab.active .tcount { background: #cfe8f5; color: var(--ocean); }
.adv-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.chip.on { background: #e5f3fa; border-color: #b9dcee; color: var(--ocean); display: inline-flex; align-items: center; gap: 4px; }
.chip.on .ic { width: .85em; height: .85em; }

.suggest-list { position: absolute; left: 34px; right: 220px; top: calc(100% - 6px); z-index: 30; list-style: none; margin: 0; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; }
.suggest-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: .92rem; }
.suggest-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-list li small { color: var(--muted); font-size: .74rem; }
.suggest-list li.on, .suggest-list li:hover { background: #eef8fd; }
.suggest-list .ic { color: var(--teal); }

/* ---------- results layout ---------- */
.results-wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; padding-top: 24px; padding-bottom: 60px; }
.facets { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; padding-right: 4px; }
.facets-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.facets h2 { font-family: var(--serif); font-size: 1.15rem; }
.fsec { border-top: 1px solid var(--line); padding: 10px 0; }
.fsec summary { cursor: pointer; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); list-style: none; display: flex; justify-content: space-between; }
.fsec summary::after { content: "+"; font-weight: 400; }
.fsec[open] summary::after { content: "–"; }
.fsec ul { list-style: none; margin: 8px 0 0; padding: 0; }
.fbtn { width: 100%; display: flex; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: none; padding: 5px 8px; border-radius: 8px; font-size: .88rem; color: var(--ink); }
.fbtn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbtn b { font-weight: 500; color: var(--muted); font-size: .8rem; }
.fbtn:hover { background: #eef3f7; }
.fbtn.on { background: var(--navy); color: #fff; }
.fbtn.on b { color: #c6d4e1; }
.yhist { display: flex; align-items: flex-end; gap: 1px; height: 64px; margin-top: 10px; }
.ybar { flex: 1; min-width: 2px; height: var(--h); background: #9fc9df; border: 0; border-radius: 2px 2px 0 0; padding: 0; }
.ybar:hover { background: var(--teal); }
.ybar.on { background: var(--accent); }
.yaxis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: 4px; }

.results-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.rcount { font-size: .95rem; color: var(--muted); }
.rcount strong { color: var(--ink); font-size: 1.1rem; }
.rcount .ms { font-size: .75rem; opacity: .7; margin-left: 6px; }
.rtools { display: flex; align-items: center; gap: 10px; }
.sort { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.sort select { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }
.qchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qchip { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; border: 1px dashed #9cc7dc; background: #f3fafd; color: var(--ocean); padding: 3px 10px; border-radius: 999px; }
.qchip .ic { width: .95em; height: .95em; }
button.qchip:hover { border-style: solid; }
.qchip.tr { border-color: #d6c9f0; background: #f7f3fd; color: #5b3fa0; }
.dym { margin-bottom: 12px; font-size: .95rem; }
.dym a, .empty a { color: var(--ocean); font-weight: 600; text-decoration: underline; }

/* result card */
.rlist { display: grid; gap: 14px; }
.rcard { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; transition: box-shadow .2s, border-color .2s; }
.rcard:hover { box-shadow: var(--shadow-sm); border-color: #cfdbe4; }
.rthumb { position: relative; display: block; aspect-ratio: 3 / 4; background: #eef2f5; border-radius: 10px; overflow: hidden; }
.rthumb.sq { aspect-ratio: 1; }
.t-event .rthumb, .t-video .rthumb { aspect-ratio: 4 / 3; }
.rthumb img { width: 100%; height: 100%; object-fit: cover; }
.t-news .rthumb img { object-position: top; }
.rthumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #9fb2c1; }
.tlabel { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: .68rem; font-weight: 600; color: #fff; background: rgba(10, 34, 56, .78); padding: 2px 7px; border-radius: 6px; backdrop-filter: blur(4px); }
.rbody { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rbadges { display: flex; flex-wrap: wrap; gap: 6px; }
.rbadges:empty { display: none; }
.badge-s { font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef2f5; color: var(--muted); }
.b-tsunami { background: #fde8e4; color: #9c3a26; }
.b-seaweeds { background: #e3f4e8; color: #23733d; }
.b-protected { background: #fff3dc; color: #8a5a00; }
.b-lang { background: #e8f1fb; color: #2a5d8f; }
.match-sem { display: inline-flex; align-items: center; gap: 3px; font-size: .7rem; color: #6b4bb3; }
.rcard h3 { font-family: var(--serif); font-weight: 600; font-size: 1.12rem; line-height: 1.3; }
.rcard h3 a:hover { color: var(--ocean); text-decoration: underline; text-underline-offset: 3px; }
.common { font-size: .88rem; color: var(--teal); font-weight: 500; }
.rmeta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); }
.rmeta span { display: inline-flex; align-items: center; gap: 4px; }
.snip { font-size: .9rem; color: #33475a; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.snip .from { font-size: .75rem; font-weight: 600; color: var(--teal); }
.rchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip, .pchip { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: #fff; }
.tchip { background: #f0f8f5; border-color: #cfe7dd; color: #1f6b52; }
.tchip:hover, .pchip:hover { border-color: var(--ocean); color: var(--ocean); }
.pchip .ic { width: .9em; height: .9em; }
.also { font-size: .8rem; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.also a { color: var(--ocean); }
.rfb { display: flex; align-items: center; gap: 4px; font-size: .74rem; color: var(--muted); margin-top: auto; justify-content: flex-end; opacity: 0; transition: opacity .2s; }
.rcard:hover .rfb, .rfb:focus-within { opacity: 1; }
.rfb button { border: 0; background: none; color: var(--muted); padding: 3px; border-radius: 6px; }
.rfb button:hover { color: var(--ocean); background: #eef3f7; }
.rcard.compact { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 10px; }
.rcard.compact h3 { font-size: .95rem; }
.rcard.compact .rbadges, .rcard.compact .common { display: none; }

/* skeleton */
.rcard.skeleton .rthumb, .rcard.skeleton i { background: linear-gradient(90deg, #eef2f5 25%, #f7f9fb 50%, #eef2f5 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
.rcard.skeleton i { display: block; height: 14px; border-radius: 6px; margin: 4px 0; }
.rcard.skeleton i:first-child { width: 70%; height: 20px; }
.rcard.skeleton i:last-child { width: 45%; }
@keyframes sk { to { background-position: -200% 0; } }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty h3 { font-family: var(--serif); color: var(--ink); font-size: 1.3rem; }
.notice { background: #fff8e8; border: 1px solid #f3dfb0; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: .9rem; }

/* AI overview */
.overview { background: linear-gradient(135deg, #f7f3fd, #eef8fd); border: 1px solid #e0d6f5; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.ov-head { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: #5b3fa0; margin-bottom: 8px; flex-wrap: wrap; }
.ov-head span { color: var(--muted); font-size: .78rem; }
.ov-body { font-size: .95rem; line-height: 1.65; }
.ov-warn { font-size: .8rem; color: #8a5a00; margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.cite { color: var(--ocean); font-weight: 600; font-size: .8em; vertical-align: 1px; padding: 0 1px; }
.cite:hover { text-decoration: underline; }

.pager { display: flex; justify-content: center; gap: 6px; margin-top: 26px; flex-wrap: wrap; }
.pg { min-width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 10px; font-size: .9rem; }
.pg:hover { border-color: var(--ocean); color: var(--ocean); }
.pg.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.pager .gap { align-self: center; color: var(--muted); }

/* ---------- preview drawer ---------- */
.preview { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 92vw); z-index: 60; background: var(--paper); box-shadow: -10px 0 40px rgba(10, 34, 56, .18);
  display: flex; flex-direction: column; animation: slidein .22s ease-out; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.preview-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; }
.preview-body { overflow: auto; padding: 18px 20px 40px; }
.scrim { position: fixed; inset: 0; background: rgba(10, 34, 56, .35); z-index: 55; }
.loading { display: grid; place-items: center; padding: 60px; }

/* typing dots (also used by style.css chat) */
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- record ---------- */
.record-wrap { padding-top: 18px; padding-bottom: 60px; max-width: 980px; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a:hover { color: var(--ocean); text-decoration: underline; }
.record { display: grid; gap: 18px; }
.rtype { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
.rtitle { font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 600; line-height: 1.2; }
.record.compact .rtitle { font-size: 1.4rem; }
.rviewer { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.pdf-cover { display: block; position: relative; border-radius: 10px; overflow: hidden; background: #f4f1ea; max-height: 640px; }
.pdf-cover img { width: 100%; max-height: 640px; object-fit: contain; }
.pdf-cover span, .gzoom, .gcount { position: absolute; display: inline-flex; align-items: center; gap: 6px; background: rgba(10, 34, 56, .82); color: #fff; font-size: .8rem; padding: 6px 12px; border-radius: 999px; }
.pdf-cover span { right: 12px; bottom: 12px; }
.pdf-embed { margin-top: 10px; }
.pdf-embed summary { cursor: pointer; font-size: .85rem; color: var(--ocean); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.pdf-embed iframe { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.vactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gallery .gmain { position: relative; display: block; width: 100%; border: 0; padding: 0; background: #0a2238; border-radius: 10px; overflow: hidden; cursor: zoom-in; }
.gallery .gmain img { width: 100%; max-height: 560px; object-fit: contain; margin: 0 auto; }
.gallery.species .gmain { background: #f4f6f8; }
.gzoom { right: 12px; bottom: 12px; padding: 8px; }
.gcount { left: 12px; bottom: 12px; }
.gstrip { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.gthumb { flex: none; width: 92px; height: 68px; border: 2px solid transparent; border-radius: 8px; overflow: hidden; padding: 0; background: #eef2f5; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; }
.gthumb.on { border-color: var(--accent); }
.vplayer, .vwrap iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #000; }
.vwrap + .vwrap, .vplayer + .vplayer { margin-top: 10px; }
.vnote { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 30px 16px; color: var(--muted); }
.transcript-note { font-size: .82rem; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.rdesc { font-size: 1.02rem; line-height: 1.7; display: grid; gap: 10px; }
.rdesc .caption { font-size: .92rem; color: #33475a; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rmeta-table { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 0; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rmeta-table dt, .rmeta-table dd { padding: 10px 14px; border-bottom: 1px solid var(--line); margin: 0; font-size: .92rem; }
.rmeta-table dt { color: var(--muted); font-weight: 600; font-size: .8rem; background: #f8fafb; }
.rmeta-table dd { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rmeta-table dd a:not(.tchip):not(.pchip) { color: var(--ocean); }
.rmeta-table dt:nth-last-of-type(1), .rmeta-table dd:last-child { border-bottom: 0; }
.rsec h3 { font-family: var(--serif); font-size: 1.15rem; margin-bottom: 10px; }
.rsec > summary { cursor: pointer; font-weight: 600; display: inline-flex; gap: 8px; align-items: center; color: var(--ocean); }
details.rsec { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
details.rsec p { margin-top: 10px; font-size: .92rem; white-space: pre-line; }
details.rsec small { color: var(--muted); font-size: .75rem; }
.cite-text { font-family: Georgia, serif; background: #f8fafb; padding: 10px; border-radius: 8px; margin-bottom: 8px; }
.also-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.also-list a { color: var(--ocean); font-weight: 500; }
.also-list small { color: var(--muted); }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.record.compact .related { grid-template-columns: 1fr; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 16, 27, .94); display: grid; place-items: center; }
.lightbox figure { margin: 0; display: grid; gap: 10px; justify-items: center; max-width: 94vw; }
.lb-stage { max-width: 94vw; max-height: 82vh; overflow: hidden; cursor: zoom-in; }
.lb-stage img { max-width: 94vw; max-height: 82vh; object-fit: contain; transition: transform .25s; }
.lb-stage.zoom { cursor: zoom-out; }
.lb-stage.zoom img { transform: scale(2.4); }
.lightbox figcaption { color: #dfe8ef; font-size: .9rem; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lightbox figcaption a { color: var(--accent); display: inline-flex; gap: 4px; align-items: center; }
.lb-close, .lb-prev, .lb-next { position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255, 255, 255, .25); }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; } .lb-next { right: 16px; top: 50%; }

/* footer + toast */
.mini-footer { background: var(--navy); color: #c6d4e1; font-size: .8rem; padding: 18px 0; }
.mini-footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.mini-footer span { display: inline-flex; align-items: center; gap: 8px; }
.mini-footer img { border-radius: 4px; background: #fff; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 120; font-size: .9rem; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Ask page ---------- */
.ask-page { padding: 30px 0 60px; }
.ask-page .chat { max-width: 920px; margin: 0 auto; min-height: 60vh; }
.ask-page .chat-body { max-height: none; min-height: 40vh; }
.msg.bot .check { font-size: .78rem; margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.msg.bot .check.ok { color: #23733d; }
.msg.bot .check.warn { color: #8a5a00; }
.msg.bot p + p { margin-top: 8px; }
.msg.bot .refusal { color: #5a6b79; font-style: italic; }
.ask-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.ask-filters select { font: inherit; font-size: .8rem; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: #fff; padding: 4px 8px; }
.ask-filters select option { color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .results-wrap { grid-template-columns: 1fr; }
  .facets { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); max-height: none; z-index: 60; background: var(--paper); padding: 16px; transform: translateX(-105%); transition: transform .25s; box-shadow: var(--shadow); top: 0; }
  .facets.open { transform: none; }
  .only-mobile { display: inline-flex !important; }
  .suggest-list { right: 0; left: 0; }
  .header-search { display: none; }
}
@media (max-width: 640px) {
  .rcard { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 10px; }
  .rcard h3 { font-size: 1rem; }
  .snip { -webkit-line-clamp: 2; }
  .results-head { flex-direction: column; }
  .rmeta-table { grid-template-columns: 1fr; }
  .rmeta-table dt { border-bottom: 0; padding-bottom: 2px; background: none; }
  .search-hero .mode-pill { display: none; }
  .rfb { opacity: 1; }
}
.preview[hidden], .scrim[hidden], .suggest-list[hidden], .overview[hidden], .notice[hidden] { display: none; }
.ractions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: -6px; }
.topbar-right .curator-link + .curator-link { margin-left: 4px; }
/* mobile overflow fixes */
.results { min-width: 0; }
.rtools { flex-wrap: wrap; }
@media (max-width: 980px) { .results-wrap { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .rtools { width: 100%; }
  .rtools .sort { margin-left: auto; }
  #saveSearch { font-size: 0; gap: 0; padding: 6px 9px; }
  #saveSearch .ic { font-size: 1rem; }
  .rcard h3 { overflow-wrap: anywhere; }
  .tlabel { font-size: .6rem; padding: 1px 5px; }
  .search-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
}
.msg.bot .sources { max-height: 340px; overflow-y: auto; }
