/* ============================================================
   PS3 WORLD — AVATAR ARCHIVE STYLESHEET (avatars.ps3.world)
   ------------------------------------------------------------
   Shares its design tokens and core components with the main
   site's style.css (ps3.world), the Theme Archive
   (themes.ps3.world) and the Manuals Archive
   (manuals.ps3.world) so they all look like one site.

   Contents
     1. Tokens
     2. Base
     3. Layout
     4. Header & navigation
     5. Page headers (hero, category header, breadcrumbs)
     6. Search & filters
     7. Section headings
     8. Category tiles
     9. Avatar cards
    10. Badges & placeholders
    11. Buttons & load more
    12. Prose (guide / about)
    13. Avatar thumbnails, region badges & filters
    14. Empty & error states
    15. Lightbox
    16. Footer & back-to-top
    17. Responsive
    18. Motion & touch
   ============================================================ */


/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  color-scheme: dark;

  --bg: #05070d;
  --bg-2: #0a0e18;
  --card: #10141f;
  --card-2: #161b28;
  --surface: rgba(255, 255, 255, 0.03);
  --media-bg: #0e1220;

  --border: #1f2533;
  --border-2: #2c3549;

  --text: #eef1f7;
  --text-2: #a2acc0;
  --text-3: #67718a;

  --ps-blue: #0070d1;
  --ps-blue-2: #2b8fff;
  --ps-cyan: #4ad9ff;
  --ps-sky: #4a9eff;
  --ps-ice: #76cae9;
  --download: #56e39f;

  --radius: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --pill: 999px;

  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(43, 143, 255, 0.15);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --header-h: 68px;
  --gutter: 28px;
}


/* ============================================================
   2. BASE
   ============================================================ */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--border-2) var(--bg);
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  background:
    linear-gradient(rgba(5, 7, 13, 0.95), rgba(5, 7, 13, 0.95)),
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(43, 143, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(74, 217, 255, 0.04), transparent);
  background-attachment: fixed;
}

::selection {
  background: rgba(43, 143, 255, 0.35);
  color: #fff;
}

a {
  color: var(--ps-blue-2);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

a:hover { color: var(--ps-cyan); }

:focus-visible {
  outline: 2px solid var(--ps-cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

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

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em;
  line-height: 1.3;
  text-wrap: balance;
}

p,
li { text-wrap: pretty; }

code { font-family: var(--font-mono); }

hr.solid {
  position: relative;
  margin: 24px 0;
  border: none;
  border-bottom: 2px solid rgba(74, 158, 255, 0.2);
}

hr.solid::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--ps-sky), transparent);
}


/* ============================================================
   3. LAYOUT
   ============================================================ */
.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main {
  position: relative;
  z-index: 1;
  padding-top: 24px;
}


/* ============================================================
   4. HEADER & NAVIGATION
   ============================================================ */
header.site {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 7, 13, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: slideDown 0.4s var(--ease);
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: none; }
}

header.site .wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  height: var(--header-h);
}

.logo {
  display: flex;
  flex-shrink: 1;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--text);
}

.logo:hover { color: var(--text); }

.logo-img {
  width: clamp(150px, 18vw, 250px);
  height: auto;
}

.logo-sub {
  padding: 4px 10px;
  border: 1px solid rgba(74, 217, 255, 0.25);
  border-radius: var(--pill);
  background: rgba(74, 217, 255, 0.06);
  color: var(--ps-ice);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  white-space: nowrap;
  text-transform: uppercase;
}

nav.main {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

nav.main a {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}

nav.main a:hover {
  background: var(--card);
  color: var(--text);
}

nav.main a.active {
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
}

nav.main a.nav-home { color: var(--ps-ice); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.nav-toggle:hover { background: var(--card); }

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }


/* ============================================================
   5. PAGE HEADERS
   ============================================================ */

/* ---- Home hero ---- */
.hero {
  position: relative;
  padding: 24px 0 8px;
}

.hero h1 {
  margin: 0 0 16px;
  padding-bottom: 4px;
  font-size: clamp(32px, 5vw, 60px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -2px;
  background: linear-gradient(180deg, #fff 0%, #a2acc0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeUp 0.6s var(--ease) backwards;
}

.hero p {
  max-width: 700px;
  margin: 0;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1.6;
  animation: fadeUp 0.6s 0.1s var(--ease) backwards;
}

.hero .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 32px;
}

.hero .stat {
  position: relative;
  min-width: 140px;
  padding: 16px 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  animation: fadeUp 0.5s var(--ease) backwards;
}

.hero .stat:nth-child(1) { animation-delay: 0.2s; }
.hero .stat:nth-child(2) { animation-delay: 0.3s; }
.hero .stat:nth-child(3) { animation-delay: 0.4s; }
.hero .stat:nth-child(4) { animation-delay: 0.5s; }

/* Thin glowing line along the top of each stat */
.hero .stat::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ps-blue-2), transparent);
  opacity: 0.5;
}

