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

:root {
    /* Palette — design/spritjakt_palette.txt */
    --indigo: #25283d;
    --grape: #8f3985;
    --frost: #98dfea;
    --sea: #07beb8;
    --petal: #efd9ce;

    --bg: var(--indigo);
    --surface: #2c2f48;
    --surface-2: #343756;
    --text: var(--petal);
    --muted: rgba(239, 217, 206, 0.62);
    --line: rgba(239, 217, 206, 0.12);
    --accent: var(--sea);
    --accent-2: var(--frost);
    --deco: var(--grape);
    --up: var(--sea);
    --down: #d77fcb; /* grape lifted for contrast on indigo */
    --signal: #ef4444; /* off-palette, reserved for destructive/reset actions */

    --radius: 10px;
    --wrap: 1200px;
    --header-h: 80px;
    --font-head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

input::placeholder { color: var(--muted); font-style: italic; }

/* ── Header ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: rgba(37, 40, 61, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 2px solid var(--deco);
}

.site-header .wrap { display: flex; align-items: center; height: 100%; gap: 40px; }

.logo img { height: 56px; display: block; }

.main-nav { display: flex; gap: 24px; flex: 1; }

.main-nav a {
    font-family: var(--font-head);
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text);
    padding: 6px 4px;
}

.main-nav a:hover { color: var(--accent); }
.main-nav a.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.main-nav a.soon { color: var(--muted); pointer-events: none; }
.main-nav a.soon::after { content: 'snart'; font-size: 0.6em; margin-left: 4px; vertical-align: super; color: var(--down); }

.lang-toggle { background: none; border: 0; cursor: pointer; padding: 4px; display: flex; }
.lang-toggle img { width: 28px; height: 18px; border-radius: 3px; object-fit: cover; opacity: 0.85; }
.lang-toggle:hover img { opacity: 1; }

/* ── Hero ── */
.hero {
    padding: 104px 0 96px;
    text-align: center;
    /* Drop a photo in img/hero.jpg and add it as the first layer here */
    background:
        radial-gradient(ellipse at 85% 20%, rgba(143, 57, 133, 0.55), transparent 55%),
        radial-gradient(ellipse at 10% 90%, rgba(7, 190, 184, 0.22), transparent 50%),
        var(--bg);
    background-attachment: fixed;
    border-bottom: 1px solid var(--line);
}

.hero h1 { font-size: clamp(2.8rem, 7vw, 5.4rem); text-transform: uppercase; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { font-family: var(--font-head); font-size: 1.6rem; font-weight: 500; line-height: 1.3; color: var(--muted); max-width: 60ch; margin: 22px auto 0; }

.search-wrap { max-width: 720px; margin: 56px auto 0; }

.search-form { display: flex; gap: 10px; }

.search-form input {
    flex: 1;
    padding: 18px 20px;
    font: inherit;
    font-size: 1.15rem;
    color: var(--text);
    background: rgba(239, 217, 206, 0.07);
    border: 2px solid var(--accent-2);
    border-radius: var(--radius);
    box-shadow: 0 0 0 4px rgba(152, 223, 234, 0.12), 0 8px 24px rgba(0, 0, 0, 0.25);
}

.search-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 5px rgba(7, 190, 184, 0.25); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-family: var(--font-head);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--indigo);
    background: var(--accent);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

.btn:hover { background: var(--accent-2); color: var(--indigo); }
.search-btn { padding: 0 24px; }

.browse-link { display: block; text-align: right; margin-top: 12px; font-weight: 500; }

/* ── Sections ── */
.section { padding: 80px 0; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 40px; padding-left: 12px; }
.section-head h2 { font-size: 2.8rem; text-transform: uppercase; }
.section-head h2::before { content: ''; display: inline-block; width: 7px; height: 0.8em; background: var(--deco); margin-right: 16px; border-radius: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ── Top 15 boards ── */
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }

.board-title { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 24px; border-bottom: 2px solid var(--deco); }
.board-title h3 { font-size: 1.6rem; text-transform: uppercase; }
.board-title span { font-size: 0.8rem; color: var(--muted); }

.board ol { list-style: none; }

.board li {
    display: grid;
    grid-template-columns: 2.2em 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 14px 24px 14px 14px;
    border-bottom: 1px solid var(--line);
}

.board li:last-child { border-bottom: 0; }
.board li:hover { background: var(--surface-2); }

.board .pos { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; line-height: 1; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.board li:nth-child(-n+3) .pos { color: var(--accent-2); }

.board .name { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); font-size: 1.05rem; font-weight: 500; }
.board .name:hover { color: var(--accent); }
.board .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .flag, .board .type { font-size: 1.3rem; flex-shrink: 0; }

.board .apk { color: var(--accent); font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.more-link { display: block; text-align: right; margin-top: 16px; font-weight: 600; }

/* ── Reigning champions ── */
.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; }

.badge {
    flex: 0 1 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 22px 24px;
    color: var(--text);
    border: 3px solid transparent;
    border-radius: 14px;
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(135deg, var(--frost), var(--sea) 35%, var(--grape) 70%, var(--frost)) border-box;
    box-shadow: 0 0 24px rgba(7, 190, 184, 0.18), 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.badge:hover { color: var(--text); transform: translateY(-3px); box-shadow: 0 0 32px rgba(7, 190, 184, 0.35), 0 14px 34px rgba(0, 0, 0, 0.35); }
.badge-emoji { font-size: 2.6rem; line-height: 1; }
.badge-cat { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2); margin-top: 12px; }
.badge-name { font-size: 1.15rem; font-weight: 600; margin-top: 8px; }
.badge-stats { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 16px; color: var(--muted); }
.badge-stats span:first-child { font-size: 1.6rem; }
.badge-stats b { color: var(--accent); font-size: 1.5rem; font-variant-numeric: tabular-nums; }

/* ── APK explainer ── */
.apk-explainer { display: grid; grid-template-columns: 3fr 2fr; gap: 56px; align-items: start; padding-left: 12px; }
.apk-explainer p { color: var(--muted); font-size: 1.05rem; margin-bottom: 16px; max-width: 62ch; }
.formula { font-family: ui-monospace, Consolas, monospace; font-size: 1rem; padding: 14px 16px; background: var(--surface); border-left: 3px solid var(--accent); border-radius: 4px; margin-bottom: 16px; color: var(--accent-2); width: fit-content; }

.apk-ref { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.apk-ref caption { text-align: left; color: var(--muted); padding-bottom: 10px; }
.apk-ref th { font-family: var(--font-head); font-size: 1.1rem; text-transform: uppercase; text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--deco); }
.apk-ref td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 1.05rem; }
.apk-ref td:first-child { color: var(--accent); font-weight: 700; }

