/* Search page styles (static/index.html).
   Shared badges/dots/chips rules are also used by node.html once that page
   is ported to the same structure; keep page-specific rules here meanwhile. */

/* Hide the whole page until Vue has compiled the inline template, otherwise
   the v-for/v-model markup renders literally for a frame. */
[v-cloak] { display: none; }

:root {
      /* Look: science / climate publication (Our World in Data, Carbon
         Brief, Copernicus) rather than a tech product: warm paper
         background, ink text, one dark-green accent, serif headings on a
         plain sans body, muted earth-and-ocean hues for the categories.
         node.css repeats these tokens: keep the two in sync. */
      --serif: "Source Serif 4", "Source Serif Pro", Charter, "Bitstream Charter", Cambria, Georgia, serif;
      --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
      --ink: #1f2e25;
      --ink-2: #37483d;
      --muted: #5b6a60;
      --faint: #8e9a91;
      --accent: #2f5e3f;
      --accent-dark: #234a30;
      --accent-tint: #e6efe8;
      --bg: #f8f8f3;
      --surface: #fff;
      --sand: #eff0e6;
      --border: #d6dbd2;
      --card-border: #e1e5dc;
      --danger: #a63d2f;
      --oi: #2f5e3f;
      --rec: #2f6f95;
      --gap: #b5651d;
      --prj: #a23e6b;
      /* FormalType badge colors (Doc Type filter entries) */
      --paper: #a2412f;
      --model: #1f7a78;
      --plan: #4a52a0;
      --law: #6a4c93;
      --dataset: #86691a;
      /* Purpose tier: muted mid-tones, softer than the type colours. */
      --pv-val: #5b84b1;   /* Valutazione      - blue    */
      --pv-mon: #5f9468;   /* Monitoraggio     - green   */
      --pv-ric: #c9a046;   /* Ricostruzione    - ochre   */
      --pv-pre: #8b6fae;   /* Previsione       - violet  */
      --pv-sup: #4b98a5;   /* Supporto         - cyan    */
      --pv-gov: #84918f;   /* Governance       - slate   */
      --pv-gap: #cd8248;   /* Gap conoscenza   - orange  */
      /* Taxonomy tier: A5 Phenomenon, B3 Topic, C8a2 Geographic area */
      --tx-phen: #7484b4;  /* Phenomena        - indigo  */
      --tx-topic: #9580b4; /* Topic            - purple  */
      --tx-geo: #5aa196;   /* Geographic area  - teal    */
    }
    * { box-sizing: border-box; }
    html, body { height: 100%; }
    body {
      margin: 0;
      font-family: var(--sans);
      background: var(--bg);
      color: var(--ink);
      display: flex;
      flex-direction: column;
      align-items: center;
      height: 100vh;
      overflow: hidden;
      padding: 0 16px;
    }
    .container {
      display: flex; flex-direction: column;
      width: 100%; max-width: 1000px; height: 100%;
      margin: 0 auto;
    }
    .logo { text-align: center; font-family: var(--serif); font-size: 30px; letter-spacing: -.3px; margin: 18px 0 14px; font-weight: 400; color: var(--ink); flex: 0 0 auto; }
    .logo b { color: var(--accent); font-weight: 600; }
    .logo .tag { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--gap); margin-left: 6px; }
    /* Mode switcher: a pill row between the logo and the search bar. The track
       is light gray, the selected tab a white "chip" with a soft shadow — the
       same interaction as DeepL's switcher, in this page's palette.
       flex: 0 0 auto is deliberate: a scroll container has an automatic
       minimum size of 0, so without it this row is the element that gets
       squashed when the column above/below runs out of room. */
    .mode-tabs {
      display: flex; justify-content: center; align-items: center; gap: 4px;
      flex: 0 0 auto;
      position: relative;
      width: fit-content; max-width: 100%; margin: -4px auto 0;
      padding: 4px; background: var(--sand); border: 1px solid var(--card-border);
      border-radius: 999px; overflow-x: auto; scrollbar-width: none;
    }
    .mode-tabs::-webkit-scrollbar { display: none; }
    .mode-tabs .mode-tab {
      position: relative; z-index: 1;   /* above the sliding .mode-indicator */
      appearance: none; -webkit-appearance: none;
      border: 0; background: transparent; cursor: pointer;
      font: inherit; font-size: 13px; font-weight: 600; line-height: 1.3;
      color: var(--muted); padding: 7px 14px; border-radius: 999px;
      white-space: nowrap; transition: background-color .15s, color .15s, box-shadow .15s;
    }
    .mode-tabs .mode-tab:hover { color: var(--ink); }
    .mode-tabs .mode-tab[aria-selected='true'] { color: var(--accent); }
    /* The white "chip" behind the selected tab is ONE element that slides
       (transform + width) from tab to tab; search-page.js positions it. */
    .mode-indicator {
      position: absolute; top: 4px; bottom: 4px; left: 0; width: 0;
      background: var(--surface); border-radius: 999px;
      box-shadow: 0 1px 2px rgba(31, 46, 37, .18);
      pointer-events: none;
    }
    .mode-indicator.ready { transition: transform .28s cubic-bezier(.4, 0, .2, 1), width .28s cubic-bezier(.4, 0, .2, 1); }
    .mode-tag {
      font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
      color: var(--gap); margin-left: 3px; vertical-align: super; line-height: 0;
    }
    /* One line under the tabs saying what the selected mode searches. */
    .mode-hint {
      flex: 0 0 auto; margin: 7px 0 12px; min-height: 1.4em;
      text-align: center; font-size: 13px; font-style: italic; color: var(--muted);
    }
    /* :key="mode" re-creates the span on every switch, which replays this. */
    .hint-text { display: inline-block; animation: hint-in .22s ease both; }
    @keyframes hint-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
    @media (prefers-reduced-motion: reduce) {
      .mode-indicator.ready { transition: none; }
      .hint-text { animation: none; }
    }
    .mode-tabs .mode-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
    .searchbar {
      display: flex; align-items: center; gap: 8px;
      background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
      padding: 8px 8px 8px 20px; box-shadow: 0 1px 2px rgba(31, 46, 37, .05);
      transition: box-shadow .2s, border-color .2s;
    }
    .searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
    .searchbar input {
      flex: 1; border: none; outline: none; font: inherit; font-size: 17px; color: var(--ink);
      background: transparent; min-width: 0;
    }
    .searchbar input::placeholder { color: var(--faint); }
    .searchbar svg { fill: var(--accent); flex-shrink: 0; }
    .btn {
      border: none; border-radius: 999px; padding: 10px 22px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    }
    .btn-primary { background: var(--accent); color: #fff; }
    .btn-primary:hover { background: var(--accent-dark); }
    .btn-primary:disabled { background: color-mix(in srgb, var(--accent) 40%, #fff); cursor: default; }
    /* flex-basis 0, not auto: the columns' CONTENT height must not take part
       in sizing this row. With basis auto a tall result list makes the row's
       hypothetical height exceed the viewport, flex shrink kicks in and
       squeezes the siblings (first of all the mode tab row) — the two columns
       scroll internally instead, which is what the overflow rules below do. */
    .layout { flex: 1 1 0; min-height: 0; display: flex; gap: 28px; margin-top: 24px; padding: 0 0 16px; }
    .col-filters { flex: 0 0 24%; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
    .col-results { flex: 1 1 auto; min-width: 0; overflow-y: auto; }
    .panel-title { margin: 0 2px 4px; font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); }
    .section-title { margin: 0 0 4px; font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink); }
    .small-title { font-size: 12px;}
    .filter-panel {
      padding: 12px 14px 6px; background: var(--surface); border: 1px solid var(--card-border); border-radius: 8px;
    }
    .filter-group { border-top: 1px solid var(--card-border); }
    .filter-group summary {
      list-style: none; cursor: pointer; user-select: none;
      font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; font-weight: 600;
      padding: 10px 0; display: flex; justify-content: space-between; align-items: center;
    }
    .filter-group summary::-webkit-details-marker { display: none; }
    .filter-group summary::after { content: "\25B6"; font-size: 10px; transition: transform .2s; }
    .filter-group[open] summary::after { transform: rotate(90deg); }
    .group-body { padding: 2px 0 12px; }
    /* Internal-only groups (Advanced parameters): greyed out. */
    .filter-group.internal summary { color: var(--faint); font-weight: 500; }
    .filter-group.internal .group-body { opacity: .7; }
    .adv-body label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
    .adv-body input { margin-top: 4px; width: 110px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); }
    .actor-input { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); }
    .adv-body input:focus, .actor-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
    .actor-input::placeholder { color: var(--faint); }
    .actor-list { max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; margin-top: 8px; }
    .actor-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
    .actor-item:hover { background: var(--sand); }
    .actor-item input { accent-color: var(--accent); cursor: pointer; }
    .actor-empty { padding: 8px 10px; font-size: 13px; color: var(--muted); }
    .actor-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
    .chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-tint); color: var(--accent-dark); border: 1px solid color-mix(in srgb, var(--accent) 25%, #fff); font-size: 12px; padding: 2px 8px; border-radius: 999px; }
    .chip button { background: none; border: none; cursor: pointer; color: var(--accent-dark); font-size: 13px; line-height: 1; padding: 0; }
    .chk {
      display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer;
      padding: 7px 0; color: var(--ink);
    }
    .chk input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
    /* Two-line filter label: category + smaller description line */
    .chk-text { display: flex; flex-direction: column; line-height: 1.3; }
    .chk-desc { font-size: 11.5px; font-weight: 400; color: var(--muted); }
    /* Time filter: two overlaid range inputs share one track. The inputs are
       click-through (pointer-events: none) except their thumbs; z-index
       swaps which bound sits on top so the near thumb stays reachable. */
    .year-readout { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
    .range-slider { position: relative; height: 22px; margin: 4px 7px 6px; }
    .range-track, .range-fill { position: absolute; top: 50%; transform: translateY(-50%); height: 4px; border-radius: 2px; }
    .range-track { left: 0; right: 0; background: var(--border); }
    .range-fill { background: var(--accent); }
    .range-input {
      position: absolute; inset: 0; width: 100%; height: 22px; margin: 0;
      background: transparent; pointer-events: none; -webkit-appearance: none; appearance: none;
    }
    .range-input::-webkit-slider-runnable-track { height: 4px; background: transparent; }
    .range-input::-webkit-slider-thumb {
      -webkit-appearance: none; pointer-events: auto; cursor: pointer;
      width: 15px; height: 15px; margin-top: -5.5px; border-radius: 50%; box-sizing: border-box;
      background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(31,46,37,.3);
    }
    .range-input::-moz-range-track { height: 4px; background: transparent; }
    .range-input::-moz-range-thumb {
      pointer-events: auto; cursor: pointer;
      width: 15px; height: 15px; border-radius: 50%; box-sizing: border-box;
      background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(31,46,37,.3);
    }
    .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
    .dot.oi { background: var(--oi); }
    .dot.rec { background: var(--rec); }
    .dot.gap { background: var(--gap); }
    .dot.prj { background: var(--prj); }
    .dot.paper { background: var(--paper); }
    .dot.model { background: var(--model); }
    .dot.plan { background: var(--plan); }
    .dot.law { background: var(--law); }
    .dot.dataset { background: var(--dataset); }
    .dot.pv-val { background: var(--pv-val); }
    .dot.pv-mon { background: var(--pv-mon); }
    .dot.pv-ric { background: var(--pv-ric); }
    .dot.pv-pre { background: var(--pv-pre); }
    .dot.pv-sup { background: var(--pv-sup); }
    .dot.pv-gov { background: var(--pv-gov); }
    .dot.pv-gap { background: var(--pv-gap); }
    /* Taxonomy facet tiers: A5 Phenomenon, B3 Topic, C8a2 Geographic area.
       Same muted mid-tone register as the purpose tier. */
    .dot.tx-phen { background: var(--tx-phen); }
    .dot.tx-topic { background: var(--tx-topic); }
    .dot.tx-geo { background: var(--tx-geo); }
    /* Search summary, shown under the Filters card in the left column:
       one fact per line. The separator belongs to the title so the whole
       block (title + lines + footer) reads as one section. */
    .col-filters .section-title {
      margin-top: 14px; padding-top: 10px;
      border-top: 1px solid var(--card-border);
    }
    .meta { color: var(--muted); font-size: 13px; }
    .meta > div { margin-top: 3px; }
    .meta .meta-q {
      color: var(--ink); font-weight: 600; font-size: 13.5px;
      overflow-wrap: anywhere; margin-top: 0;
    }
    .results { margin-top: 4px; }
    .card {
      background: var(--surface); border: 1px solid var(--card-border); border-radius: 8px;
      padding: 16px 18px; margin-bottom: 14px;
      cursor: pointer; transition: border-color .15s, box-shadow .15s;
    }
    .card:hover { border-color: color-mix(in srgb, var(--accent) 45%, #fff); box-shadow: 0 2px 8px rgba(31,46,37,.08); }
    .card:active { border-color: var(--accent); }
    .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
    /* Titles read as headlines (serif, ink); the accent appears on hover. */
    .name { font-family: var(--serif); font-size: 18.5px; font-weight: 600; line-height: 1.3; color: var(--ink); flex: 1; min-width: 0; transition: color .15s; }
    .card:hover .name { color: var(--accent); }
    /* Type badge: a soft tinted pill in sentence case (full words:
       "Indication", "Document"), in the spirit of science / climate sites
       (Our World in Data, Carbon Brief, Copernicus): muted earth-and-ocean
       hues, tinted fill + hairline border + dark text instead of white on
       saturated colour. The width grows with the label (never clipped);
       min-width keeps the short ones ("Gap", "Law") from looking stubby. */
    .badge {
      --bc: var(--muted);
      box-sizing: border-box; flex-shrink: 0;
      display: inline-flex; align-items: center; justify-content: center; gap: 5px;
      min-width: 104px; white-space: nowrap;
      font-size: 12px; font-weight: 600; line-height: 1.3; letter-spacing: .1px;
      color: color-mix(in srgb, var(--bc) 82%, #000);
      background: color-mix(in srgb, var(--bc) 11%, #fff);
      border: 1px solid color-mix(in srgb, var(--bc) 32%, #fff);
      border-radius: 999px; padding: 3px 12px 3px 10px;
    }
    .badge.oi { --bc: var(--oi); }
    .badge.rec { --bc: var(--rec); }
    .badge.gap { --bc: var(--gap); }
    .badge.prj { --bc: var(--prj); }
    .badge.paper { --bc: var(--paper); }
    .badge.model { --bc: var(--model); }
    .badge.plan { --bc: var(--plan); }
    .badge.law { --bc: var(--law); }
    .badge.dataset { --bc: var(--dataset); }
    .badge.ft { --bc: var(--muted); }
    /* Badge icon: <use> into the inline Lucide sprite at the top of <body>.
       Inherited properties pass through the <use> shadow tree, so the stroke
       styling lives here rather than in each <symbol>. */
    .bic {
      width: 13px; height: 13px; flex-shrink: 0;
      fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round;
    }
    .preview {
      color: var(--ink-2); font-size: 14.5px; line-height: 1.55; margin: 0 0 10px;
      display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    }
    .preview:empty { display: none; }
    /* Matched query words (word modes). A soft ochre wash, no padding, so
       the line does not shift when marks appear. */
    mark.hl {
      background: color-mix(in srgb, var(--dataset) 24%, #fff);
      color: inherit; border-radius: 2px;
      box-shadow: 0 0 0 1px color-mix(in srgb, var(--dataset) 24%, #fff);
    }
    /* Where the match is, when the visible text does not show it. */
    .matched-in { font-size: 12.5px; font-style: italic; color: var(--muted); margin: -4px 0 10px; overflow-wrap: anywhere; }
    .matched-in mark.hl { font-style: normal; }
    /* Indication / Gap cards have no headline: the body text sits where the
       title would be, with the badge to its right (and still right-aligned
       when "Show more" hides the preview). */
    .child-head { align-items: flex-start; }
    .child-head .preview { flex: 1; min-width: 0; margin: 0; }
    .child-head .badge { margin-left: auto; flex-shrink: 0; }
    .full { display: none; margin-bottom: 10px; }
    .full .field { color: var(--ink-2); font-size: 14.5px; line-height: 1.6; margin-bottom: 8px; }
    .full .flabel { font-weight: 600; color: var(--ink); }
    .card.open .full { display: block; }
    .card.open .preview { display: none; }
    .toggle {
      background: none; border: none; color: var(--accent); cursor: pointer;
      font: inherit; font-size: 13.5px; font-weight: 600; padding: 0; margin-bottom: 10px;
    }
    .toggle:hover { text-decoration: underline; }
    .scores { font-size: 12px; color: var(--muted); background: var(--sand); border-radius: 6px; padding: 6px 10px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
    .scores b { color: var(--ink-2); font-weight: 600; }
    /* First author | Year | Type | Journal, between "Show more" and the scores. */
    .card-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; overflow-wrap: anywhere; }
    .card-meta .mlabel { color: var(--ink-2); font-weight: 600; }
    .card-meta .msep { margin: 0 8px; color: var(--border); }
    /* Provenance of a STANDALONE child card (Rec/Gap): the parent document
       at the TOP of the card ("Plan: ...") and a matching one-line reason at
       the bottom (.why-row). Both are suppressed when the card is nested —
       the card right above already IS the parent. */
    .parent-row { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
    .parent-row .plabel { color: var(--ink-2); font-weight: 600; }
    .why-row { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 8px; }
    /* Rec/Gap children of a document that is itself in the results: indented
       on a left rule under that parent card instead of top-level cards. The
       negative top margin pulls the rule up into the parent card's bottom
       margin, so parent + children read as one block; the bottom margin keeps
       the usual card rhythm towards the next top-level card. */
    .child-group { margin: -6px 0 14px 26px; padding-left: 16px; border-left: 2px solid color-mix(in srgb, var(--accent) 22%, var(--bg)); }
    .child-group .card { margin-bottom: 10px; }
    .child-group .card:last-child { margin-bottom: 0; }
    .empty, .error, .loading { color: var(--muted); text-align: center; padding: 24px 0; }
    .far-toggle { display: block; width: 100%; margin: 8px 0 14px; padding: 10px 14px; font: inherit; font-size: 14px; color: var(--muted); background: transparent; border: 1px dashed var(--border); border-radius: 8px; cursor: pointer; }
    .far-toggle:hover { color: var(--ink); border-style: solid; background: var(--surface); }
    .far-results { border-top: 1px solid var(--border); padding-top: 14px; }
    .far-results .card { opacity: .85; }
    .scores .fail { opacity: .5; }
    .error { color: var(--danger); }
    footer { margin: 40px 0 20px; font-size: 12px; color: var(--faint); }
    /* Footer now sits in the left column, right under the summary lines. */
    .col-filters footer { margin: 14px 0 4px; }