.hero .stat b {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #fff 0%, #8fbaff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero .stat span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Inner page header ---- */
.cat-header { padding: 16px 0 24px; }

.cat-header h1 {
  margin: 0 0 8px;
  padding-bottom: 6px;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -1.5px;
  background: linear-gradient(180deg, #fff 0%, #8fbaff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cat-header .count {
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
}

.cat-header .count b {
  color: var(--text);
  font-weight: 700;
}

/* ---- Breadcrumbs (same pill as ps3.world) ---- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 16px;
  padding: 6px 14px;
  border: 1px solid rgba(74, 217, 255, 0.25);
  border-radius: var(--pill);
  background: rgba(74, 217, 255, 0.06);
  color: var(--ps-ice);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--ps-cyan); }

.crumbs > * + *::before {
  content: '/';
  display: inline-block;
  margin: 0 9px;
  color: var(--text-3);
}


/* ============================================================
   6. SEARCH & FILTERS
   ============================================================ */
.searchbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 40px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.searchbar:focus-within {
  border-color: var(--ps-blue);
  box-shadow: 0 0 0 4px rgba(43, 143, 255, 0.12);
}

.searchbar-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-3);
}

.searchbar input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 12px 6px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.searchbar input[type="search"]::placeholder { color: var(--text-3); }

.searchbar input::-webkit-search-cancel-button { filter: invert(0.7); }

.searchbar select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.searchbar select:focus { border-color: var(--ps-blue); }

/* ============================================================
   7. SECTION HEADINGS
   ============================================================ */
h2.section {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 48px 0 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(74, 158, 255, 0.2);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
}

h2.section::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--ps-sky), transparent);
}

