/* =========================================================================
   Republic of Roldem — structural stylesheet
   -------------------------------------------------------------------------
   This file owns layout and component structure only. Every colour, font and
   radius comes from a custom property that the active theme defines, so a
   theme can restyle the site without touching this file.

   The contract a theme must provide is documented in
   src/Themes/roldem-classic.css.
   ========================================================================= */

/* ---------- Reset & base ------------------------------------------------ */

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

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: 1.65;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

img,
picture,
svg,
video {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--color-link);
    text-decoration: none;
}

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

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.22;
    color: var(--color-heading);
    letter-spacing: -0.011em;
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }

p, ul, ol, dl, table, figure, blockquote, pre {
    margin: 0 0 var(--space-4);
}

ul, ol {
    padding-left: 1.35em;
}

li + li {
    margin-top: 0.3em;
}

li > ul,
li > ol {
    margin: 0.3em 0 0;
}

hr {
    height: 1px;
    border: 0;
    margin: var(--space-6) 0;
    background: var(--color-border);
}

code, pre, kbd {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

code {
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
}

pre {
    padding: var(--space-4);
    overflow-x: auto;
    border-radius: var(--radius);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
}

blockquote {
    padding: var(--space-2) 0 var(--space-2) var(--space-4);
    border-left: 3px solid var(--color-brand);
    color: var(--color-text-muted);
    font-style: italic;
}

mark {
    background: var(--color-highlight);
    color: inherit;
    padding: 0 0.15em;
    border-radius: 2px;
}

/* ---------- Utilities --------------------------------------------------- */

.shell {
    width: 100%;
    max-width: var(--layout-width);
    margin: 0 auto;
    padding-inline: var(--layout-gutter);
}

.shell--narrow {
    max-width: var(--layout-width-narrow);
}

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

.is-muted {
    color: var(--color-text-muted);
}

.skip-link {
    position: fixed;
    top: -100px;
    left: var(--space-4);
    z-index: 200;
    padding: 0.7em 1.1em;
    font-weight: 700;
    color: var(--color-brand-contrast);
    background: var(--color-brand);
    border-radius: 0 0 var(--radius) var(--radius);
    transition: top 0.15s ease;
}

.skip-link:focus {
    top: 0;
    color: var(--color-brand-contrast);
    text-decoration: none;
}

/* ---------- Buttons & forms -------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    min-height: 2.6rem;
    padding: 0.5em 1.1em;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    background: var(--color-brand);
    color: var(--color-brand-contrast);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button:hover {
    background: var(--color-brand-dark);
    color: var(--color-brand-contrast);
    text-decoration: none;
}

.button--secondary {
    background: var(--color-surface);
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.button--secondary:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.button--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-link);
}

.button--ghost:hover {
    background: var(--color-surface-alt);
}

.button--danger {
    background: var(--color-danger);
    color: #fff;
}

.button--danger:hover {
    background: var(--color-danger-dark);
}

.button--small {
    min-height: 2.1rem;
    padding: 0.3em 0.75em;
    font-size: 0.86rem;
}

.button--block {
    width: 100%;
}

.button[disabled],
.button[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 2.6rem;
    padding: 0.5em 0.7em;
    font: inherit;
    color: var(--color-text);
    background: var(--color-input-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
}

textarea {
    min-height: 8rem;
    line-height: 1.55;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-brand);
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.35em;
}

.field {
    margin-bottom: var(--space-4);
}

.field__hint {
    margin: 0.35em 0 0;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.field--inline {
    display: flex;
    align-items: center;
    gap: 0.6em;
}

.field--inline label {
    margin: 0;
    font-weight: 400;
}

.field--inline input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    min-height: 0;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--color-brand);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
    gap: 0 var(--space-4);
}

/* ---------- Notices ---------------------------------------------------- */

.notice {
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-brand);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.notice p:last-child,
.notice ul:last-child {
    margin-bottom: 0;
}

.notice--success { border-left-color: var(--color-success); }
.notice--error { border-left-color: var(--color-danger); }
.notice--info { border-left-color: var(--color-info); }
.notice--warning { border-left-color: var(--color-warning); }

.flash-stack {
    margin-bottom: var(--space-5);
}

.theme-preview-bar {
    margin: 0;
    border-radius: 0;
    border-left-width: 0;
    border-top: 0;
}

/* ---------- Utility bar ------------------------------------------------ */

.utility-bar {
    background: var(--color-surface-alt);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.utility-bar__inner {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    min-height: 2.9rem;
}

.utility-bar__links {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-left: auto;
}

.utility-bar__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.4em 0.65em;
    border-radius: var(--radius);
    color: var(--color-text-muted);
    font-weight: 600;
}

.utility-bar__link:hover {
    color: var(--color-brand);
    background: var(--color-surface);
    text-decoration: none;
}

.utility-bar__icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
}

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

