/* TSN hub filter bar + landing cards (CC52). Light by default; dark follows the theme's own switches. */
.hub {
    --hub-ink: #1f2937;
    --hub-muted: #5b6472;
    --hub-line: #d9dee6;
    --hub-surface: #fff;
    --hub-tint: #f3f6fb;
    --hub-accent: #2563eb;
    --hub-accent-ink: #fff;
    --hub-focus: #1d4ed8;
    --hub-free-bg: #dcfce7;
    --hub-free-ink: #166534;
    --hub-lab-bg: #e0e7ff;
    --hub-lab-ink: #3730a3;
    --hub-bar-h: 160px; /* height of the filter bar at this width: reserved before the script draws it, so nothing jumps */
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .hub {
        --hub-ink: #f3f4f6; --hub-muted: #a3aab6; --hub-line: #2e2e40; --hub-surface: #1e1e2b; --hub-tint: #252536;
        --hub-accent: #60a5fa; --hub-accent-ink: #0f172a; --hub-focus: #93c5fd;
        --hub-free-bg: #14532d; --hub-free-ink: #bbf7d0; --hub-lab-bg: #312e81; --hub-lab-ink: #c7d2fe;
    }
}
:root[data-theme="dark"] .hub {
    --hub-ink: #f3f4f6; --hub-muted: #a3aab6; --hub-line: #2e2e40; --hub-surface: #1e1e2b; --hub-tint: #252536;
    --hub-accent: #60a5fa; --hub-accent-ink: #0f172a; --hub-focus: #93c5fd;
    --hub-free-bg: #14532d; --hub-free-ink: #bbf7d0; --hub-lab-bg: #312e81; --hub-lab-ink: #c7d2fe;
}

.hub .hub-off { display: none !important; }
.hub.hub-filtered #calc-recent { display: none !important; }

/* filter bar. The slot keeps the bar's height before the script has drawn it (only where scripts run, so with JS off there is no gap). */
.hub [data-hub-bar] { margin: 0 0 32px; }
@media (scripting: enabled) { .hub [data-hub-bar] { min-height: var(--hub-bar-h); } }
.hub-bar {
    min-height: var(--hub-bar-h);
    align-content: start;
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(190px, 1.3fr) minmax(220px, 2fr);
    gap: 12px 16px;
    align-items: end;
    margin: 0;
    padding: 16px;
    background: var(--hub-tint);
    border: 1px solid var(--hub-line);
    border-radius: 12px;
}
.hub-field { display: grid; gap: 6px; min-width: 0; }
.hub-field label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hub-muted);
}
.hub-field select,
.hub-field input {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 8px 14px;
    font: inherit;
    font-size: 16px;
    color: var(--hub-ink);
    background-color: var(--hub-surface);
    border: 1px solid var(--hub-line);
    border-radius: 8px;
}
.hub-field select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}
.hub-field input::placeholder { color: var(--hub-muted); opacity: 1; }
.hub-field select:hover,
.hub-field input:hover { border-color: var(--hub-accent); }
.hub-field select:focus-visible,
.hub-field input:focus-visible,
.hub-clear:focus-visible,
.hub .hub-card a:focus-visible {
    outline: 3px solid var(--hub-focus);
    outline-offset: 2px;
}
.hub-bar-foot {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
}
.hub-count {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--hub-ink);
    font-variant-numeric: tabular-nums;
}
.hub-clear {
    min-height: 44px;
    padding: 6px 12px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--hub-accent);
    background: none;
    border: 0;
    border-radius: 8px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.hub-clear[hidden], .hub-empty[hidden] { display: none; }
.hub-clear-solid {
    padding: 8px 20px;
    color: var(--hub-accent-ink);
    background: var(--hub-accent);
    text-decoration: none;
}
.hub-empty {
    max-width: 520px;
    margin: 24px auto 48px;
    padding: 28px 20px;
    text-align: center;
    color: var(--hub-muted);
    border: 2px dashed var(--hub-line);
    border-radius: 16px;
}
.hub-empty p { margin: 0 0 14px; }

/* landing cards (Field Guides, Lab Reports) */
.hub .hub-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: 20px;
}
.hub .hub-card {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--hub-surface);
    border: 1px solid var(--hub-line);
    border-radius: 12px;
    transition: border-color 0.2s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.hub .hub-card::marker { content: none; }
.hub .hub-card:hover,
.hub .hub-card:focus-within {
    border-color: var(--hub-accent);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}
/* the covers are 4:5 portrait cards with their own headline: they sit beside the text at their natural ratio, never cropped */
.hub .hub-card-img {
    display: block;
    flex: 0 0 152px;
    width: 152px;
    height: auto;
    align-self: flex-start;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    background: var(--hub-tint);
    margin: 0;
    border-radius: 0;
}
.hub .hub-card-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; padding: 16px 18px 18px; }
.hub .hub-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.hub .hub-tag {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--hub-muted);
    background: var(--hub-tint);
    border-radius: 999px;
}
.hub .hub-tag-free { color: var(--hub-free-ink); background: var(--hub-free-bg); }
.hub .hub-tag-lab { color: var(--hub-lab-ink); background: var(--hub-lab-bg); }
.hub .hub-card-kicker { margin: 4px 0 0; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--hub-muted); }
.hub .hub-card-title { margin: 0; font-size: 20px; line-height: 1.25; }
.hub .hub-card-title a { color: var(--hub-ink); text-decoration: none; }
.hub .hub-card-title a::after { content: ""; position: absolute; inset: 0; }
.hub .hub-card:hover .hub-card-title a { color: var(--hub-accent); }
.hub .hub-card-desc {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--hub-muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    overflow: hidden;
}
.hub .hub-card-foot { margin: auto 0 0; font-size: 14px; font-weight: 600; }
.hub .hub-card-foot a { position: relative; z-index: 1; color: var(--hub-accent); }
.hub .hub-note { margin: 24px 0 0; font-size: 14px; color: var(--hub-muted); }

@media (max-width: 720px) {
    .hub { --hub-bar-h: 236px; }
    .hub-bar { grid-template-columns: 1fr 1fr; padding: 12px; }
    .hub-field-search { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
    .hub { --hub-bar-h: 316px; }
    .hub-bar { grid-template-columns: 1fr; }
    .hub .hub-card-img { flex-basis: 96px; width: 96px; }
    .hub .hub-card-body { padding: 12px 14px 14px; }
    .hub .hub-card-title { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    .hub .hub-card { transition: none; }
}
