/*
  The Compendium v2 Stylesheet
  ---
  - Uses CSS Variables for theming
  - Mobile-first responsive design
  - Includes CRT effects and animations
*/

/* --- CSS Variables (Custom Properties) --- */
:root {
  /* Themes */
  --theme-dnd: #d72626; /* Red */
  --theme-digimon: #00aaff; /* Cyan */
  --theme-pokemon: #ffcb05; /* Yellow */
  --theme-creations: #55ff55; /* Green */
  --theme-mythrin: #aa55ff; /* Purple */
  --theme-blog: #ff80ff; /* Pink */

  /* Base Palette */
  --color-dark-bg: #0d0d0d;
  --color-card-bg: rgba(26, 26, 26, 0.85);
  --color-border: rgba(128, 128, 128, 0.3);
  --color-text-primary: #e0e0e0;
  --color-text-secondary: #a0a0a0;
  --font-body: 'VT323', monospace;
  --font-heading: 'Press Start 2P', cursive;
}

/* --- General & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--color-dark-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

body.no-scroll {
    overflow: hidden;
}

/* --- CRT / Retro Screen Effects --- */
#scanline-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background:
    repeating-linear-gradient(
      transparent 0,
      rgba(0, 0, 0, 0.4) 1px,
      transparent 2px
    );
  pointer-events: none;
  z-index: 1002;
  opacity: 0.6;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: radial-gradient(circle, transparent 40%, rgba(0,0,0,0.8) 110%);
  pointer-events: none;
  z-index: 1001;
}

/* --- Header & Navigation --- */
.main-header {
  background: rgba(13, 13, 13, 0.8);
  backdrop-filter: blur(5px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo a {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #fff;
  text-decoration: none;
  text-shadow: 0 0 5px #fff;
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: 25px;
}

.main-nav a {
  color: var(--color-text-primary);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  padding: 8px 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.3s, text-shadow 0.3s, border-color 0.3s;
  position: relative;
}

.header-actions {
    display: flex;
    align-items: center;
}

.sound-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 5px;
}
.sound-button:hover { color: #fff; }
.sound-button .icon-sound-off { display: none; }
.sound-button.muted .icon-sound-on { display: none; }
.sound-button.muted .icon-sound-off { display: block; }


#mobile-nav-toggle { display: none; }

/* --- Hero Section --- */
.hero {
  position: relative;
  height: 30vh;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  margin-bottom: 15px;
  text-shadow: 0 0 15px rgba(0,0,0,0.8), 0 0 8px;
}

.hero p {
  font-size: 1.2rem;
  max-width: 60ch;
  color: var(--color-text-secondary);
  text-shadow: 0 0 10px rgba(0,0,0,0.9);
  margin: 0 auto;
}

#grid-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  z-index: 0;
  opacity: 0.1;
}

/* --- Hero Animation Styles --- */
.hero-shape, .d20-shape, .digital-bit, .pokeball-shape, .crystal-shape, .rune-shape, .cursor-shape { z-index: 1; }
.d20-shape, .digital-bit, .pokeball-shape, .crystal-shape, .rune-shape, .cursor-shape { position: absolute; top: 100%; }

.hero-shape {
  background-color: var(--shape-color, #fff);
  opacity: 0;
  animation: float-up-fade 8s infinite ease-in-out;
}
@keyframes float-up-fade {
    0% { transform: translateY(20px) scale(0.8); opacity: 0; }
    50% { opacity: 0.7; }
    100% { transform: translateY(-20px) scale(1.2); opacity: 0; }
}
.d20-shape {
    width: 30px; height: 30px; background-color: var(--theme-dnd);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation: float-up 12s infinite linear;
}
@keyframes float-up {
    0% { transform: translateY(5vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-35vh) rotate(360deg); opacity: 0; }
}
.digital-bit {
    font-family: var(--font-body); font-size: 24px; color: var(--theme-digimon);
    animation: digital-rain 8s infinite linear; text-shadow: 0 0 8px var(--theme-digimon);
}
@keyframes digital-rain {
    0% { transform: translateY(5vh); opacity: 1; }
    100% { transform: translateY(-35vh); opacity: 0; }
}
.pokeball-shape {
    width: 25px; height: 25px; border-radius: 50%;
    background: linear-gradient(to bottom, var(--theme-dnd) 48%, #333 48%, #333 52%, white 52%);
    border: 2px solid #333; animation: float-fade 10s infinite ease-in-out;
}
@keyframes float-fade {
    0% { transform: translateY(5vh) scale(0.8); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-35vh) scale(1.2); opacity: 0; }
}
.crystal-shape {
    width: 20px; height: 30px; background-color: var(--theme-creations);
    clip-path: polygon(50% 0%, 100% 35%, 100% 100%, 0% 100%, 0% 35%);
    animation: float-shimmer 14s infinite linear;
}
@keyframes float-shimmer {
    0% { transform: translateY(5vh) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translateY(-35vh) rotate(-360deg) scale(0.5); opacity: 0; }
}
.rune-shape {
    font-family: var(--font-heading); font-size: 30px; color: var(--theme-mythrin);
    text-shadow: 0 0 10px var(--theme-mythrin); animation: float-glow 15s infinite ease-in-out;
}
@keyframes float-glow {
    0%, 100% { transform: translateY(5vh); opacity: 0; }
    50% { transform: translateY(-30vh); opacity: 1; }
}
.cursor-shape {
    width: 15px; height: 25px; background-color: var(--theme-blog);
    box-shadow: 0 0 10px var(--theme-blog);
    animation: float-up 18s infinite linear, blink-cursor 1s infinite step-end;
}
@keyframes blink-cursor { 50% { opacity: 0; } }

/* --- Glitch Effect --- */
.glitch-hover { position: relative; }
.glitch-hover:hover::before, .glitch-hover:hover::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-dark-bg);
}
.glitch-hover:hover::before {
    left: 2px;
    text-shadow: -1px 0 red;
    animation: glitch-anim 1.5s infinite linear alternate-reverse;
}
.glitch-hover:hover::after {
    left: -2px;
    text-shadow: -1px 0 blue;
    animation: glitch-anim-2 1.5s infinite linear alternate-reverse;
}
@keyframes glitch-anim {
  0% { clip-path: inset(89% 0 10% 0); } 25% { clip-path: inset(15% 0 58% 0); }
  50% { clip-path: inset(62% 0 31% 0); } 75% { clip-path: inset(33% 0 41% 0); }
  100% { clip-path: inset(83% 0 11% 0); }
}
@keyframes glitch-anim-2 {
  0% { clip-path: inset(63% 0 35% 0); } 25% { clip-path: inset(3% 0 88% 0); }
  50% { clip-path: inset(100% 0 1% 0); } 75% { clip-path: inset(55% 0 37% 0); }
  100% { clip-path: inset(21% 0 76% 0); }
}