.searchbox {
    display: flex;
    align-items: stretch;
    max-width: 22rem;
}

.searchbox__input {
    min-width: 0;
    min-height: 2.3rem;
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: 0;
}

.searchbox__button {
    min-height: 2.3rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    white-space: nowrap;
}

/* ---------- Site header ------------------------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-header);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: 4.5rem;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    margin-right: auto;
}

.site-brand img {
    max-height: 3rem;
    width: auto;
}

.site-brand__text {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-heading);
    line-height: 1.2;
}

/* ---------- Primary navigation (desktop) ------------------------------- */

.primary-nav__list,
.primary-nav__sublist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.primary-nav__list {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.primary-nav__item {
    position: relative;
    margin: 0;
}

.primary-nav__row {
    display: flex;
    align-items: stretch;
}

.primary-nav__link {
    display: flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.6em 0.7em;
    border-radius: var(--radius);
    color: var(--color-nav-text);
    font-weight: 700;
    white-space: nowrap;
}

.primary-nav__link:hover {
    color: var(--color-brand);
    background: var(--color-surface-alt);
    text-decoration: none;
}

.primary-nav__item--current > .primary-nav__row > .primary-nav__link {
    color: var(--color-brand);
}

.primary-nav__item--current > .primary-nav__row > .primary-nav__link::after {
    content: "";
    position: absolute;
    left: 0.7em;
    right: 0.7em;
    bottom: 0.1em;
    height: 2px;
    border-radius: 2px;
    background: var(--color-brand);
}

.primary-nav__caret {
    width: 0.7em;
    height: 0.7em;
    flex: 0 0 auto;
    opacity: 0.65;
}

/* Dropdown for sub-pages: opens on hover and on keyboard focus. */
.primary-nav__sublist {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 70;
    min-width: 15rem;
    padding: 0.4rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.35rem);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
}

.primary-nav__item:hover > .primary-nav__sublist,
.primary-nav__item:focus-within > .primary-nav__sublist,
.primary-nav__sublist:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Invisible bridge: without it the pointer loses the menu in the gap
   between the trigger and the panel. */
.primary-nav__sublist::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -0.4rem;
    height: 0.4rem;
}

.primary-nav__sublist .primary-nav__item--ancestor > .primary-nav__sublink {
    font-weight: 700;
}

.primary-nav__sublink {
    display: block;
    padding: 0.5em 0.7em;
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.94rem;
}

.primary-nav__sublink:hover {
    background: var(--color-surface-alt);
    color: var(--color-brand);
    text-decoration: none;
}

.primary-nav__sublist .primary-nav__item--current > .primary-nav__sublink {
    color: var(--color-brand);
    font-weight: 700;
}

.primary-nav__sublist .primary-nav__sublist {
    position: static;
    min-width: 0;
    padding: 0 0 0 0.85rem;
    border: 0;
    border-left: 1px solid var(--color-border);
    margin-left: 0.7rem;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* ---------- Nav toggle & mobile drawer --------------------------------- */

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    width: 2.85rem;
    height: 2.85rem;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.nav-toggle__bars {
    display: block;
    position: relative;
    width: 1.15rem;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: background-color 0.15s ease;
}

.nav-toggle__bars::before,
.nav-toggle__bars::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.18s ease;
}

.nav-toggle__bars::before { top: -0.4rem; }
.nav-toggle__bars::after { top: 0.4rem; }

