/* === FONT FALLBACK (reduces CLS during font swap) === */
@font-face {
  font-family: "Stack Sans Notch Fallback";
  src: local("Arial");
  size-adjust: 98%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* === ROOT VARIABLES === */
:root {
  --primary: #7d2bcb;
  --white: #ffffff;
  --black-light: rgba(0, 0, 0, 0.1);
  --black-lighter: rgba(0, 0, 0, 0.06);
  --text-color: #1f2937;
  --bg-light: #e9dbf5;
  --shadow-1: 0 2px 4px -1px var(--black-lighter);
  --shadow-2: 0 4px 6px -1px var(--black-light);
  --shadow-3: 0 1px 3px 0 var(--black-light), 0 1px 2px 0 var(--black-lighter);
  --font-main: "Stack Sans Notch", "Stack Sans Notch Fallback", sans-serif;
}

/* === SCROLLBAR (Webkit) === */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--white);
}
::-webkit-scrollbar-thumb {
  background: var(--primary);
}

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

html {
  overflow-x: hidden;
}

body {
  font-family: sans-serif;
  background-color: var(--bg-light);
  background: url(/bg.png);
  color: var(--text-color);
  margin: 0;
  line-height: 1.5;
  overflow-x: hidden;
}

/* === LAYOUT === */
.container {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

#main-content {
  padding: 0;
  width: 100%;
  min-height: 100vh;
  max-width: 100%;
  position: relative;
}

.content-wrapper {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  width: 100%;
  contain: layout;
  position: relative;
  overflow: visible;
}

/* === SIDEBAR === */
/* Z-index scale: sidebar 400 > overlay 300 > sticky 200 > float 100 */
#sidebar {
  background-color: var(--primary);
  color: var(--white);
  width: 18rem;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 400;
  padding: 0;
  transition: transform 0.3s ease-in-out;
  transform: translateX(-100%);
  font-family: var(--font-main);
}

#sidebar.sidebar-open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.375rem;
}

.close-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--white);
}

#sidebar nav {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

#sidebar nav::-webkit-scrollbar {
  width: 6px;
}
#sidebar nav::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}
#sidebar nav::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
#sidebar nav::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

#sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.2rem;
  text-align: center;
  text-decoration: none;
}

/* === OVERLAY === */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* === HEADER === */
.main-header {
  background-color: var(--primary);
  height: 60px;
  contain: layout;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-toggle svg {
  width: 1.875rem;
  height: 1.875rem;
  color: var(--white);
}

.site-branding {
  flex: 1;
  font-family: var(--font-main);
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  margin: 0;
  line-height: 1.2;
}

.site-title a {
  color: var(--white);
  text-decoration: none;
}

.navLink {
  display: block;
}

.navLink ul {
  display: flex;
}

.navLink ul li {
  list-style-type: none;
  margin-left: 1.25rem;
}

.navLink ul li a {
  font-family: var(--font-main);
  text-decoration: none;
  color: var(--white);
  text-transform: uppercase;
  line-height: 1;
  display: inline-block;
}

/* === POPULAR BAR === */
.popular {
  overflow: hidden;
  white-space: nowrap;
  width: 100%;
  background: var(--primary);
  padding: 3px 0;
  position: relative;
  box-shadow: var(--shadow-2);
}

.popular ul {
  display: inline-flex;
  list-style: none;
  gap: 0.3rem;
  padding: 0;
  margin: 0;
  animation: scroll 60s linear infinite;
}

.popular li {
  display: inline-block;
}

.popular a {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 37px;
  text-decoration: none;
  font-size: 1rem;
  color: var(--white);
  white-space: nowrap;
  text-transform: uppercase;
  font-family: var(--font-main);
}

@keyframes scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* === COLLECTION AREA === */
.sticky-collection {
  margin-top: 20px;
  position: sticky;
  top: 0;
  z-index: 200;
  background-color: var(--primary);
  border-radius: 10px;
}

.collection-content {
  display: flex;
  gap: 0.75rem;
 align-items: center;
  width: 100%;
}

#lenny-collection {
  font-family: var(--font-main);
  flex: 1;
  height: 4rem;
  padding: 1.4rem;
  border: 2px solid var(--primary);
  resize: none;
  font-size: 0.875rem;
  min-width: 0;
  width: 100%;
  overflow: hidden;
      border-radius: 10px;
}

#lenny-collection:focus {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--primary);
}

.collection-buttons {
  display: flex;
  gap: 0.5rem;
  flex-direction: column;
}

.collection-buttons button {
  border: none;
  cursor: pointer;
  background: transparent;
}