h2.section .count {
  padding: 3px 10px;
  border-radius: var(--pill);
  background: rgba(74, 217, 255, 0.1);
  color: var(--ps-ice);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

h2.section .count b { color: #fff; }


/* ============================================================
   8. CATEGORY TILES
   ============================================================ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin: 24px 0 40px;
}

.cat-tile {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.cat-tile:hover {
  border-color: rgba(43, 143, 255, 0.45);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(43, 143, 255, 0.15);
  color: var(--text);
  transform: translateY(-4px);
}

.cat-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.85) saturate(0.95);
  transition: transform 0.5s var(--ease), filter 0.3s var(--ease);
}

.cat-tile:hover img {
  filter: brightness(1) saturate(1.1);
  transform: scale(1.06);
}

.cat-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(5, 7, 13, 0.55) 65%, rgba(5, 7, 13, 0.95) 100%);
  pointer-events: none;
}

.cat-tile .tile-body {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 22px;
}

.cat-tile .tile-name {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.cat-tile .tile-meta {
  color: var(--ps-ice);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.cat-tile .tile-arrow {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(5, 7, 13, 0.75);
  backdrop-filter: blur(10px);
  color: var(--text-2);
  font-size: 16px;
  transition: all 0.25s var(--ease);
}

.cat-tile:hover .tile-arrow {
  border-color: var(--ps-blue-2);
  background: var(--ps-blue);
  box-shadow: 0 0 20px rgba(43, 143, 255, 0.6);
  color: #fff;
  transform: translate(2px, -2px);
}


/* ============================================================
   9. AVATAR CARDS
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow), 0 0 0 1px rgba(43, 143, 255, 0.15);
  transform: translateY(-3px);
}

.card .thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--media-bg);
}

.card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
}

/* Fade images in as they arrive */
.card .thumb img.is-loading { opacity: 0; }

.card:hover .thumb img { transform: scale(1.05); }

.card .body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
}

.card .title {
  display: -webkit-box;
  overflow: hidden;
  color: #fff;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.35;
  word-break: break-word;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card .author {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: -4px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card .author::before {
  content: '';
  flex-shrink: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ps-cyan);
  opacity: 0.7;
}

.card .author .name {
  overflow: hidden;
  color: var(--text-2);
  text-overflow: ellipsis;
}

.card .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

.card .meta .cat-chip {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--pill);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-transform: uppercase;
}

.card .meta .size {
  margin-left: auto;
  color: var(--text-3);
  font-size: 10.5px;
  white-space: nowrap;
}

.card .actions {
  display: flex;
  gap: 6px;
}

.card .actions a {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.card .actions a:hover {
  border-color: var(--border-2);
  background: var(--card-2);
  color: var(--text);
}

.card .actions a.dl {
  border-color: rgba(86, 227, 159, 0.35);
  background: rgba(86, 227, 159, 0.05);
  color: var(--download);
}

.card .actions a.dl:hover {
  border-color: rgba(86, 227, 159, 0.6);
  background: rgba(86, 227, 159, 0.14);
  color: #7fffbb;
}

.card .actions a.disabled {
  opacity: 0.3;
  pointer-events: none;
}


/* ============================================================
   10. BADGES & PLACEHOLDERS
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 1px;
  white-space: nowrap;
  text-transform: uppercase;
}

.badge-wrap {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 3;
  display: flex;
  gap: 5px;
  pointer-events: none;
}

/* "No preview" / "18+" stand-ins — on cards and on category tiles */
.card .thumb .placeholder,
.tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    linear-gradient(135deg, rgba(43, 143, 255, 0.06), rgba(74, 217, 255, 0.02)),
    var(--media-bg);
  color: var(--text-3);
  line-height: 1;
  text-align: center;
}

.card .thumb .placeholder .ph-icon,
.tile-placeholder .tile-ph-icon {
  display: block;
  color: var(--text-2);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
}

.tile-placeholder .tile-ph-icon { font-size: 26px; }

.card .thumb .placeholder .ph-text,
.tile-placeholder .tile-ph-text {
  display: block;
  color: var(--text-3);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.tile-placeholder .tile-ph-text { font-size: 11px; }

/* ============================================================
   11. BUTTONS & LOAD MORE
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  border: 1px solid var(--ps-blue-2);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-blue-2));
  box-shadow: 0 0 24px rgba(43, 143, 255, 0.35);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn:hover {
  box-shadow: 0 0 36px rgba(74, 217, 255, 0.6);
  color: #fff;
  transform: translateY(-1px);
}

.btn.btn-ghost {
  border-color: var(--border-2);
  background: rgba(255, 255, 255, 0.02);
  box-shadow: none;
  color: var(--text);
}

.btn.btn-ghost:hover {
  border-color: var(--ps-blue-2);
  background: rgba(43, 143, 255, 0.1);
  box-shadow: none;
}

#load-more-btn {
  display: block;
  margin: 32px auto 8px;
  padding: 12px 28px;
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-radius: var(--pill);
  background: rgba(74, 158, 255, 0.08);
  color: var(--ps-sky);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

#load-more-btn:hover {
  border-color: var(--ps-sky);
  background: rgba(74, 158, 255, 0.18);
  color: #fff;
}

#load-more-btn:active { transform: translateY(1px); }


/* ============================================================
   12. PROSE (guide / about)
   ============================================================ */
.prose {
  max-width: 760px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.75;
}

.prose h2 {
  position: relative;
  margin: 44px 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(74, 158, 255, 0.2);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.prose h2::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--ps-sky), transparent);
}

.prose p { margin: 0 0 18px; }

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose ul,
.prose ol {
  margin: 0 0 22px;
  padding-left: 22px;
}

.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--ps-sky); }

.prose code {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}


/* ============================================================
   13. AVATAR THUMBNAILS, REGION BADGES & FILTERS
   ============================================================ */

/* Avatars are square, so cards use a square frame and never crop */
.card .thumb { aspect-ratio: 1 / 1; }

.card .thumb img {
  object-fit: contain;
  padding: 10px;
}

.grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* Pack tiles are square too, in a denser grid (there are hundreds) */
#home-categories .cat-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

#home-categories .cat-tile { aspect-ratio: 1 / 1; }

#home-categories .cat-tile .tile-body { padding: 14px 16px; }