.nav-toggle[aria-expanded="true"] .nav-toggle__bars {
    background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before {
    transform: translateY(0.4rem) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after {
    transform: translateY(-0.4rem) rotate(-45deg);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.has-drawer-open .drawer-backdrop {
    opacity: 1;
    visibility: visible;
}

/* The drawer lives inside the header, so it shares the header's stacking
   context. The header has to outrank the backdrop or the dimming would be
   painted over the open drawer. */
body.has-drawer-open .site-header {
    z-index: 100;
}

body.has-drawer-open {
    overflow: hidden;
}

/* ---------- Hero banner ------------------------------------------------ */

.hero {
    position: relative;
    background: var(--color-banner-bg);
    color: var(--color-banner-text);
    padding-block: var(--space-6) var(--space-7);
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--hero-overlay, none);
    pointer-events: none;
}

.hero__inner {
    position: relative;
    z-index: 1;
}

.hero__title {
    margin: 0 0 0.2em;
    color: inherit;
    font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.85rem);
}

.hero__subtitle {
    margin: 0;
    font-family: var(--font-body);
    font-size: clamp(1rem, 0.94rem + 0.3vw, 1.2rem);
    font-weight: 400;
    color: inherit;
    opacity: 0.92;
}

.hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-4);
    font-size: 0.85rem;
    opacity: 0.85;
}

.hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.2em 0.6em;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}

/* Breadcrumbs sit inside the banner, which avoids a divider line
   crowding the first line of body copy. */
.breadcrumbs {
    margin-bottom: var(--space-3);
    font-size: 0.85rem;
}

.breadcrumbs__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35em;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumbs__item {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.breadcrumbs__item + .breadcrumbs__item::before {
    content: "/";
    opacity: 0.55;
}

.breadcrumbs a {
    color: inherit;
    opacity: 0.9;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
    text-underline-offset: 0.2em;
}

.breadcrumbs a:hover {
    opacity: 1;
    color: inherit;
}

.breadcrumbs__item[aria-current] {
    opacity: 0.85;
}

/* ---------- Main layout ------------------------------------------------ */

.layout {
    padding-block: var(--space-6) var(--space-8);
}

.layout__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
}

.layout__grid--with-sidebar {
    grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
    gap: var(--space-7);
}

.layout__main {
    min-width: 0;
}

.layout__sidebar {
    min-width: 0;
    position: sticky;
    top: 5.75rem;
}

/* ---------- Article content -------------------------------------------- */

/* Body copy keeps a comfortable measure. Without a sidebar the column would
   sit lonely on the left, so it gets centred instead. */
/* The measure lives on the text blocks, not on the article, so grids, tables
   and figures can still use the full column width. */
.prose > * {
    max-width: 68ch;
}

.prose > .card-grid,
.prose > .data-table-wrap,
.prose > .notice,
.prose > .page-meta,
.prose > hr {
    max-width: none;
}

.prose > h2 {
    margin-top: var(--space-7);
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--color-border);
}

.prose > h2:first-child {
    margin-top: 0;
}

.prose > h3 {
    margin-top: var(--space-6);
}

.prose::after {
    content: "";
    display: table;
    clear: both;
}

.content-heading {
    scroll-margin-top: 6rem;
}

.content-link--missing {
    border-bottom: 1px dashed var(--color-danger);
    color: var(--color-danger);
    cursor: help;
}

.content-link--self {
    font-weight: 700;
}

.content-link--external::after {
    content: "↗";
    margin-left: 0.2em;
    font-size: 0.8em;
    vertical-align: super;
    opacity: 0.7;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-7);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ---------- Content components ----------------------------------------- */

.content-figure {
    margin: 0 0 var(--space-5);
}