/* ── News ── */
.news { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.news li { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--deco); border-radius: var(--radius); }
.news time { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--down); font-weight: 600; }
.news h3 { font-size: 1.35rem; margin: 4px 0 6px; }
.news p { color: var(--muted); }

/* ── Footer ── */
.site-footer { background: #1e2033; border-top: 2px solid var(--deco); padding: 56px 0 28px; font-size: 0.85rem; color: var(--muted); }
.footer-brand { display: block; height: 72px; margin: 0 auto 40px; }
.footer-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.footer-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; color: var(--muted); }
.footer-card:hover { color: var(--text); }
.footer-card img { height: 44px; max-width: 100%; object-fit: contain; }
.footer-bottom { margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; }

/* ── Toplist page ── */
.list-page { padding-bottom: 72px; }
.page-head { padding: 44px 0 24px; }
.page-head h1 { font-size: 2.8rem; text-transform: uppercase; }
.page-head p { color: var(--muted); }

.filter-bar { padding: 20px; margin-bottom: 20px; }
.filter-row { display: flex; gap: 12px; }
.filter-row input { flex: 1; padding: 14px 16px; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.filter-row input:focus { outline: none; border-color: var(--accent); }

.filter-toggle { width: 54px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.filter-toggle img { width: 26px; height: 26px; filter: invert(1); opacity: 0.8; } /* black icon → light */
.filter-toggle:hover, .filter-toggle[aria-expanded="true"] { border-color: var(--accent); }
.filter-toggle.has-filter { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(7, 190, 184, 0.25); }

.filter-panel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; padding: 24px 4px 4px; }
.filter-panel[hidden] { display: none; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-family: var(--font-head); font-size: 1.05rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-2); }
.filter-group .filter-label:not(:first-child) { margin-top: 10px; }
.filter-group label { cursor: pointer; padding: 2px 0; }
.filter-group input[type="checkbox"] { accent-color: var(--accent); margin-right: 8px; }
.filter-group select, .range-filter input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.range-filter { display: flex; align-items: center; gap: 8px; }
.range-filter input { width: 90px; }
.filter-clear-btn { margin-top: auto; align-self: flex-start; padding: 8px 18px; font: inherit; font-weight: 600; color: var(--signal); background: none; border: 1px solid var(--signal); border-radius: 6px; cursor: pointer; }
.filter-clear-btn:hover { color: var(--text); background: var(--signal); }

