*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --max-width: 1100px;
    --spacing: 1.5rem;
}

body {
    margin: 0;
}

a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--color-link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-link);
    outline-offset: 2px;
    border-radius: 2px;
}

header :focus-visible {
    outline-color: #fff;
}

main:focus {
    outline: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -4rem;
    left: 0.5rem;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--color-bg);
    color: var(--color-link);
    border: 1px solid var(--color-link);
    border-radius: 4px;
    text-decoration: none;
    transition: top 0.15s ease;
}

.skip-link:focus {
    top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

header {
    background: var(--color-header-bg);
    color: var(--color-header-text);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.75rem var(--spacing);
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    /* Pinned so the <h1> (homepage) and <p> (elsewhere) render identically
       regardless of the shared heading styles. */
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.site-title a {
    color: inherit;
    text-decoration: none;
}

.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, .content {
    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 {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: calc(var(--spacing) * 1.5) var(--spacing);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
}

.footer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.footer-credit {
    margin: 0;
}

h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
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;
}

dl {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 0.25rem 1.25rem;
    margin: 0.5rem 0 1rem;
}

dt {
    color: var(--color-muted);
    font-size: var(--text-sm);
    font-weight: 600;
    padding-top: 0.1rem;
}

dd {
    margin: 0;
    min-width: 0;
}

form {
    margin: 1rem 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 input[type="search"]::placeholder {
    color: rgba(255,255,255,0.7);
}

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

header form button:hover {
    background: rgba(255,255,255,0.35);
}

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);
}

.table-wrap {
    overflow-x: auto;
    margin: 0.5rem 0 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    margin: 0.5rem 0 1rem;
}

.table-wrap table {
    margin: 0;
}

th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }

th {
    font-weight: 600;
    color: var(--color-muted);
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

tbody tr:hover {
    background: #f5f7fa;
}

.muted {
    color: var(--color-muted);
    font-size: var(--text-sm);
}

/* Filing status on charity pages. Same shape as .company-popup-status. Amber
   only while a return is outstanding; being late in the past stays grey. */
.index-layout {
  display: grid;
  grid-template-columns: 1fr 15rem;
  gap: 0 2.5rem;
  align-items: start;
}
.stats-column {
  grid-row: 1 / 99;
  grid-column: 2;
}
.stats-panel {
  background: #f5f7fa;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.stats-panel dl {
  display: block;
  margin: 0;
}
.stats-panel dt {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.75rem;
}
.stats-panel dt:first-of-type {
  margin-top: 0;
}
.stats-panel dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
  color: var(--color-muted);
}
.stats-panel .country-breakdown dd {
  text-align: right;
}
.map-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  font-size: 1.1rem;
  font-weight: 500;
}
.map-link svg {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
}
.hp-search-form {
  margin: 0 0 1.5rem;
}
.hp-search-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.hp-search-row input[type="search"] {
  flex: 1;
  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;
}
.hp-advanced-link {
  margin: 0.25rem 0 0;
  font-size: var(--text-sm);
}
@media (max-width: 600px) {
  .index-layout { grid-template-columns: 1fr; }
  .stats-column { grid-row: auto; grid-column: 1; }
}

/* ---- OpenLegislation ---------------------------------------------------- */

.lede { font-size: var(--text-lg); line-height: var(--text-lg-leading); }

.item-list { padding-left: 1.1rem; }
.item-list li { margin: 0.35rem 0; }

.breadcrumb {
    margin: 0 0 0.5rem;
    font-size: var(--text-sm);
    color: var(--color-muted);
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumb li + li::before {
    content: '\203A';
    margin: 0 0.4rem;
    color: var(--color-muted);
}

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

.item-main { min-width: 0; max-width: 46rem; }

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

.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.25rem; padding: 0; }

/* Facts list: a two-column grid of muted bold labels and values. */
.facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    margin: 0;
}

.facts dt { color: var(--color-muted); font-weight: 600; }
.facts dd { margin: 0; }

.data-links {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.data-links li { margin: 0; }

.data-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: var(--text-sm);
    text-decoration: none;
    color: var(--color-link);
    background: var(--color-bg);
    transition: background 0.15s, border-color 0.15s;
}

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

.data-links a::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: -0.2rem;
    background-color: currentColor;
    -webkit-mask: no-repeat center / contain;
    mask: no-repeat center / contain;
}

.data-links a.format-json::before { -webkit-mask-image: url('../img/formats/json.svg'); mask-image: url('../img/formats/json.svg'); }
.data-links a.format-md::before   { -webkit-mask-image: url('../img/formats/markdown.svg'); mask-image: url('../img/formats/markdown.svg'); }

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

.status-banner {
    border-left: 4px solid var(--color-border);
    background: var(--color-panel-bg);
    padding: 0.6rem 1rem;
    margin: 1rem 0;
    border-radius: 0 4px 4px 0;
}

.status-banner p { margin: 0.25rem 0; }
.status-banner.is-ok { border-left-color: #0b6e4f; }
/* The family's amber caveat block. */
.status-banner.is-warning { border-left-color: #e0b800; background: #fff8e1; }
.status-banner.is-info { border-left-color: var(--color-link); background: var(--color-accent-bg); }
.status-banner details { margin-top: 0.5rem; }
.status-banner summary { cursor: pointer; color: var(--color-link); }
.status-banner table { font-size: var(--text-sm); margin-top: 0.5rem; }

.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;
}

/* The quiet variant: extents and other labels. */
.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;
}