.content-figure img {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.content-figure figcaption {
    margin-top: 0.5em;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.content-figure--right {
    float: right;
    max-width: min(17rem, 42%);
    margin: 0 0 var(--space-4) var(--space-5);
}

.content-figure--left {
    float: left;
    max-width: min(17rem, 42%);
    margin: 0 var(--space-5) var(--space-4) 0;
}

.content-figure--flag {
    max-width: 26rem;
}

.content-figure--on-white img {
    background-color: #fff;
    padding: 0.5rem;
}

.flag-pair {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}

.info-box {
    float: right;
    width: min(18rem, 42%);
    margin: 0 0 var(--space-5) var(--space-5);
    padding: var(--space-4);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
}

.info-box-title {
    margin-bottom: 0.6em;
    font-weight: 700;
    text-align: center;
}

.info-box-media img {
    margin: 0 auto 0.85em;
}

.info-box dl { margin: 0; }
.info-box dt { font-weight: 700; margin-top: 0.5em; }
.info-box dd { margin: 0; }

.hymn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-5);
}

.hymn-title {
    font-weight: 700;
}

/* ---------- Tables ------------------------------------------------------ */

.data-table-wrap {
    margin-bottom: var(--space-5);
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th,
.data-table td {
    padding: 0.6em 0.8em;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--color-border);
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-surface-alt);
    border-bottom: 2px solid var(--color-border-strong);
    white-space: nowrap;
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: var(--color-surface-alt);
}

