/* Box sizing, links, focus rings, skip link, the header band, breadcrumbs,
   tables (.table-wrap), .search-tabs, .index-layout and .stats-panel: see
   opencommons.uk/shared/opencommons.css. The page width, --max-width, and
   gutter, --spacing, come from there too. */

/* ---- Header and footer (as openlegislation) ----------------------------- */

.header-inner {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.site-title a:hover { color: inherit; text-decoration: underline; }
.site-title-open { color: #fff; font-weight: 700; }
.site-title-thing { color: #fff; opacity: 0.7; font-weight: 600; }

main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing) var(--spacing) calc(var(--spacing) * 3);
}

footer {
    background: #f5f5f5;
    font-size: var(--text-sm);
    color: var(--color-muted);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
}

.footer-nav { flex-direction: column; }
.footer-licence { max-width: 36rem; }
.footer-licence p { margin: 0 0 0.5rem; }
.footer-licence p:last-child { margin-bottom: 0; }

header form {
    margin: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}

header form input[type="search"] {
    width: 180px;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

header form button { background: rgba(255, 255, 255, 0.2); white-space: nowrap; }
header form button:hover { background: rgba(255, 255, 255, 0.35); }

/* ---- Type and basic elements -------------------------------------------- */

/* The trail sits 0.75rem above the page heading (design language). */
.breadcrumb { margin: 0 0 0.75rem; color: var(--color-muted); }

h1 { font-size: 1.75rem; margin: 0 0 0.5rem; overflow-wrap: anywhere; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.25rem; }
p { margin: 0.5rem 0 1rem; }
ul { margin: 0.25rem 0 1rem; padding-left: 1.25rem; }
li { margin-bottom: 0.35rem; }

.lede { font-size: var(--text-lg); line-height: var(--text-lg-leading); }
.intro { color: var(--color-muted); }
.prose { max-width: 46rem; }
.muted { color: var(--color-muted); font-size: var(--text-sm); }
/* The shared CSS gives code the mono face and resets Inter's features. */
code { font-size: 0.9em; background: var(--color-panel-bg); padding: 0.1em 0.3em; border-radius: 3px; }
.error { color: #b3261e; font-weight: 600; }

input[type="search"], input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
    max-width: 400px;
}

button, input[type="submit"] {
    padding: 0.4rem 1rem;
    background: var(--color-link);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

button:hover, input[type="submit"]:hover { background: var(--color-link-hover); }

/* ---- Tables: the rest is in the shared CSS ------------------------------ */

table { font-size: var(--text-sm); margin: 0.5rem 0 1rem; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th { white-space: nowrap; }
td { vertical-align: top; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--color-panel-bg); }
/* A title column keeps a readable width when the table scrolls on a phone. */
.title-cell { min-width: 14rem; overflow-wrap: anywhere; }
.sub { display: block; color: var(--color-muted); font-size: var(--text-sm); margin-top: 0.1rem; }
.vat { display: block; font-size: var(--text-xs); line-height: 1.2; white-space: nowrap; }
tr.is-void td { color: var(--color-muted); }
tr.is-void td a { color: var(--color-muted); }

/* ---- Lists of procurements ---------------------------------------------- */

.proc-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.proc-list li { margin: 0 0 0.85rem; }
.proc-list li > a { font-weight: var(--font-weight-medium); overflow-wrap: anywhere; }

/* ---- Home --------------------------------------------------------------- */

.hp-search-form { margin: 0 0 1.5rem; }
.hp-search-row { display: flex; gap: 0.5rem; }
.hp-search-row input[type="search"] { flex: 1; min-width: 0; max-width: none; font-size: 1.1rem; padding: 0.55rem 0.75rem; }
.hp-search-row button { white-space: nowrap; font-size: 1.1rem; padding: 0.55rem 1.25rem; }
.index-main { min-width: 0; }
.index-main > h2:first-of-type { margin-top: 0.5rem; }
.stats-panel dl { display: block; }
.stats-note { font-size: var(--text-sm); color: var(--color-muted); margin: 0.75rem 0 0; }

/* ---- Procurement and organisation pages --------------------------------- */

.item-sub {
    color: var(--color-muted);
    margin: 0 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    align-items: center;
}

.facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.4rem 1.25rem;
    margin: 0.5rem 0 1rem;
}

.facts dt { color: var(--color-muted); font-weight: 600; font-size: var(--text-sm); padding-top: 0.1rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.description p { margin: 0 0 0.75rem; }

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

.item-main { min-width: 0; }

.item-sidebar {
    font-size: var(--text-sm);
    background: var(--color-panel-bg);
    border-radius: 6px;
    padding: 1rem;
    position: sticky;
    top: 1.5rem;
}

.item-sidebar h2 { font-size: var(--text-sm); border: 0; margin: 1rem 0 0.5rem; padding: 0; }
.item-sidebar h2:first-child { margin-top: 0; }
/* On the panel the chip takes the page colour so it still shows. */
.item-sidebar code { background: var(--color-bg); }
.item-sidebar .facts { gap: 0.35rem 0.75rem; margin: 0; }
.item-sidebar .facts dt { font-size: var(--text-sm); }
.item-sidebar p { margin: 0.75rem 0 0; }

.totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 2.5rem;
    margin: 0 0 0.5rem;
}

.totals dt { color: var(--color-muted); font-size: var(--text-sm); font-weight: 600; }
.totals dd { margin: 0; font-size: var(--text-xl); line-height: var(--text-xl-leading); font-weight: 600; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; padding: 0; margin: 0.5rem 0 0.75rem; }
.timeline li { display: flex; flex-wrap: wrap; gap: 0 0.6rem; align-items: baseline; margin: 0 0 0.4rem; }
.timeline-date { min-width: 6.5rem; color: var(--color-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

.search-tabs a { font-size: var(--text-sm); }
.search-tabs .count { color: var(--color-muted); font-weight: 500; }

.badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    background: #8a8a8a;
    vertical-align: middle;
    white-space: nowrap;
}

/* Green for live states; every other status keeps the grey above. */
.badge.is-open, .badge.status-active { background: #0b6e4f; }

.tag {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--color-link);
    background: var(--color-accent-bg);
    vertical-align: middle;
    white-space: nowrap;
}

/* ---- Data: format pills (the shared CSS draws them) ---------------------- */

.data-links a { background: var(--color-bg); transition: background 0.15s, border-color 0.15s; }
.data-links a::before { margin-left: -0.2rem; }

/* ---- Search ------------------------------------------------------------- */

.results-search-form { display: flex; gap: 0.5rem; margin: 0 0 1.5rem; max-width: 46rem; }
.results-search-form input[type="search"] { flex: 1; min-width: 0; max-width: none; font-size: 1.1rem; padding: 0.55rem 0.75rem; }
.results-search-form button { white-space: nowrap; font-size: 1.1rem; padding: 0.55rem 1.25rem; }
.search-tips { max-width: 46rem; }

/* ---- Pagination (as openlegislation) ------------------------------------ */

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: var(--text-sm);
}

.pagination-prev { justify-self: start; }
.pagination-next { justify-self: end; }
.pagination-status { color: var(--color-muted); white-space: nowrap; }

.pagination a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--color-link);
    background: var(--color-bg);
    transition: background 0.15s, border-color 0.15s;
}