.search-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 1rem 0 1.5rem;
    box-shadow: inset 0 -1px 0 var(--color-border);
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.search-tabs::-webkit-scrollbar { display: none; }

/* A row of plain links for narrowing a page (country, legislature). */
.filter-links {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.9rem;
    margin: 1rem 0 1.5rem;
    font-size: var(--text-sm);
}

.filter-label { color: var(--color-muted); }

.filter-links a[aria-current="page"] {
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
}

.search-tabs a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--color-muted);
    font-weight: 600;
    font-size: var(--text-sm);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    margin-bottom: -1px;
}

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

.search-tabs a[aria-current="page"] {
    color: var(--color-text);
    background: var(--color-bg);
    border-color: var(--color-border);
}

.intro { color: var(--color-muted); }

/* Contents */
.contents { list-style: none; padding: 0; margin: 0 0 2rem; }
.contents li { margin: 0.15rem 0; }
.contents .c-head { display: block; font-weight: var(--font-weight-semibold); margin-top: 0.9rem; }
.contents .kind-crossheading > .c-head { font-weight: var(--font-weight-medium); font-style: italic; margin-top: 0.6rem; }
.contents .c-num { display: inline-block; min-width: 2.25rem; margin-right: 0.35rem; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.contents li > a { display: inline-grid; grid-template-columns: auto minmax(0, 1fr); }
.contents .depth-1 { padding-left: 1rem; }
.contents .depth-2 { padding-left: 2rem; }
.contents .depth-3 { padding-left: 3rem; }
.contents .depth-4 { padding-left: 4rem; }
.contents .is-repealed a { color: var(--color-muted); }

/* Legislation text */
.provision { margin: 2rem 0; scroll-margin-top: 1rem; }
.provision h3 { font-size: var(--text-lg); margin: 0 0 0.5rem; }
.provision h3 a { color: inherit; }
.p-num { color: var(--color-muted); margin-right: 0.35rem; }
.heading-refs { margin-left: 0.3rem; font-size: var(--text-base); }

.legtext { font-size: 16px; line-height: 1.65; }
.legtext p { margin: 0.4rem 0; }
.ltitle { font-weight: 600; margin: 1rem 0 0.4rem; } /* not a heading: it would skip levels */
.legtext .p { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr); margin: 0.35rem 0; scroll-margin-top: 1rem; }
.legtext .p > .pnum { color: var(--color-muted); font-variant-numeric: tabular-nums; }
.legtext .p > .pbody > p:first-child { margin-top: 0; }
.legtext .p > .pbody:first-child { grid-column: 1 / -1; } /* unnumbered: full width */
.legtext .signee { margin: 1rem 0; }
.legtext .signee p { margin: 0.15rem 0; }
.legtext .signee .signee-name { font-weight: 600; }
.legtext .p:target { background: #fff3a8; border-radius: 2px; }
.legtext blockquote.amendment {
    margin: 0.5rem 0 0.5rem 0.5rem;
    padding-left: 1rem;
    border-left: 3px solid var(--color-border);
}
.legtext ins.amend { text-decoration: none; background: var(--color-accent-bg); }
.legtext ins.amend::before { content: "["; color: var(--color-muted); }
.legtext ins.amend::after { content: "]"; color: var(--color-muted); }
.legtext del.repeal { color: var(--color-muted); }
.legtext dfn { font-style: normal; font-weight: var(--font-weight-semibold); }
.legtext .smallcaps { font-variant: small-caps; }
.legtext cite { font-style: normal; }
.legtext img { max-width: 100%; height: auto; }
.legtext table { font-size: var(--text-sm); }
.legtext td, .legtext th { vertical-align: top; }

.ann-ref {
    font-size: 0.7em;
    vertical-align: super;
    line-height: 0;
    font-weight: var(--font-weight-semibold);
    margin-right: 0.1em;
}

.annotations { font-size: var(--text-sm); margin-top: 2.5rem; }
.annotations h3 { font-size: var(--text-sm); margin: 1rem 0 0.25rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.annotations dl { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: 0.25rem 0.5rem; margin: 0; }
.annotations dt { font-weight: var(--font-weight-semibold); scroll-margin-top: 1rem; }
.annotations dt:target, .annotations dt:target + dd { background: #fff3a8; }
.annotations dd { margin: 0; }
.annotations p { margin: 0; }

.prev-next {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

/* Search and browse */
.search-filters { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.75rem; font-size: var(--text-sm); }
.search-filters label { display: flex; gap: 0.4rem; align-items: center; }
.search-results { padding-left: 1.5rem; }
.search-results li { margin: 1rem 0; }
.snippet { margin: 0.25rem 0 0; color: var(--color-muted); font-size: var(--text-sm); }
.snippet mark { background: #fff3a8; color: inherit; }
.year-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 0.4rem 1rem; }
.prose { max-width: 46rem; }
.footer-licence { margin: 0; max-width: 36rem; }
.ann-ref + .ann-ref { margin-left: 0.2em; }

/* Pagination: Previous / status / Next on a 1fr auto 1fr grid. The wrappers
   hold their columns open on the first and last page so the status stays
   centred. */
.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);
}

.error { color: #b3261e; font-weight: 600; }

code {
    font-size: 0.9em;
    background: var(--color-panel-bg);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

@media (max-width: 640px) {
    :root { --spacing: 0.75rem; }
    .site-title { font-size: 1.1rem; }
}