#home-categories .cat-tile .tile-name {
  display: -webkit-box;
  overflow: hidden;
  font-size: 16px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#home-categories .cat-tile .tile-meta { font-size: 11px; }

/* Region badges (cards, tiles and pack headers) */
.badge.region { background: rgba(43, 143, 255, 0.92); }

.badge-wrap {
  flex-wrap: wrap;
  max-width: calc(100% - 60px);
}

.cat-header .count .badge {
  margin-right: 2px;
  vertical-align: 2px;
}

/* Pack name under the avatar title */
.card .author .name a { color: var(--text-2); }
.card .author .name a:hover { color: var(--ps-cyan); }

/* Region filter pills on the home page */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -16px 0 8px;
}

.filter-row button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--pill);
  background: var(--card);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-row button:hover {
  border-color: var(--border-2);
  color: var(--text);
}

.filter-row button.active {
  border-color: var(--ps-blue-2);
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-blue-2));
  box-shadow: 0 0 14px rgba(43, 143, 255, 0.35);
  color: #fff;
}

/* Pack names can be long: keep the pack dropdown inside the search bar */
.searchbar select {
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
}

#pack { max-width: 360px; }

/* Small avatars stay crisp and readable in the preview popup */
.lightbox .lb-stage img {
  min-width: min(320px, 85vw);
  image-rendering: auto;
}

@media (max-width: 720px) {
  #home-categories .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #home-categories .cat-tile .tile-body { padding: 10px 12px; }
  #home-categories .cat-tile .tile-name { font-size: 14px; }
  #home-categories .cat-tile .tile-meta { font-size: 10px; letter-spacing: 0.8px; }
  .card .thumb img { padding: 6px; }
  .filter-row { margin-top: -8px; }
  .filter-row button { padding: 7px 12px; font-size: 12px; }
  #pack { max-width: 100%; }
}


/* ============================================================
   14. EMPTY & ERROR STATES
   ============================================================ */
.empty {
  padding: 80px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-3);
  text-align: center;
}

.error-hero {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 0 40px;
  text-align: center;
}

.error-hero .error-code {
  margin: 0 0 8px;
  color: #ea0e0e;
  font-size: clamp(64px, 12vw, 96px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -4px;
  text-shadow: 0 4px 24px rgba(234, 14, 14, 0.3);
}

.error-hero h1 { font-size: 28px; }

.error-hero p {
  margin: 0 0 28px;
  color: var(--text-2);
  font-size: 16px;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.error-hero .error-note {
  color: var(--text-3);
  font-size: 13px;
  font-style: italic;
}


/* ============================================================
   15. LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(5, 7, 13, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox.open {
  display: flex;
  animation: lbIn 0.25s var(--ease);
}

.lightbox .lb-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: auto;
  max-width: min(95vw, 1200px);
  /* margin:auto centres the viewer but lets it scroll when it is taller
     than the screen (align-items:center would cut the top off) */
  margin: auto;
  animation: lbZoom 0.3s var(--ease);
}

.lightbox .lb-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 80vh;
  max-height: min(80vh, calc(100dvh - 190px));
  margin: 0 auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-2);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
}

.lightbox .lb-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 20, 31, 0.9);
  font-size: 14px;
}

.lightbox .lb-title {
  color: var(--text);
  font-weight: 700;
}

.lightbox .lb-author { color: var(--text-2); }

.lightbox .lb-dl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 9px 16px;
  border: 1px solid var(--ps-blue-2);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-blue-2));
  box-shadow: 0 0 20px rgba(43, 143, 255, 0.4);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.lightbox .lb-dl:hover {
  box-shadow: 0 0 30px rgba(74, 217, 255, 0.6);
  color: #fff;
}

.lightbox .lb-dl svg { width: 16px; height: 16px; }

.lightbox .close {
  position: absolute;
  top: -44px;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.lightbox .close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: rotate(90deg);
}

@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes lbZoom {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}


/* ============================================================
   16. FOOTER & BACK-TO-TOP
   ============================================================ */
footer.site {
  position: relative;
  z-index: 1;
  margin-top: 100px;
  padding: 36px 0;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 13px;
}

footer.site .wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

footer.site .footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 4px;
}