/* === CATEGORY GRID === */
.category-section {
  margin: 2rem 0 1.5rem;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.3s ease-out forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-header {
  color: var(--white);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.category-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.category-header:hover::before {
  left: 100%;
}

.category-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  position: relative;
  z-index: 1;
}

.category-count {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  position: relative;
  z-index: 1;
  font-weight: 500;
}

.category-header.happy    { background: linear-gradient(135deg, var(--happy-1), var(--happy-2)); }
.category-header.sad      { background: linear-gradient(135deg, var(--sad-1), var(--sad-2)); }
.category-header.shocked  { background: linear-gradient(135deg, var(--shocked-1), var(--shocked-2)); }
.category-header.cry      { background: linear-gradient(135deg, var(--cry-1), var(--cry-2)); }
.category-header.angry    { background: linear-gradient(135deg, var(--angry-1), var(--angry-2)); }
.category-header.flower   { background: linear-gradient(135deg, var(--flower-1), var(--flower-2)); }
.category-header.glasses  { background: linear-gradient(135deg, var(--glasses-1), var(--glasses-2)); }
.category-header.cute     { background: linear-gradient(135deg, var(--cute-1), var(--cute-2)); }
.category-header.blush    { background: linear-gradient(135deg, var(--blush-1), var(--blush-2)); }
.category-header.confused { background: linear-gradient(135deg, var(--confused-1), var(--confused-2)); }
.category-header.sleep    { background: linear-gradient(135deg, var(--sleep-1), var(--sleep-2)); }
.category-header.gun      { background: linear-gradient(135deg, var(--gun-1), var(--gun-2)); }
.category-header.thinking { background: linear-gradient(135deg, var(--thinking-1), var(--thinking-2)); }
.category-header.vomit    { background: linear-gradient(135deg, var(--vomit-1), var(--vomit-2)); }
.category-header.laugh    { background: linear-gradient(135deg, var(--laugh-1), var(--laugh-2)); }
.category-header.devil    { background: linear-gradient(135deg, var(--devil-1), var(--devil-2)); }
.category-header.love     { background: linear-gradient(135deg, var(--love-1), var(--love-2)); }
.category-header.kiss     { background: linear-gradient(135deg, var(--kiss-1), var(--kiss-2)); }
.category-header.surprised { background: linear-gradient(135deg, var(--surprised-1), var(--surprised-2)); }
.category-header.naughty  { background: linear-gradient(135deg, var(--naughty-1), var(--naughty-2)); }
.category-header.hug      { background: linear-gradient(135deg, var(--hug-1), var(--hug-2)); }
.category-header.heart    { background: linear-gradient(135deg, var(--heart-1), var(--heart-2)); }
.category-header.cat      { background: linear-gradient(135deg, var(--cat-1), var(--cat-2)); }
.category-header.smile    { background: linear-gradient(135deg, var(--smile-1), var(--smile-2)); }
.category-header.sparkle  { background: linear-gradient(135deg, var(--sparkle-1), var(--sparkle-2)); }

#lenny-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
  width: 100%;
}

.lenny-face-container {
    background-color: var(--white);
    /* box-shadow: 6px -7px 0px -2px var(--primary), var(--shadow-1); */
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    /* border: 2px solid var(--primary); */
    border-radius: 9px;
    padding: 4px 0px;
}

.lenny-face-container:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-2);
  background-color: var(--primary);
  color: var(--white);
}

.lenny-face-container:hover .add-to-collection {
  color: var(--white);
}

.lenny-face {
  font-size: 1.5rem;
  cursor: pointer;
  word-break: break-all;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.add-to-collection {
  font-size: 2rem;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
}

/* === INFINITE SCROLL STATUS === */
.page-load-status {
  margin: 2rem 0;
  text-align: center;
  font-size: 1.125rem;
}

.page-load-status .infinite-scroll-request {
  display: none;
  color: #3b82f6;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.1s ease-in;
}

.page-load-status .infinite-scroll-request.show {
  opacity: 1;
}

.page-load-status .infinite-scroll-last {
  display: none;
  color: #6b7280;
  font-style: italic;
  opacity: 0;
  transition: opacity 0.2s ease-in;
}

.page-load-status .infinite-scroll-last.show {
  opacity: 1;
}

.page-load-status .infinite-scroll-error {
  display: none;
  color: #ef4444;
}

/* === SCROLL-TO-TOP BUTTON === */
.action-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.action-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#scroll-top-btn {
  width: 3rem;
  height: 3rem;
  background-color: var(--white);
  /* box-shadow: 6px -6px 0px -2px var(--primary), var(--shadow-1); */
  display: flex;
  border: 2px solid var(--primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
      border-radius: 31%;
}

#scroll-top-btn svg {
  height: 1.25rem;
  width: 1.25rem;
}

/* === FOOTER === */
footer {
  font-family: var(--font-main);
  text-align: center;
  /* padding: 1.5rem; */
  background-color: var(--white);
  margin-top: 3rem;
  box-shadow: inset var(--shadow-1);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.version {
  position: absolute;
  bottom: 0.4rem;
  right: 0.75rem;
  font-size: 0.7rem;
  color: #6b7280;
  pointer-events: none;
}

#sidebar .version {
  color: rgba(255, 255, 255, 0.85);
}