.data-table caption {
    padding: 0.6em 0.8em;
    text-align: left;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Sortable headers, wired up by assets/js/site.js */
.data-table thead th[data-sortable] {
    position: sticky;
    cursor: pointer;
    user-select: none;
    padding-right: 1.5em;
}

.data-table thead th[data-sortable]:hover {
    color: var(--color-brand);
}

.data-table thead th[data-sortable]::after {
    content: "↕";
    position: absolute;
    right: 0.5em;
    opacity: 0.4;
    font-size: 0.8em;
}

.data-table thead th[aria-sort="ascending"]::after {
    content: "↑";
    opacity: 1;
    color: var(--color-brand);
}

.data-table thead th[aria-sort="descending"]::after {
    content: "↓";
    opacity: 1;
    color: var(--color-brand);
}

/* ---------- Cards & listings ------------------------------------------- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
    gap: var(--space-4);
    list-style: none;
    margin: var(--space-5) 0;
    padding: 0;
}

.card-grid__item {
    margin: 0;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
    height: 100%;
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
    border-color: var(--color-brand);
    box-shadow: var(--shadow-1);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--color-text);
}

.card__title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-brand);
}

.card__text {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.news-list,
.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.news-list__item,
.search-results-list li {
    margin: 0;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border);
}

.news-list__item:first-child,
.search-results-list li:first-child {
    padding-top: 0;
}

.news-list__link,
.search-results-list a {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
}

.news-list__date {
    display: block;
    margin-top: 0.2em;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.news-list__teaser,
.search-result__teaser {
    margin: 0.5em 0 0;
    color: var(--color-text-muted);
}

.search-result__path {
    display: block;
    margin-top: 0.3em;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
    list-style: none;
    padding: 0;
}

.pagination li { margin: 0; }

.pagination a,
.pagination span {
    display: inline-block;
    min-width: 2.4rem;
    padding: 0.4em 0.7em;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.pagination__current {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: var(--color-brand-contrast);
    font-weight: 700;
}

/* ---------- Sidebar ---------------------------------------------------- */

.widget {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.widget:last-child {
    margin-bottom: 0;
}

.widget__title {
    margin: 0 0 var(--space-3);
    padding-bottom: 0.4em;
    border-bottom: 2px solid var(--color-brand);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.widget p:last-child {
    margin-bottom: 0;
}

.widget__footer {
    margin: var(--space-3) 0 0;
}

.widget form + form,
.prose > .widget + .widget {
    margin-top: var(--space-5);
}

.section-nav,
.section-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.section-nav li {
    margin: 0;
}

.section-nav a {
    display: block;
    padding: 0.5em 0.7em;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--color-text);
    font-size: 0.95rem;
}

.section-nav a:hover {
    background: var(--color-surface-alt);
    border-left-color: var(--color-border-strong);
    color: var(--color-brand);
    text-decoration: none;
}

.section-nav__item--current > a {
    border-left-color: var(--color-brand);
    background: var(--color-surface-alt);
    color: var(--color-brand);
    font-weight: 700;
}

.section-nav__item--ancestor > a {
    border-left-color: var(--color-border-strong);
    font-weight: 700;
}

.section-nav ul {
    margin-left: 0.7rem;
    padding-left: 0.4rem;
    border-left: 1px solid var(--color-border);
}

.section-nav ul a {
    font-size: 0.9rem;
    padding-block: 0.4em;
}

/* Table of contents */
.toc {
    margin-bottom: var(--space-5);
}

.prose .toc {
    padding: var(--space-4);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.toc__title {
    margin: 0 0 var(--space-2);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: toc;
}

.toc__item {
    margin: 0;
}

.toc__item a {
    display: block;
    padding: 0.3em 0.5em;
    border-left: 2px solid transparent;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.toc__item a:hover,
.toc__item a[aria-current="true"] {
    color: var(--color-brand);
    border-left-color: var(--color-brand);
    background: var(--color-surface-alt);
    text-decoration: none;
}

.toc__item--level-3 a {
    padding-left: 1.3em;
    font-size: 0.85rem;
}

/* ---------- Forum ticker ----------------------------------------------- */

.ticker {
    position: relative;
    height: 3rem;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.ticker__list {
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
}

.ticker__item {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding-inline: var(--space-3);
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.ticker__item.is-active {
    opacity: 1;
    visibility: visible;
}

/* Without motion the entries are stacked instead of rotated. */
.ticker--static {
    height: auto;
}

.ticker--static .ticker__item {
    position: static;
    border-bottom: 1px solid var(--color-border);
    padding-block: 0.5rem;
}

.ticker--static .ticker__item:last-child {
    border-bottom: 0;
}

.ticker__link {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
    font-size: 0.94rem;
}

.ticker__link:hover {
    color: var(--color-brand);
}

.ticker__date {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ---------- Prefooter & footer ----------------------------------------- */

.prefooter {
    padding-block: var(--space-6);
    background: var(--color-surface-alt);
    border-top: 1px solid var(--color-border);
}

.prefooter__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: var(--space-5);
}

.prefooter .widget {
    margin: 0;
    background: transparent;
    border: 0;
    padding: 0;
}

.site-footer {
    padding-block: var(--space-5);
    background: var(--color-footer-bg);
    color: var(--color-footer-text);
    font-size: 0.9rem;
}

.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.site-footer a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
    text-underline-offset: 0.2em;
}

.site-footer a:hover {
    color: inherit;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-nav li { margin: 0; }

.site-footer__note {
    margin: 0;
    opacity: 0.8;
}

/* ---------- Back to top ------------------------------------------------ */

.to-top {
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    z-index: 50;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.85rem;
    height: 2.85rem;
    border-radius: 50%;
    background: var(--color-brand);
    color: var(--color-brand-contrast);
    box-shadow: var(--shadow-2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.to-top:hover {
    background: var(--color-brand-dark);
    color: var(--color-brand-contrast);
    text-decoration: none;
}

/* ---------- Auth & account pages --------------------------------------- */

.auth-card {
    max-width: 26rem;
    margin: 0 auto;
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
}

.auth-card__title {
    margin-bottom: var(--space-4);
}

.auth-card__footer {
    margin: var(--space-4) 0 0;
    font-size: 0.9rem;
}

.page-back {
    margin-top: var(--space-6);
}

.definition-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4em var(--space-4);
    margin: 0;
}

.definition-list dt {
    font-weight: 700;
    color: var(--color-text-muted);
}

.definition-list dd {
    margin: 0;
}

/* ---------- Responsive ------------------------------------------------- */

@media (max-width: 1080px) {
    .layout__grid--with-sidebar {
        grid-template-columns: minmax(0, 1fr) 15rem;
        gap: var(--space-5);
    }
}

@media (max-width: 900px) {
    .layout__grid--with-sidebar {
        grid-template-columns: minmax(0, 1fr);
    }

    .layout__sidebar {
        position: static;
    }

    /* Section navigation is already in the drawer on small screens; the
       sidebar keeps only the extras (table of contents, info boxes). */
    .layout__sidebar .widget--section-nav {
        display: none;
    }
}

@media (max-width: 780px) {
    .nav-toggle {
        display: inline-flex;
    }

    .site-header__inner {
        min-height: 3.9rem;
    }

    .site-brand img {
        max-height: 2.4rem;
    }

    /* The primary navigation becomes an off-canvas drawer. */
    .primary-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        width: min(21rem, 88vw);
        padding: var(--space-5) var(--space-4) var(--space-6);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--color-surface);
        border-left: 1px solid var(--color-border);
        box-shadow: var(--shadow-3);
        transform: translateX(100%);
        transition: transform 0.22s ease;
    }

    .primary-nav.is-open {
        transform: translateX(0);
    }

    .primary-nav__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        margin-bottom: var(--space-4);
        padding-bottom: var(--space-3);
        border-bottom: 1px solid var(--color-border);
    }

    .primary-nav__heading {
        margin: 0;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--color-text-muted);
    }

    .primary-nav__close {
        width: 2.4rem;
        height: 2.4rem;
        padding: 0;
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius);
        background: var(--color-surface);
        color: var(--color-text);
        font-size: 1.2rem;
        line-height: 1;
        cursor: pointer;
    }

    .primary-nav__list {
        display: block;
    }

    .primary-nav__item {
        position: static;
        border-bottom: 1px solid var(--color-border);
    }

    .primary-nav__row {
        display: flex;
        align-items: stretch;
    }

    .primary-nav__link {
        flex: 1 1 auto;
        padding: 0.85em 0.4em;
        border-radius: 0;
        white-space: normal;
    }

    .primary-nav__item--current > .primary-nav__row > .primary-nav__link {
        color: var(--color-brand);
    }

    .primary-nav__item--current > .primary-nav__row > .primary-nav__link::after {
        display: none;
    }

    /* The accordion button carries the caret in the drawer, so the one inside
       the link would only duplicate it. */
    .primary-nav__link .primary-nav__caret {
        display: none;
    }

    /* Accordion toggle for sub-pages */
    .primary-nav__expand {
        flex: 0 0 auto;
        width: 2.9rem;
        border: 0;
        border-left: 1px solid var(--color-border);
        background: transparent;
        color: var(--color-text-muted);
        cursor: pointer;
    }

    .primary-nav__expand .primary-nav__caret {
        width: 0.85rem;
        height: 0.85rem;
        margin: 0 auto;
        transition: transform 0.18s ease;
    }

    .primary-nav__expand[aria-expanded="true"] .primary-nav__caret {
        transform: rotate(180deg);
    }

    .primary-nav__sublist {
        position: static;
        min-width: 0;
        margin: 0 0 var(--space-3);
        padding: 0 0 0 var(--space-3);
        border: 0;
        border-left: 2px solid var(--color-brand);
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
        display: none;
    }

    .primary-nav__sublist::before {
        display: none;
    }

    .primary-nav__item.is-expanded > .primary-nav__sublist {
        display: block;
    }

    .primary-nav__sublink {
        padding: 0.6em 0.5em;
    }

    .primary-nav__drawer-search {
        margin-bottom: var(--space-4);
    }

    .primary-nav__drawer-search .searchbox {
        max-width: none;
    }

    .utility-bar__inner {
        justify-content: center;
    }

    .utility-bar .searchbox {
        display: none;
    }

    .hero {
        padding-block: var(--space-5) var(--space-6);
    }

    .layout {
        padding-block: var(--space-5) var(--space-6);
    }

    .content-figure--right,
    .content-figure--left,
    .info-box {
        float: none;
        width: 100%;
        max-width: none;
        margin-inline: 0;
    }

    .data-table thead th {
        position: static;
    }

    .site-footer__inner {
        flex-direction: column;
        text-align: center;
    }
}

@media (min-width: 781px) {
    .primary-nav__header,
    .primary-nav__drawer-search,
    .primary-nav__expand {
        display: none;
    }
}

@media print {
    .utility-bar,
    .site-header,
    .layout__sidebar,
    .prefooter,
    .to-top,
    .breadcrumbs {
        display: none !important;
    }

    body {
        color: #000;
        background: #fff;
    }

    .hero {
        background: none;
        color: #000;
        padding-block: 0 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
