/* ============================================================
   IndexAll - Static Site Stylesheet
   Clean light theme on white. Warm, airy, refined.
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-alt: #fafafa;
    --bg-hover: #f5f5f7;
    --bg-card: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #1d1d1f;
    --text-tertiary: #444446;
    --border: #e8e8ed;
    --border-light: #f2f2f5;
    --accent: #0066cc;
    --accent-hover: #0055aa;
    --accent-light: #e8f1fb;
    --link: #0066cc;
    --tag-bg: #ffffff;
    --tag-text: #1d1d1f;
    --tag-border: #1d1d1f;
    --tag-active-bg: #1d1d1f;
    --tag-active-text: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 10px;
    --radius-sm: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    --max-width: 1200px;
    --header-height: 56px;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

img { max-width: 100%; height: auto; }

/* --- Header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    text-decoration: none;
}

.site-logo:hover { text-decoration: none; opacity: 0.7; }

.site-logo span {
    font-weight: 300;
    color: var(--text-tertiary);
}

.header-stats {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* --- Layout --- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

main {
    flex: 1;
    padding: 2.5rem 0;
}

/* --- Page header --- */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.page-header .icon {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--text-tertiary);
    transition: color 0.15s;
}

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

.breadcrumbs .sep {
    margin: 0 0.4rem;
    opacity: 0.4;
}

/* --- Search / Filter bar --- */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 0.85rem;
    padding-left: 2.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.filter-select {
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23aeaeb2' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.result-count {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.clear-filters {
    font-size: 0.8rem;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    display: none;
    transition: background 0.15s;
}

.clear-filters:hover {
    background: var(--accent-light);
}

.clear-filters.visible {
    display: inline-block;
}

/* --- Index grid (homepage) --- */
.index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.5rem;
}

.index-card {
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.15s ease;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.index-card:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.index-card .card-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    width: 2.2rem;
    text-align: center;
}

.index-card .card-info {
    flex: 1;
    min-width: 0;
}

.index-card .card-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--text);
}

.index-card .card-count {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.index-card .card-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.index-card:hover .card-arrow {
    opacity: 1;
    transform: translateX(2px);
}

.index-card.empty {
    opacity: 0.4;
}

.index-card.empty:hover {
    opacity: 0.65;
}

/* --- Group sections on homepage --- */
.index-group {
    margin-bottom: 2.5rem;
}

.group-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.group-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.group-header .group-count {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* --- Items table --- */
.items-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

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

.items-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    transition: color 0.15s;
}

.items-table th:hover {
    color: var(--text);
}

.items-table th .sort-indicator {
    margin-left: 0.3rem;
    opacity: 0.4;
    font-size: 0.7rem;
}

.items-table th.sorted .sort-indicator {
    opacity: 1;
    color: var(--accent);
}

.items-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.items-table tr:last-child td {
    border-bottom: none;
}

.items-table tbody tr {
    transition: background 0.1s;
}

.items-table tbody tr:hover {
    background: var(--bg-hover);
}

.items-table .item-name {
    font-weight: 600;
    white-space: nowrap;
}

.items-table .item-name a {
    color: var(--text);
    transition: color 0.15s;
}

.items-table .item-name a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.items-table .item-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.items-table .item-website a {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    word-break: break-all;
    transition: color 0.15s;
}

.items-table .item-website a:hover {
    color: var(--accent);
}

.items-table .item-country {
    white-space: nowrap;
    font-size: 0.85rem;
}

.items-table .item-year {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* --- Social icons --- */
.social-links {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: color 0.15s, background 0.15s;
}

.social-links a:hover {
    color: var(--accent);
    background: var(--accent-light);
    text-decoration: none;
}

.social-links svg {
    width: 14px;
    height: 14px;
}

/* --- Tags --- */
.tags {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid var(--tag-border);
    border-radius: 999px;
    font-size: 0.75rem;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.15s ease;
}

a.tag:hover {
    background: var(--tag-active-bg);
    color: var(--tag-active-text);
    border-color: var(--tag-active-bg);
    text-decoration: none;
}

.tag.active {
    background: var(--tag-active-bg);
    color: var(--tag-active-text);
    border-color: var(--tag-active-bg);
}

/* --- Tag filter bar (category page) --- */
.tag-filters {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.tag-filters .tag {
    cursor: pointer;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 0.95rem;
}

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-top: auto;
    background: var(--bg-alt);
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.site-footer a {
    color: var(--text-tertiary);
    transition: color 0.15s;
}

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

/* --- No-results row in table --- */
.no-results-row td {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    html { font-size: 14px; }

    .container { padding: 0 1rem; }

    main { padding: 1.5rem 0; }

    .page-header h1 { font-size: 1.4rem; }

    .index-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .search-wrapper {
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .items-table .item-desc {
        display: none;
    }

    .items-table th, .items-table td {
        padding: 0.5rem 0.65rem;
    }

    .site-footer .container {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .index-card {
        padding: 0.75rem 1rem;
    }

    .social-links a {
        width: 24px;
        height: 24px;
    }

    .social-links svg {
        width: 12px;
        height: 12px;
    }
}

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

/* --- Print --- */
@media print {
    .site-header, .site-footer, .filter-bar, .tag-filters { display: none; }
    .items-table { font-size: 0.8rem; }
    .items-table th { background: none; }
}
