.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 28px;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 400px;
}

.search .icon {
    position: absolute;
    left: 13px;
    color: var(--dim);
    pointer-events: none;
}

.search input {
    min-height: 42px;
    padding: 0 42px 0 38px;
}

.search input::-webkit-search-cancel-button {
    filter: invert(.7);
    cursor: pointer;
}

:root[data-theme="light"] .search input::-webkit-search-cancel-button {
    filter: none;
}

.search kbd {
    position: absolute;
    right: 11px;
    padding: 0 6px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--dim);
    font: inherit;
    font-size: .74rem;
    font-weight: 600;
    line-height: 1.6;
    pointer-events: none;
    transition: opacity .16s;
}

.search input:focus ~ kbd,
.search input:not(:placeholder-shown) ~ kbd {
    opacity: 0;
}

.directory {
    margin-top: 22px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.directory-sorts {
    gap: 4px;
    padding: 0;
    background: transparent;
}

.directory-sorts > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 11px;
}

.directory-sorts > a .icon {
    width: .95em;
    height: .95em;
    opacity: .75;
}

.directory-sorts > a:hover {
    background: var(--raised);
}

.directory-sorts > [aria-current] {
    color: var(--accent-strong);
    background: var(--accent-wash);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 6px 11px;
    border-radius: 6px;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 550;
    transition: color .16s, background-color .16s;
}

.chip:hover {
    color: var(--text);
    background: var(--raised);
}

.chip[aria-current] {
    color: var(--accent-strong);
    background: var(--accent-wash);
}

.directory .card-foot {
    flex-wrap: wrap;
    gap: 6px 9px;
}

/* The card graph sits on a faint tile. Pointing at it shows the count for that day. */
.spark-box {
    position: relative;
    display: flex;
    flex: 1 1 48px;
    min-width: 48px;
    max-width: 100px;
    margin-left: auto;
    padding: 4px 7px;
    border-radius: 6px;
    background: var(--spark-bg);
    cursor: crosshair;
    transition: background-color .16s;
}

.spark-box:hover {
    background: var(--spark-bg-hover);
}

