/* ===== DESIGN TOKENS ===== */
:root {
    --color-bg: #faf8f5;
    --color-surface: #ffffff;
    --color-ink: #1a1a1a;
    --color-ink-muted: #55524c;
    --color-border: #e0dcd3;
    --color-accent: #0b5394;
    --color-accent-hover: #083f70;
    --color-active: #1f7a4d;
    --color-inactive: #b3261e;
    --color-local: #6b3fa0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-ink);
    line-height: 1.6;
}

a {
    color: var(--color-accent);
}

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

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

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

.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;
    left: -9999px;
    top: 0;
    background: var(--color-accent);
    color: white;
    padding: 0.75rem 1rem;
    z-index: 100;
}

.skip-link:focus {
    left: 0;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 20px 10px;
}

header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0;
    padding-bottom: 0;
}

.brand {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-ink);
    text-decoration: none;
}

.site-nav {
    display: flex;
    gap: 1.25rem;
}

.site-nav a {
    color: var(--color-ink-muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.site-nav a:hover {
    color: var(--color-accent);
}

h1 {
    font-size: 2rem;
    font-weight: 300;
}

footer {
    background: var(--color-ink);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

footer a {
    color: #9ec7ec;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ===== INFO BOX ===== */
.info-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    color: var(--color-ink);
}

.info-box h2 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--color-ink);
}

.info-box p {
    margin: 0;
    line-height: 1.6;
}

/* ===== STATS SECTION ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 20px;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    font: inherit;
    color: inherit;
    width: 100%;
}

.stat-card:hover {
    border-color: var(--color-accent);
}

.stat-card[aria-pressed="true"] {
    background: var(--color-ink);
    border-color: var(--color-ink);
}

.stat-card[aria-pressed="true"] .stat-number,
.stat-card[aria-pressed="true"] .stat-label {
    color: white;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-accent);
}

.stat-label {
    display: block;
    color: var(--color-ink-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ===== CONTROLS SECTION ===== */
.controls {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 300px;
}

input[type="text"],
input[type="search"],
select {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
    color: var(--color-ink);
    background: var(--color-surface);
}

input[type="text"],
input[type="search"] {
    width: 100%;
    padding-right: 2.5rem;
}

select {
    cursor: pointer;
}

.clear-search {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-ink-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: none;
    align-items: center;
    justify-content: center;
}

.clear-search.visible {
    display: flex;
}

/* ===== FILTER MESSAGES ===== */
#siteCount {
    color: var(--color-ink-muted);
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
}

#filterMessage {
    color: var(--color-ink-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

#filterMessage a {
    cursor: pointer;
}

/* ===== BADGES ===== */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #ecf0f1;
    color: #444;
    font-size: 0.8rem;
}

.badge.active {
    background: var(--color-active);
    color: white;
}

.badge.inactive {
    background: var(--color-inactive);
    color: white;
}

.badge.local {
    background: var(--color-local);
    color: white;
}

/* ===== SITES GRID ===== */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

.site-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.site-thumb-link {
    display: block;
}

.site-screenshot {
    width: 100%;
    aspect-ratio: 340 / 172;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: #ecf0f1;
    display: block;
    border: none;
}

.site-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-ink);
}

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

.site-name a:hover {
    text-decoration: underline;
}