/* --- Content Sections & Cards --- */
.content-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: 60px 20px;
}
.content-section h2 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  margin-bottom: 40px;
  text-align: center;
  color: #fff;
  text-shadow: 0 0 8px;
}
[data-theme="dnd"] h2 { color: var(--theme-dnd); text-shadow: 0 0 8px var(--theme-dnd); }
[data-theme="digimon"] h2 { color: var(--theme-digimon); text-shadow: 0 0 8px var(--theme-digimon); }
[data-theme="pokemon"] h2 { color: var(--theme-pokemon); text-shadow: 0 0 8px var(--theme-pokemon); }
[data-theme="creations"] h2 { color: var(--theme-creations); text-shadow: 0 0 8px var(--theme-creations); }
[data-theme="mythrin"] h2 { color: var(--theme-mythrin); text-shadow: 0 0 8px var(--theme-mythrin); }
[data-theme="blog"] h2 { color: var(--theme-blog); text-shadow: 0 0 8px var(--theme-blog); }

.view-all-container { text-align: center; margin-top: 40px; }
.view-all-button {
    font-family: var(--font-heading);
    font-size: 0.9rem; text-decoration: none; color: var(--color-text-primary);
    padding: 12px 24px; border: 1px solid var(--color-border); border-radius: 5px;
    transition: background-color 0.3s, color 0.3s, text-shadow 0.3s, border-color 0.3s;
}

.content-wrapper { min-height: 250px; }
.vertical-list { display: flex; flex-direction: column; gap: 20px; align-items: center; }
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 25px;
}

.content-card-link, .blog-card-link { cursor: pointer; }
.content-card {
  background: var(--color-card-bg); border: 1px solid var(--color-border);
  border-radius: 5px; overflow: hidden; height: 320px; display: flex;
  flex-direction: column; transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
.blog-card {
    background: var(--color-card-bg); border: 1px solid var(--color-border);
    border-radius: 5px; padding: 25px; width: 100%; max-width: 800px;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
}
.content-card:hover, .blog-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.5); }
[data-theme="dnd"] .content-card:hover, [data-theme="dnd"] .view-all-button:hover, .load-more-button[data-theme="dnd"]:hover { border-color: var(--theme-dnd); box-shadow: 0 8px 16px rgba(0,0,0,0.5), 0 0 15px var(--theme-dnd); }
[data-theme="digimon"] .content-card:hover, [data-theme="digimon"] .view-all-button:hover, .load-more-button[data-theme="digimon"]:hover { border-color: var(--theme-digimon); box-shadow: 0 8px 16px rgba(0,0,0,0.5), 0 0 15px var(--theme-digimon); }
[data-theme="pokemon"] .content-card:hover, [data-theme="pokemon"] .view-all-button:hover, .load-more-button[data-theme="pokemon"]:hover { border-color: var(--theme-pokemon); box-shadow: 0 8px 16px rgba(0,0,0,0.5), 0 0 15px var(--theme-pokemon); }
[data-theme="creations"] .content-card:hover, [data-theme="creations"] .view-all-button:hover, .load-more-button[data-theme="creations"]:hover { border-color: var(--theme-creations); box-shadow: 0 8px 16px rgba(0,0,0,0.5), 0 0 15px var(--theme-creations); }
[data-theme="mythrin"] .content-card:hover, [data-theme="mythrin"] .view-all-button:hover, .load-more-button[data-theme="mythrin"]:hover { border-color: var(--theme-mythrin); box-shadow: 0 8px 16px rgba(0,0,0,0.5), 0 0 15px var(--theme-mythrin); }
.blog-card:hover, [data-theme="blog"] .view-all-button:hover, .load-more-button[data-theme="blog"]:hover { border-color: var(--theme-blog); box-shadow: 0 8px 16px rgba(0,0,0,0.5), 0 0 15px var(--theme-blog); }