.spark-box .spark {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.spark-dot {
    fill: currentColor;
    stroke: var(--surface);
    stroke-width: 1.5;
    opacity: 0;
    transition: opacity .12s;
}

.spark-box.is-active .spark-dot {
    opacity: 1;
}

/* Top-3 emblems: a small faceted crest in the cover's corner, gold, silver or bronze, with a light
   that crosses it now and then (first place also glows and twinkles, and wears a crown). On hover
   it flips like a coin, rays turn behind it, sparks burst out, and it opens into "#1 in Gaming".
   Still for anyone who asks for less motion. */
.rank-emblem {
    position: absolute;
    z-index: 2;
    top: 9px;
    right: 9px;
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 3px;
    border: 1px solid transparent;
    border-radius: 999px;
    transition: background-color .35s, border-color .35s, padding .45s var(--ease);
    --metal-a: #ffd43f;
    --metal-b: #fff6b8;
    --metal-edge: #8a5c00;
    --metal-ink: #5c3a00;
}

.cover > .rank-emblem { top: 14px; right: 14px; }

.rank-emblem.rank-2 { --metal-a: #dfe6ee; --metal-b: #ffffff; --metal-edge: #5f6b79; --metal-ink: #36404c; }
.rank-emblem.rank-3 { --metal-a: #f0a868; --metal-b: #ffe3c8; --metal-edge: #6b330d; --metal-ink: #431d06; }

.emblem-art {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    width: 26px;
    height: 28px;
}

.rank-1 .emblem-art { animation: emblem-glow 3.2s ease-in-out infinite; }

.emblem {
    position: relative;
    z-index: 1;
    width: 24px;
    height: 27px;
    overflow: visible;
    filter: drop-shadow(0 1px 2px rgb(0 0 0 / .55));
}

.emblem-face { fill: url(#emblem-gold); stroke: var(--metal-edge); stroke-width: 1.2; stroke-linejoin: round; }
.rank-2 .emblem-face { fill: url(#emblem-silver); }
.rank-3 .emblem-face { fill: url(#emblem-bronze); }
.emblem-facet-light { fill: #fff; opacity: .2; }
.emblem-facet-dark { fill: #000; opacity: .14; }
.emblem-inner { fill: none; stroke: rgb(255 255 255 / .55); stroke-width: .8; stroke-linejoin: round; }
.emblem-number { fill: var(--metal-ink); font-size: 11.5px; font-weight: 800; }
.emblem-crown { display: none; fill: url(#emblem-gold); stroke: var(--metal-edge); stroke-width: .7; stroke-linejoin: round; }
.rank-1 .emblem-crown { display: inline; }
.emblem-shine { transform-box: view-box; animation: emblem-shine 5s ease-in-out infinite; }
.rank-2 .emblem-shine { animation-delay: -1.7s; }
.rank-3 .emblem-shine { animation-delay: -3.4s; }

.emblem-rays {
    position: absolute;
    width: 46px;
    height: 46px;
    fill: none;
    stroke: var(--metal-a);
    stroke-width: 1.4;
    stroke-linecap: round;
    opacity: 0;
    transform: scale(.5);
    transition: opacity .35s, transform .45s var(--ease);
}

.emblem-spark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    fill: var(--metal-b);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0);
}

.s1 { --x: -22px; --y: -6px; --d: 0s; }
.s2 { --x: -15px; --y: 14px; --d: .06s; }
.s3 { --x: 3px; --y: 19px; --d: .12s; }
.s4 { --x: 17px; --y: 11px; --d: .04s; }
.s5 { --x: -27px; --y: 6px; --d: .15s; }
.s6 { --x: 11px; --y: -9px; --d: .09s; }

/* First place twinkles now and then, even at rest. */
.rank-1:not(:hover) .s6 { animation: emblem-twinkle 4.4s ease-in-out infinite 1s; }

.emblem-label {
    max-width: 0;
    overflow: hidden;
    color: #eef3f8;
    font-size: .74rem;
    font-weight: 650;
    white-space: nowrap;
    opacity: 0;
    transition: max-width .45s var(--ease), opacity .3s, margin .45s var(--ease);
}

.emblem-label b {
    background: linear-gradient(100deg, var(--metal-a) 20%, var(--metal-b) 45%, var(--metal-a) 70%);
    background-size: 220% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    font-weight: 800;
}

.rank-emblem:hover,
.card:focus-visible .rank-emblem {
    padding-left: 11px;
    border-color: color-mix(in srgb, var(--metal-a) 45%, transparent);
    background: rgb(11 12 16 / .85);
    backdrop-filter: blur(6px);
}

.rank-emblem:hover .emblem-label,
.card:focus-visible .emblem-label {
    max-width: 170px;
    margin-right: 6px;
    opacity: 1;
}

.rank-emblem:hover .emblem-label b { animation: emblem-text 2.6s linear infinite; }
.rank-emblem:hover .emblem { animation: emblem-flip .8s cubic-bezier(.34, 1.56, .64, 1); }
.rank-emblem:hover .emblem-rays { opacity: .85; transform: scale(1); animation: emblem-spin 9s linear infinite; }
.rank-emblem:hover .emblem-spark { animation: emblem-burst .9s ease-out var(--d) both; }

@keyframes emblem-glow {
    0%, 100% { filter: drop-shadow(0 0 0 rgb(255 207 58 / 0)); }
    50% { filter: drop-shadow(0 0 5px rgb(255 207 58 / .7)); }
}
@keyframes emblem-shine { 0%, 62% { transform: translateX(0); } 88%, 100% { transform: translateX(46px); } }
@keyframes emblem-flip { from { transform: perspective(70px) rotateY(0); } to { transform: perspective(70px) rotateY(360deg); } }
@keyframes emblem-spin { to { transform: scale(1) rotate(360deg); } }
@keyframes emblem-text { from { background-position: 100% 0; } to { background-position: -120% 0; } }
@keyframes emblem-burst {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.15) rotate(90deg); }
}
@keyframes emblem-twinkle {
    0%, 70%, 100% { opacity: 0; transform: translate(calc(-50% + 10px), calc(-50% - 10px)) scale(0); }
    82% { opacity: 1; transform: translate(calc(-50% + 10px), calc(-50% - 10px)) scale(1) rotate(45deg); }
}

@media (prefers-reduced-motion: reduce) {
    .rank-emblem *, .rank-emblem:hover * { animation: none !important; }
    .rank-emblem, .emblem-label, .emblem-rays { transition: none; }
    .rank-emblem:hover .emblem-rays { opacity: 0; }
}

/* Show 18+: off by default, kept in this browser. Sits at the end of the heading row. */
.adult-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 600;
}

.adult-switch label {
    cursor: pointer;
}

.results-head .text-link:not([hidden]) ~ .adult-switch {
    margin-left: 0;
}

/* The tag filters: one chip each, clicked or typed as #tag in the search. */
.tag-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-chips:empty {
    display: none;
}

/* "Show N new communities": waits next to the heading until the visitor wants them. */
.new-listings {
    margin-inline-start: 6px;
}

/* Its look is the site-wide tooltip rule in hub.css, the same as the charts'. */
.spark-tip {
    position: absolute;
    z-index: 2;
    bottom: calc(100% + 9px);
    left: var(--x, 50%);
    display: grid;
    justify-items: start;
    white-space: nowrap;
    opacity: 0;
    transform: translate(calc(-1 * var(--caret, 50%)), 3px);
    transition: opacity .12s, transform .12s;
}

.spark-box.is-active .spark-tip {
    opacity: 1;
    transform: translate(calc(-1 * var(--caret, 50%)), 0);
}

@media (max-width: 640px) {
    .search {
        flex-basis: 100%;
    }

    .search kbd {
        display: none;
    }

    /* Every category stays in view: the chips wrap onto rows instead of running off the edge. */
    .chips {
        gap: 4px;
    }

    .chip {
        padding: 5px 9px;
        white-space: nowrap;
    }
}