.site-description {
    color: var(--color-ink-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.site-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
}

/* ===== EXTERNAL LINKS ===== */
.site-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.site-link-external {
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.site-link-external:hover {
    text-decoration: underline;
}

.external-icon {
    font-size: 0.75rem;
    color: var(--color-ink-muted);
}

/* ===== DETAIL PAGE STYLES ===== */
.detail-page {
    max-width: 960px;
    margin: 0 auto;
}

.breadcrumb {
    margin-bottom: 1rem;
    color: var(--color-ink-muted);
    font-size: 0.9rem;
}

.detail-header {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.detail-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-ink);
    margin-bottom: 0.25rem;
    text-align: left;
}

.detail-url {
    margin-bottom: 1rem;
}

.detail-url a {
    font-size: 1rem;
    text-decoration: none;
}

.detail-url a:hover {
    text-decoration: underline;
}

.inactive-note {
    background: #fbeceb;
    color: var(--color-inactive);
    border: 1px solid #f3c9c6;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.detail-desc {
    color: var(--color-ink-muted);
    line-height: 1.7;
    margin-bottom: 1rem;
}

.detail-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-primary {
    background: var(--color-accent);
    color: white;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    color: white;
}

.btn-secondary {
    background: #ecf0f1;
    color: var(--color-ink);
}

.btn-secondary:hover {
    background: #d5dbdb;
    color: var(--color-ink);
}

.btn-bluesky {
    background: #0085FF;
    color: white;
}

.btn-bluesky:hover {
    background: #006dd6;
    color: white;
}

.detail-screenshot-wrap {
    margin-bottom: 1.5rem;
}

.detail-screenshot {
    width: 100%;
    max-width: 340px;
    aspect-ratio: 340 / 172;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    display: block;
}

.detail-archive {
    margin-bottom: 1.5rem;
}

/* Older shots share one row evenly, however many there are. */
.detail-archive-row {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.detail-archive-item {
    display: block;
}

.detail-archive-row .detail-archive-item {
    flex: 1;
    min-width: 0;
}

.detail-archive-item figure {
    margin: 0;
}

.detail-archive-item img {
    width: 100%;
    aspect-ratio: 340 / 172;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    display: block;
    background: #ecf0f1;
}

.detail-archive-item figcaption {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--color-ink-muted);
    text-align: center;
}

.detail-meta {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 1.5rem 2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.detail-meta dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.6rem 1.5rem;
    margin: 0;
    align-items: baseline;
}

.detail-meta dt {
    font-weight: 600;
    color: var(--color-ink-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.detail-meta dd {
    margin: 0;
    color: var(--color-ink);
}

.detail-meta dd a {
    text-decoration: none;
}

.detail-meta dd a:hover {
    text-decoration: underline;
}

.detail-provenance {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--color-ink-muted);
    padding-bottom: 1rem;
}

.detail-provenance-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.7rem;
}

.detail-provenance-tag {
    background: #f0f0f0;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.75rem;
    color: #555;
}

/* ===== PREV/NEXT + RELATED SITES ===== */
.detail-pagenav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.detail-pagenav-next {
    margin-left: auto;
    text-align: right;
}

.related-sites {
    padding-top: 1.5rem;
}

.related-sites h2 {
    font-size: 1rem;
    color: var(--color-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.related-sites-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.related-sites-list a {
    text-decoration: none;
    font-size: 0.9rem;
}

.related-sites-list a:hover {
    text-decoration: underline;
}

/* ===== 404 PAGE ===== */
.not-found {
    text-align: center;
    padding: 4rem 20px;
}

.not-found h1 {
    font-size: 3rem;
    color: var(--color-inactive);
    margin-bottom: 1rem;
}

.not-found h2 {
    color: var(--color-ink);
    margin-bottom: 0.5rem;
}

.not-found p {
    color: var(--color-ink-muted);
    margin-bottom: 2rem;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .info-box {
        padding: 0.5rem 0.75rem;
    }

    .info-box h2 {
        font-size: 0.9rem;
    }

    .info-box p {
        font-size: 0.85rem;
    }

    .stats {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 0.4rem;
    }

    .stat-card {
        padding: 0.4rem 0.25rem;
    }

    .stat-number {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.65rem;
        line-height: 1.1;
        min-height: 2.2em;
    }

    .controls {
        padding: 0.75rem;
        gap: 0.5rem;
        margin-bottom: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        min-width: 0;
    }

    #filterSelect,
    #sortSelect {
        width: 100%;
    }

    .detail-meta dl {
        grid-template-columns: 1fr;
    }

    .detail-meta dt {
        margin-top: 0.5rem;
    }

    .detail-meta dt:first-child {
        margin-top: 0;
    }

    .detail-header {
        padding: 1.25rem;
    }

    .detail-archive-row {
        flex-direction: column;
    }
}