footer.site .footer-links a {
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

footer.site .footer-links a:hover {
  background: var(--card);
  color: var(--ps-cyan);
}

footer.site .footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

footer.site .ps-mark {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

footer.site .ps-mark a { color: var(--text-2); }

#backToTop {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--ps-blue-2);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-blue-2));
  box-shadow: 0 8px 32px rgba(43, 143, 255, 0.4);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transform: translateY(20px) scale(0.8);
  transition: all 0.3s var(--ease);
}

#backToTop.visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

#backToTop:hover {
  box-shadow: 0 12px 40px rgba(43, 143, 255, 0.6), 0 0 0 8px rgba(74, 217, 255, 0.08);
  transform: translateY(-3px);
}

#backToTop svg { width: 18px; height: 18px; }


/* ============================================================
   17. RESPONSIVE
   ============================================================ */

/* ---- Hamburger menu ---- */
@media (max-width: 1060px) {
  .nav-toggle { display: flex; flex-shrink: 0; }

  header.site .wrap { position: relative; }

  nav.main {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 99;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    max-height: 0;
    margin-left: 0;
    padding: 12px 18px 18px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 7, 13, 0.98);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.35s var(--ease), opacity 0.25s var(--ease), visibility 0.25s var(--ease);
  }

  nav.main.open {
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
  }

  nav.main a {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 15px;
  }

  nav.main a + a { border-top: 1px solid var(--border); }

  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
}

@media (max-width: 720px) {
  :root {
    --gutter: 18px;
    --header-h: 60px;
  }

  header.site .wrap { gap: 12px; }

  .logo { gap: 10px; }
  .logo-sub { padding: 3px 8px; font-size: 9.5px; letter-spacing: 1px; }

  .hero p { font-size: 16px; }
  .hero .stats { gap: 10px; }
  .hero .stat { flex: 1 1 calc(50% - 10px); min-width: 0; padding: 12px 16px; }
  .hero .stat b { font-size: 22px; }

  /* Search stacks */
  .searchbar {
    flex-wrap: wrap;
    margin: 20px 0 32px;
    padding: 10px;
  }

  .searchbar input[type="search"] { flex: 1 1 calc(100% - 40px); }

  .searchbar select { flex: 1 1 100%; padding: 12px 14px; }

  .cat-grid { grid-template-columns: 1fr; gap: 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  .card .body { gap: 8px; padding: 12px 12px 14px; }
  .card .title { min-height: 34px; font-size: 13px; line-height: 1.3; }
  .card .author { font-size: 11px; }
  .card .meta .cat-chip { padding: 2px 6px; font-size: 8px; }
  .card .meta .size { font-size: 9.5px; }
  .card .actions { flex-direction: column; gap: 5px; }
  .card .actions a { padding: 8px 6px; font-size: 11.5px; }

  h2.section { font-size: 17px; }

  .lightbox { padding: 56px 12px 16px; }
  .lightbox .lb-stage img { max-height: min(80vh, calc(100dvh - 230px)); }

  .lightbox .lb-info {
    flex-direction: column;
    justify-content: center;
    padding: 12px 16px;
    text-align: center;
  }

  .lightbox .lb-title,
  .lightbox .lb-author { max-width: 100%; overflow-wrap: anywhere; }

  .lightbox .lb-dl { margin-left: 0; }

  #backToTop { right: 18px; bottom: 18px; width: 44px; height: 44px; }

  footer.site { margin-top: 60px; padding: 28px 0; }
  footer.site .footer-links a { padding: 5px 10px; font-size: 12px; }

  footer.site .footer-meta {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

@media (max-width: 340px) {
  .logo-sub { display: none; }
}

/* Short screens (phones in landscape): keep the close button on screen */
@media (max-height: 520px) {
  .lightbox { padding-top: 56px; padding-bottom: 12px; }
  .lightbox .lb-stage img { max-height: calc(100dvh - 160px); }
}

@media (max-width: 400px) {
  .cat-tile .tile-name { font-size: 17px; }
}


/* ============================================================
   18. MOTION & TOUCH
   ============================================================ */
@media (hover: none) {
  .cat-tile:hover,
  .card:hover,
  .btn:hover { transform: none; }

  .cat-tile:hover img,
  .card:hover .thumb img { transform: none; }
}

@media (max-width: 720px), (hover: none) and (pointer: coarse) {
  body { background-attachment: scroll; }

  header.site,
  nav.main {
    background: rgba(5, 7, 13, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  html { scroll-behavior: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