/* overflow: clip (not hidden) so the sticky header cells still stick to the viewport */
.table-container { overflow: clip; }

.pagination-container { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: var(--muted); }
.pagination-controls { display: flex; gap: 6px; }
.page-btn { min-width: 36px; padding: 6px 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.page-btn:hover { border-color: var(--accent); }
.page-btn.active { background: var(--accent); color: var(--indigo); border-color: var(--accent); font-weight: 700; }

/* Scoped to .products so other tables (e.g. .apk-ref) don't inherit the sticky header */
.products { width: 100%; border-collapse: collapse; table-layout: fixed; }
.products th:nth-child(1), .products td:nth-child(1) { width: 80px; }
.products th:nth-child(2), .products td:nth-child(2) { width: 110px; }
.products th:nth-child(4), .products td:nth-child(4) { width: 90px; }
.products th:nth-child(5), .products td:nth-child(5) { width: 112px; }
.products th:nth-child(6), .products td:nth-child(6) { width: 112px; }
.products th:nth-child(7), .products td:nth-child(7) { width: 112px; }

.products th { position: sticky; top: var(--header-h); z-index: 10; background: var(--grape); padding: 12px 10px; white-space: nowrap; text-align: left; font-family: var(--font-head); font-size: 1.05rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; user-select: none; }
.products th.sorted-asc::after { content: ' \2191'; color: var(--frost); }
.products th.sorted-desc::after { content: ' \2193'; color: var(--frost); }
.apk-unit { font-family: var(--font-body); font-size: 0.7em; font-weight: 400; color: rgba(239, 217, 206, 0.8); text-transform: none; }

.products td { padding: 14px 10px; border-bottom: 1px solid var(--line); font-size: 0.98rem; vertical-align: middle; }
.products tbody tr:hover { background: var(--surface-2); }

.rank { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-number { display: inline-block; width: 3em; text-align: right; margin-right: 4px; }
.rank-1 .rank-number, .rank-2 .rank-number, .rank-3 .rank-number { color: var(--accent-2); }
.rank-up, .rank-down { font-size: 0.6em; vertical-align: middle; }
.rank-up { color: var(--up); }
.rank-down { color: var(--down); }

.apk-value { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.price-value { font-variant-numeric: tabular-nums; }

.product-cell > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.country-flag { font-size: 1.4em; }
.product-link { color: var(--text); font-weight: 500; }
.product-link:hover { color: var(--accent); }
.type-detailed { font-size: 0.8em; color: var(--muted); }

.indicators-column { text-align: right; white-space: nowrap; }
.label-logo { height: 1.3em; vertical-align: middle; margin-left: 2px; }
.label-badge, .source-icon { margin-left: 2px; }

.mobile-info { width: 100%; font-size: 0.82em; color: var(--muted); }
.mobile-type-detailed { display: block; }
.no-results, .loading { text-align: center; padding: 40px !important; color: var(--muted); }

/* ── Responsive ── */
@media (max-width: 900px) {
    .boards, .apk-explainer, .news, .footer-cards { grid-template-columns: 1fr; }
    .filter-panel { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    :root { --header-h: 64px; }
    .site-header .wrap { gap: 16px; }
    .logo img { height: 40px; }
    .main-nav { gap: 12px; overflow-x: auto; }
    .main-nav a { font-size: 1rem; }
    .main-nav a.soon { display: none; }
    .hero { padding: 56px 0 48px; background-attachment: scroll; }
    .hero .lede { font-size: 1.3rem; }
    .search-wrap { margin-top: 36px; }
    .section { padding: 56px 0; }
    .section-head h2 { font-size: 2.1rem; }
    .board li { padding: 12px 16px 12px 8px; gap: 12px; }
    .board .pos { font-size: 1.5rem; }
    .filter-panel { grid-template-columns: 1fr; }

    .products th:nth-child(4), .products td:nth-child(4),
    .products th:nth-child(5), .products td:nth-child(5),
    .products th:nth-child(6), .products td:nth-child(6),
    .products th:nth-child(7), .products td:nth-child(7),
    .type-detailed, .pagination-container { display: none; }
    .products th:nth-child(1), .products td:nth-child(1) { width: 60px; }
    .products th:nth-child(2), .products td:nth-child(2) { width: 76px; }
}
