/* Giurisprudenza (index.html): the home page and the questioni search.
 *
 * Only what is particular to this page, on top of site.css: the home sections shown
 * before the first search, the authority and taxonomy pickers of the advanced search,
 * the "Affina i risultati" sidebar and the result entries. Class names are the ones
 * script.js renders.
 */

/* ── Home: the sections under the search, hidden from the first search on
   (script.js sets body.has-searched) */

body.has-searched .home-only { display: none; }

.mcp-cta { margin-top: 1.5rem; }
.mcp-cta p { max-width: 62ch; margin: 0 0 1rem; }

.doors { margin-top: 2rem; }

.door {
    padding-top: 1rem;
    border-top: 2px solid var(--ink);
}

.door__label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    color: var(--graphite);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.door h3 { margin-bottom: 0.5rem; }
.door p:last-child { margin-bottom: 0; }

.coverage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 2.5rem;
    align-items: start;
}

.coverage-table tbody th {
    color: var(--ink);
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.coverage-table td:last-child { color: var(--graphite); }
.coverage-table .num { color: var(--ink); text-align: left; }
.coverage-source { margin: 0.75rem 0 0; color: var(--graphite); font-size: 0.8125rem; }

.why__text {
    font-family: var(--font-serif);
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
    line-height: 1.5;
}

@media (max-width: 860px) {
    .coverage { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
}

/* ── Advanced search: authority picker and taxonomy */
.searchable-select,
.keywords-input-container { position: relative; }

.keywords-input-container { display: flex; gap: 0.5rem; }
.keywords-input-container .input { flex: 1; }

.searchable-select-dropdown,
.keywords-dropdown {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    display: none;
    max-height: 18rem;
    overflow-y: auto;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.searchable-select-dropdown.show,
.keywords-dropdown.show { display: block; }

.searchable-select-option,
.keywords-dropdown-option {
    padding: 0.5rem 0.75rem;
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option.highlighted,
.keywords-dropdown-option:hover,
.keywords-dropdown-option.highlighted { background: var(--paper-2); }

.keyword-option-content { display: flex; justify-content: space-between; gap: 1rem; }

.keyword-hierarchy {
    max-width: 55%;
    overflow: hidden;
    color: var(--graphite);
    font-size: 0.75rem;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-keywords { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.selected-keywords:empty { display: none; }

.selected-keyword {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.25rem 0.15rem 0.6rem;
    border-radius: var(--radius);
    background: var(--hl);
    color: var(--hl-ink);
    font-size: 0.8125rem;
    font-weight: 500;
}

.remove-keyword { padding: 0 0.3rem; color: var(--hl-ink); font-size: 1rem; line-height: 1; cursor: pointer; }

.taxonomy-pills-section {
    display: none;
    margin-top: 0.75rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper);
}

.taxonomy-pills-section.expanded { display: block; }

.pills-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--rule);
    font-size: 0.8125rem;
}

.pills-title { color: var(--ink); font-weight: 600; }
.pills-stats { display: flex; gap: 1rem; color: var(--graphite); font-family: var(--font-mono); font-size: 0.75rem; }

.pills-container {
    display: flex;
    max-height: 18rem;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.9rem;
    overflow-y: auto;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--graphite);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

/* The taxonomy roots read as headings of the run of pills that follows them. */
.pill.level-1 { border-color: var(--ink); color: var(--ink); font-weight: 700; }
.pill.level-2 { color: var(--ink); }
.pill:hover { border-color: var(--ink); }
.pill.selected { border-color: var(--hl); background: var(--hl); color: var(--hl-ink); }
.pill-checkmark { display: none; }
.pill.selected .pill-checkmark { display: inline; }

@media (max-width: 720px) {
    .keyword-hierarchy { display: none; }
}

/* ── Results: sidebar + list */
.results-section:not(.show) { display: none; }

.results-layout {
    display: grid;
    grid-template-columns: 16.5rem minmax(0, 1fr);
    gap: 3rem;
    padding-block: 1.5rem 3rem;
}

.results-list { min-width: 0; }

.stats-sidebar {
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
    max-height: calc(100vh - var(--header-h) - 2.5rem);
    align-self: start;
    padding-right: 0.25rem;
    overflow-y: auto;
    font-size: 0.875rem;
}

.stats-title { margin: 0 0 0.2rem; font-size: 1.25rem; }

.stat-summary {
    margin: 0 0 0.75rem;
    color: var(--graphite);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.stat-item { padding-block: 0.9rem; border-top: 1px solid var(--rule); }

.stat-label {
    display: block;
    margin: 0 0 0.4rem;
    color: var(--graphite);
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-pills-container { display: grid; gap: 0.1rem; }

.stat-pill-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-inline: -0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius);
    line-height: 1.35;
    cursor: pointer;
}

.stat-pill-item:hover { background: var(--paper-2); }

.stat-pill-label { min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.reference-pill .stat-pill-label { font-family: var(--font-mono); font-size: 0.8125rem; }

.stat-pill-count {
    flex: 0 0 auto;
    color: var(--graphite);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* An active filter is something the reader selected: it gets the highlighter. */
.stat-pill-item.stat-pill-active { background: var(--hl); }
.stat-pill-item.stat-pill-active .stat-pill-label,
.stat-pill-item.stat-pill-active .stat-pill-count { color: var(--hl-ink); }

.stat-hint { margin: 0.9rem 0 0; color: var(--graphite); font-size: 0.75rem; }

.results-header { padding-bottom: 0.75rem; border-bottom: 1px solid var(--ink); }

.results-count {
    margin: 0;
    color: var(--graphite);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.search-references { margin-top: 0.6rem; }

.search-references-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--graphite);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.search-references-pills { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; }
.search-ref-pill { font-family: var(--font-mono); font-size: 0.8125rem; }

@media (max-width: 900px) {
    .results-layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
    .stats-sidebar { position: static; max-height: none; order: 2; overflow: visible; }
}

/* ── A result: one questione */
.result-item { border-bottom: 1px solid var(--rule); }

.result-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding-block: 1.25rem;
    cursor: pointer;
}

.result-main { min-width: 0; flex: 1; }

.result-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.65rem;
    margin-bottom: 0.45rem;
    color: var(--graphite);
    font-size: 0.8125rem;
}

.result-meta .cite { color: var(--ink); }
.result-date { font-family: var(--font-mono); font-size: 0.75rem; }

.result-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-sans);
    font-size: 1.1875rem;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.result-summary {
    margin: 0;
    color: var(--graphite);
    font-size: 0.9375rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.result-cites { margin: 0.55rem 0 0; color: var(--graphite); font-size: 0.8125rem; }
.result-cites mark { font-family: var(--font-mono); }

/* Below the relevance threshold: still there, but receding until opened. */
.result-item.low-relevance .result-main { opacity: 0.72; }
.result-item.low-relevance:hover .result-main,
.result-item.low-relevance.expanded .result-main { opacity: 1; }

.result-toggle svg { transition: transform 0.15s ease; }
.result-item.expanded .result-toggle svg { transform: rotate(180deg); }

.result-expanded:not(.show) { display: none; }

.expanded-content { max-width: 60rem; padding: 0.25rem 0 1.75rem; }

.detail-section { border-top: 2px solid var(--struttura); padding-top: 0.7rem; }
.detail-section + .detail-section { margin-top: 1.6rem; }

.detail-title {
    margin: 0 0 0.6rem;
    color: var(--struttura);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* What the case is made of — dates, keywords, documents — sits together at the end, so
   the reasoning above reads as continuous text and the rules there stay quiet. */
.detail-meta {
    margin-top: 1.75rem;
    padding: 1.1rem 1.25rem;
    background: var(--paper-2);
    border-radius: var(--radius);
}

.detail-meta .detail-section { border-top: 1px solid var(--rule-strong); }
.detail-meta .detail-section:first-child { border-top: 0; padding-top: 0; }
.detail-meta .detail-section + .detail-section { margin-top: 1.2rem; }
.detail-meta .detail-title { color: var(--graphite); }

.detail-text {
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.facts-list,
.reasoning-list { margin: 0; padding-left: 1.2rem; }
.facts-list { font-size: 0.9375rem; }
.reasoning-list { font-family: var(--font-sans); font-size: 0.9375rem; line-height: 1.6; }
.facts-list li + li,
.reasoning-list li + li { margin-top: 0.4rem; }

/* The cited references, as a list: one per row, its reason underneath in the margin. */
.ref { margin: 0 0 0.75rem; }
.ref + .ref { padding-top: 0.75rem; border-top: 1px solid var(--rule); }
.ref:last-child { margin-bottom: 0; }
.ref-text { font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.5; overflow-wrap: anywhere; }
.ref .note { margin: 0.3rem 0 0; font-family: var(--font-sans); font-size: 0.875rem; }

.ref-list-plain { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }

/* Ricorso → Udienza → Deposito: la linea passa dietro i pallini, e una data che la
   decisione non porta tiene il suo posto, vuota. */
.timeline {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline__step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
}

.timeline__label {
    color: var(--graphite);
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.timeline__mark {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 0.9rem;
}

.timeline__mark::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--rule-strong);
    transform: translateY(-50%);
}

/* La linea si ferma al primo e all'ultimo pallino invece di uscire dai bordi. */
.timeline__step:first-child .timeline__mark::before { left: 50%; }
.timeline__step:last-child .timeline__mark::before { right: 50%; }

.timeline__dot {
    position: relative;
    width: 0.65rem;
    height: 0.65rem;
    border: 2px solid var(--rule-strong);
    border-radius: 50%;
    background: var(--paper-2);
}

.timeline__date { font-family: var(--font-mono); font-size: 0.8125rem; }

.timeline__step.is-set .timeline__label { color: var(--ink); }
.timeline__step.is-set .timeline__dot { border-color: var(--struttura); background: var(--struttura); }

.timeline__step:not(.is-set) .timeline__date {
    color: var(--graphite);
    font-family: var(--font-sans);
    font-size: 0.75rem;
}

@media (max-width: 560px) {
    .timeline__label { font-size: 0.625rem; }
    .timeline__date { font-size: 0.75rem; }
}

.info-list { margin: 0; padding: 0; font-size: 0.875rem; list-style: none; }
.info-list li + li { margin-top: 0.35rem; }

@media (max-width: 760px) {
    .result-title { font-size: 1.0625rem; }
}

.results-content > .empty,
.results-content > .notice { margin-top: 1.25rem; }

/* ── Free-text feedback after each search */
.feedback-prompt {
    margin-top: 1.5rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper-2);
}

.feedback-prompt-label { display: block; margin-bottom: 0.5rem; color: var(--ink); font-size: 0.875rem; }
.feedback-textarea { min-height: 4.5rem; resize: vertical; }

.feedback-prompt-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.6rem;
}

.feedback-prompt-status { color: var(--graphite); font-size: 0.8125rem; transition: opacity 0.4s ease; }
.feedback-prompt-status.success { color: var(--verifica); }
.feedback-prompt-status.error { color: var(--attenzione-text); }
.feedback-prompt-status.fading { opacity: 0; }