footer ul {
  display: flex;
  gap: 0.625rem;
}

footer ul li {
  list-style-type: none;
}

footer ul li a {
  text-decoration: none;
}

.footSiteName {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* === TOAST === */
#toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background-color: var(--primary);
  color: var(--white);
  padding: 0.5rem 1rem;
  font-family: var(--font-main);
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: 10px;
}

/* ====================================================
   RESPONSIVE — all media queries after base styles
   so they override correctly without !important
   ==================================================== */

/* Grid columns */
/* === CATEGORY PAGE === */
.category-page-header {
  padding: 2rem 0 1rem;
}

.category-page-header h1 {
  font-family: var(--font-main);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0 0 0.25rem;
}

.category-page-header p {
  color: #6b7280;
  margin: 0;
  font-size: 0.95rem;
}

.category-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1rem;
  padding: 1.5rem 0 3rem;
}

.category-card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem 1rem 1.25rem;
  text-align: center;
  text-decoration: none;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  box-shadow: var(--shadow-3);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.category-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-2);
  background: var(--primary);
  color: var(--white);
}

.category-card-face {
  font-size: 1.15rem;
  line-height: 1.5;
  font-family: var(--font-main);
  word-break: break-all;
}

.category-card-name {
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.other-tools-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 1.5rem 0 2rem;
  padding: 0;
  background: transparent;
  color: #ffffff;
  overflow-x: auto;
  white-space: nowrap;
}

.other-tools-strip-title {
  font-family: var(--font-main);
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #ffffff;
  /* border: 1px solid #5b5b5b; */
}

.other-tools-strip-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.other-tools-strip-links a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0.5rem 1rem;
  background: #434343;
  border: 1px solid #5b5b5b;
  color: #ffffff;
  text-decoration: underline;
  font-family: var(--font-main);
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
}

.other-tools-strip-links a:hover {
  background: #2f2f2f;
}

@media (min-width: 640px) {
  #lenny-grid,
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  #lenny-grid,
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  #lenny-grid,
  .category-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Tablet (641px–1023px) */
@media (min-width: 641px) and (max-width: 1023px) {
  .site-title {
    font-size: 1.75rem;
  }

  .menu-toggle svg {
    width: 1.375rem;
    height: 1.375rem;
  }

  .collection-content {
    gap: 1rem;
  }

  #lenny-collection {
    height: 3.25rem;
    padding: 0.625rem;
    font-size: 0.9375rem;
  }
}

/* Tablet and below: hide top nav links, shrink sidebar */
@media (max-width: 768px) {
  .navLink {
    display: none;
  }

  #sidebar {
    width: 16rem;
  }

  #sidebar nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1.25rem;
  }

  /* #sidebar nav a {
    font-size: 0.8rem;
    padding: 0.75rem 0.5rem;
    min-height: 3rem;
  } */
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
  .site-branding {
    text-align: center;
  }

  .site-title {
    font-size: 1.5rem;
  }

  #lenny-collection {
    height: 4rem;
    padding: 0.75rem;
    font-size: 1rem;
    resize: vertical;
    min-height: 4rem;
    max-height: 8rem;
  }

  .collection-buttons button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .category-header {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .category-title {
    font-size: 1.25rem;
  }

  .lenny-face {
    font-size: 1.25rem;
  }

  .lenny-face-container {
    padding: 0.75rem;
  }

  .action-btn {
    right: 0.75rem;
    bottom: 1rem;
  }

  #scroll-top-btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  #scroll-top-btn svg {
    height: 1rem;
    width: 1rem;
  }
}

/* Small mobile (≤480px) */
@media (max-width: 480px) {
  #sidebar {
    width: 16rem;
  }

  #sidebar nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 1rem;
  }

  /* #sidebar nav a {
    font-size: 0.75rem;
    padding: 0.625rem 0.25rem;
    min-height: 2.75rem;
  } */

  .menu-toggle svg {
    width: 1.6rem;
    height: 1.6rem;
  }

  .site-title {
    font-size: 1.25rem;
  }

  .content-wrapper {
    padding: 0 0.5rem 2rem;
  }

  .other-tools-strip {
    gap: 4px;
  }

  /* .sticky-collection {
    margin-top: 0;
  } */

  /* .collection-area {
    padding: 0.75rem;
  } */

  .collection-content {
    gap: 0;
  }

  #lenny-collection {
    height: 3.5rem;
    padding: 0.625rem;
    font-size: 0.875rem;
    min-height: 3.5rem;
    max-height: 7rem;
  }

  .collection-buttons {
    gap: 0.5rem;
  }
}