.card-image-container { height: 50%; overflow: hidden; }
.card-image-container img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s; background-color: #222;
}
.content-card:hover img { transform: scale(1.05); }
.card-content { padding: 20px; height: 50%; display: flex; flex-direction: column; }
.card-content h3 {
  font-family: var(--font-heading); font-size: 1rem; color: #fff; margin-bottom: 10px;
}
.card-content p {
  font-size: 1rem; color: var(--color-text-secondary); flex-grow: 1;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.blog-card h3 {
    font-family: var(--font-heading); font-size: 1.1rem;
    color: var(--theme-blog); margin-bottom: 10px;
}
.blog-card .blog-date { font-size: 0.9rem; color: var(--color-text-secondary); margin-bottom: 15px; }
.blog-card .blog-description { font-size: 1rem; color: var(--color-text-primary); }

/* --- PDF Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    position: relative;
    background: var(--color-dark-bg);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    width: 90%;
    height: 90%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    transform: scale(0.95);
    transition: transform 0.3s;
}
.modal-overlay.visible .modal-content {
    transform: scale(1);
}
.modal-close-button {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 2rem;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    font-family: sans-serif;
}
#pdf-viewer {
    flex-grow: 1;
    border: none;
    border-radius: 0 0 5px 5px;
}


/* --- Footer & Back to Top --- */
.main-footer { text-align: center; padding: 40px 20px; border-top: 1px solid var(--color-border); color: var(--color-text-secondary); }
.back-to-top-button {
    position: fixed; bottom: 20px; right: 20px; background-color: rgba(40, 40, 40, 0.8);
    color: #fff; border: 1px solid var(--color-border); border-radius: 50%;
    width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0; visibility: hidden; transform: translateY(20px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s; z-index: 1000;
}
.back-to-top-button.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top-button:hover { background-color: #fff; color: #000; }

/* --- Utility, Loaders, Pagination --- */
.skip-link { position: absolute; top: -40px; left: 0; background: #fff; color: #000; padding: 8px; z-index: 1003; }
.skip-link:focus { top: 0; }

.retro-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--color-text-secondary);
    padding: 40px;
    width: 100%;
    grid-column: 1 / -1; /* Span across grid */
}
.loader-cursor {
    width: 10px;
    height: 1.2rem;
    background: var(--color-text-secondary);
    animation: blink-cursor 1s infinite step-end;
}

.error-message {
    grid-column: 1 / -1; color: var(--theme-dnd); background: rgba(215, 38, 38, 0.1);
    padding: 15px; border-radius: 5px; border: 1px solid var(--theme-dnd);
}

.load-more-container {
    grid-column: 1 / -1; /* Make it span the full width of the grid */
    text-align: center;
    padding: 20px 0;
}
.load-more-button {
    font-family: var(--font-heading); font-size: 0.9rem;
    background: transparent; color: var(--color-text-primary);
    padding: 12px 24px; border: 1px solid var(--color-border);
    border-radius: 5px; cursor: pointer;
    transition: background-color 0.3s, color 0.3s, text-shadow 0.3s, border-color 0.3s;
}


/* --- Responsive Design --- */
@media (max-width: 768px) {
  body { font-size: 16px; }
  .header-container { height: 60px; }
  .main-nav { flex-grow: 1; }
  .main-nav ul {
    position: absolute; top: 60px; left: 0; right: 0; background: #111;
    flex-direction: column; width: 100%; padding: 20px; gap: 15px;
    transform: translateY(-120%); transition: transform 0.3s ease-in-out;
    border-bottom: 1px solid var(--color-border);
  }
  .main-nav ul.active { transform: translateY(0); }
  
  #mobile-nav-toggle {
    display: block; background: none; border: none; cursor: pointer;
    width: 30px; height: 25px; display: flex; flex-direction: column;
    justify-content: space-between; margin-left: 15px; order: 3;
  }
  .hamburger-line { width: 100%; height: 3px; background: #fff; border-radius: 2px; }
  .header-container .logo { order: 1; }
  .header-container .header-actions { order: 2; }

  .hero { height: 40vh; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1rem; }
  .content-section { padding: 40px 15px; }
  .content-section h2 { font-size: 1.5rem; }

  .modal-content { width: 95%; height: 85%; }
  .modal-close-button { top: -10px; right: -10px; width: 30px; height: 30px; font-size: 1.5rem; line-height: 30px;}
}