.pagination a:hover { background: var(--color-accent-bg); border-color: var(--color-link); color: var(--color-link-hover); }

/* ---- Narrow screens ----------------------------------------------------- */

@media (max-width: 800px) {
    .item-layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
    .item-sidebar { position: static; }
}

@media (max-width: 640px) {
    /* Wordmark and compact search on one line, as on the sister sites. */
    .header-inner { padding: 0.6rem var(--spacing); gap: 0.75rem; flex-wrap: nowrap; min-height: 3.25rem; }
    .site-title { font-size: 1.1rem; flex-shrink: 0; }
    header form { gap: 0.4rem; min-width: 0; flex: 1; justify-content: flex-end; }
    header form input[type="search"] { flex: 1; min-width: 0; max-width: 180px; padding: 0.3rem 0.5rem; font-size: 1rem; }
    header form button { padding: 0.35rem 0.7rem; font-size: var(--text-sm); }

    .index-layout { grid-template-columns: minmax(0, 1fr); }
    .stats-panel { margin-top: 1.5rem; }
    .hp-search-row button, .results-search-form button { padding: 0.55rem 0.9rem; }
    .facts { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
    .facts dt { margin-top: 0.5rem; }
    .item-sidebar .facts { grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 0.75rem; }
    .item-sidebar .facts dt { margin-top: 0; }
    .title-cell { min-width: 11rem; }
    .totals { gap: 0.5rem 1.5rem; }
    .totals dd { font-size: var(--text-lg); line-height: var(--text-lg-leading); }
}

/* ---- Contracts list: filters (selects as opencharities.uk's sort) -------- */

.list-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem 1rem; margin: 0 0 1rem; }
.list-filters label { display: flex; flex-direction: column; gap: 0.2rem; font-size: var(--text-sm); font-weight: 600; color: var(--color-muted); }
.list-filters select {
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
}
.list-filters button { padding: 0.45rem 1rem; }
.list-filters a { font-size: var(--text-sm); align-self: center; }

/* A headline with nothing to add up says why, in muted words, not "None". */
.totals dd .totals-note { color: var(--color-muted); font-size: var(--text-base); font-weight: 500; }
