/*
 * Shared chrome for both pages: reset, layout container, header, footer,
 * form controls, panels, tables and the vanilla replacements for the three
 * Materialize widgets we actually used (toast, tooltip, preloader).
 */

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

img {
    max-width: 100%;
}

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

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

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 500;
    line-height: 1.25;
}

/* Materialize utility class, kept by name because page_status() toggles it. */
.hide {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.container {
    width: min(100% - 2rem, 1200px);
    margin-inline: auto;
}

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

/* header */

.site-header {
    /* the ring has to survive a red background */
    --focus: #fff;
    background: var(--header-bg);
    color: var(--header-text);
    padding-block: clamp(.6rem, 1.6vw, 1rem);
}

.header-grid {
    display: grid;
    gap: clamp(1rem, 3vw, 2rem);
    grid-template-columns: 1fr;
    align-items: center;
}

@media (min-width: 62rem) {
    .header-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.header-utility {
    display: flex;
    justify-content: flex-end;
    margin-bottom: .25rem;
}

.header-brand {
    display: block;
    text-align: center;
}

/* the stats page has no logo, so its header is a single title bar */
.header-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-bar h1 {
    font-size: clamp(1.15rem, 3.5vw, 1.6rem);
    text-transform: uppercase;
    letter-spacing: .02em;
}

.header-bar a {
    color: inherit;
}

.sci-logo {
    width: clamp(96px, 18vw, 148px);
}

.header-main h1 {
    font-size: clamp(1.25rem, 3.5vw, 1.75rem);
    text-transform: uppercase;
    letter-spacing: .02em;
}

.header-main p {
    margin: .35rem 0 .85rem;
    color: var(--header-muted);
    font-size: .95rem;
}

/* search field */

.search {
    display: flex;
    gap: .5rem;
    max-width: 34rem;
}

.search input {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    color: var(--header-text);
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: var(--radius-sm);
    padding: .6rem .75rem;
}

.search input::placeholder {
    color: rgba(255, 255, 255, .65);
}

.search input:focus {
    background: rgba(255, 255, 255, .2);
    border-color: #fff;
    outline: none;
}

.search input:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

/* buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font: inherit;
    font-weight: 500;
    line-height: 1;
    padding: .65rem 1.1rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--on-accent);
    cursor: pointer;
    text-transform: uppercase;
    font-size: .8rem;
    letter-spacing: .04em;
    transition: background var(--speed) ease;
}

.btn:hover {
    background: var(--accent-strong);
    color: var(--on-accent);
}

.btn svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
}

.btn-icon {
    padding: .65rem .8rem;
}

/* theme toggle */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font: inherit;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: inherit;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    padding: .4rem .75rem;
    cursor: pointer;
    transition: background var(--speed) ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, .26);
}

.theme-toggle svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

/* panels and cards */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}

.section-head h2 {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    text-transform: uppercase;
    letter-spacing: .02em;
}

/* tables. A container query drives the stack, so the breakpoint follows the
   table's own box rather than the viewport. */

.table-wrap {
    container-type: inline-size;
    container-name: tablewrap;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

thead th {
    text-align: left;
    padding: .75rem 1rem;
    font-size: .75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

tbody tr:hover {
    background: var(--surface-hover);
}

.cell-center {
    text-align: center;
}

.thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    /* stored thumbnail URLs go stale. A broken one is an empty circle (ui.js swaps in
       a blank image), never its alt text -- the title, shown in the next cell anyway --
       spilling across the row */
    overflow: hidden;
    color: transparent;
    font-size: 0;
    background: var(--surface-2);
}

@container tablewrap (max-width: 46rem) {
    thead {
        display: none;
    }

    tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: .25rem;
        padding: .85rem 1rem;
        border-bottom: 1px solid var(--border);
    }

    tbody tr:last-child {
        border-bottom: 0;
    }

    tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .15rem 0;
        border: 0;
    }

    tbody td[data-label]::before {
        content: attr(data-label);
        font-size: .7rem;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-subtle);
    }
}

/* footer */

.page-footer {
    --focus: #fff;
    margin-top: auto;
    background: var(--footer-bg);
    color: var(--footer-text);
}

.footer-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1.75rem;
}

.footer-top img {
    max-height: 40px;
}

.footer-top p {
    margin: .5rem 0 0;
    color: var(--footer-muted);
    font-size: .9rem;
}

.footer-copyright {
    border-top: 1px solid rgba(255, 255, 255, .2);
    font-size: .85rem;
    color: var(--footer-muted);
}

.footer-copyright .container {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    justify-content: space-between;
    padding-block: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
}

.page-footer a {
    color: var(--footer-text);
}

.page-footer a:hover {
    color: #fff;
    text-decoration: underline;
}
