
/***************************************************************************************************
 *                                   ** DO NOT COPY - ALL RIGHTS RESERVED **
 *
 * This code is the exclusive property of Dodch Stories and its owner. Unauthorized copying,
 * reproduction, modification, distribution, or any form of use of this code, in whole or in part,
 * is strictly prohibited.
 *
 * The intellectual property rights, including copyright, for this software are protected by
 * international laws and treaties. Any infringement of these rights will be pursued to the
 * fullest extent of the law, which may include civil and criminal charges.
 *
 * Copyright (c) 2024 Dodch Stories. All rights reserved.
 ***************************************************************************************************/
:root{
  /* Light mode variables (default) */
  --heart-color:rgba(255,255,255,0.8);
  --heart-active:#fb4268;
  --main-bg:rgba(0,0,0,0);
  --moon-color:#fff;
  --notification-text:#fff;
  --search-placeholder:rgba(255,255,255,0.5);
  --tint-color:#fff;
  --blue-tint:#00aaff;
  --purple-tint:#a366ff;
  --pink-tint: #f750a0; /* NEW: A more vibrant pink for heart buttons */
  --red-tint:#ff477e; /* A slightly softer, more pinkish hue */
  --green-tint: #4ade80; /* A nice, vibrant light green */
  --golden-tint:gold;
  --glass-bg:color-mix(in srgb,var(--tint-color) 10%,transparent);
  --glass-text:#f0f0f0;
  /* REFACTOR: Advanced, multi-layered glass edge for a modern, high-tech look. */
  /* REFACTOR: Enhanced glass edge with a high-contrast "double edge" highlight for a more defined, glassy feel. */
  --glass-shadow: 
    /* 1. The primary, sharp inner highlight for the top edge. */
    inset 0 1.5px 1px color-mix(in srgb, #fff 90%, transparent),
    /* 2. A secondary, softer inner highlight to create a beveled look. */
    inset 0 2.5px 3px color-mix(in srgb, var(--blue-tint) 20%, transparent),    
    /* 3. A sharp highlight on the bottom edge to complete the glass look. */
    inset 0 -1.5px 1.5px color-mix(in srgb, #fff 70%, transparent),
    /* 4. Dark Inner Edges (all sides for curved look) */
    inset 0 2.5px 3px color-mix(in srgb, #000 15%, transparent), /* Top */
    inset 0 -2.5px 3px color-mix(in srgb, #000 15%, transparent), /* Bottom */
    inset 2.5px 0 3px color-mix(in srgb, #000 15%, transparent), /* Left */
    inset -2.5px 0 3px color-mix(in srgb, #000 15%, transparent), /* Right */
    /* 5. Soft Inner Shadows (all sides for smooth depth) */
    inset 0 4px 5px -3px color-mix(in srgb, #000 20%, transparent), /* Top */
    inset 0 -4px 5px -3px color-mix(in srgb, #000 20%, transparent), /* Bottom */
    inset 4px 0 5px -3px color-mix(in srgb, #000 20%, transparent), /* Left */
    inset -4px 0 5px -3px color-mix(in srgb, #000 20%, transparent), /* Right */
    /* Outer Drop Shadows (already centered) */ 0px 0px 20px 0px color-mix(in srgb, #000 25%, transparent),
    0px 0px 40px 0px color-mix(in srgb, #000 20%, transparent);
  /* NEW: A simpler shadow for the stacked cards, without the inset borders. */
  --stack-shadow:
    /* White Highlights (all sides) */
    inset 0 1.5px 1px color-mix(in srgb, #fff 90%, transparent),
    inset 0 -1.5px 1.5px color-mix(in srgb, #fff 70%, transparent),
    inset 1.5px 0 1px color-mix(in srgb, #fff 90%, transparent),
    inset -1.5px 0 1.5px color-mix(in srgb, #fff 70%, transparent),
    /* Dark Inner Edges (all sides) */
    inset 0 2.5px 3px color-mix(in srgb, #000 15%, transparent),
    inset 0 -2.5px 3px color-mix(in srgb, #000 15%, transparent),
    inset 2.5px 0 3px color-mix(in srgb, #000 15%, transparent),
    inset -2.5px 0 3px color-mix(in srgb, #000 15%, transparent),
    /* Soft Inner Shadows (all sides) */
    inset 0 4px 5px -3px color-mix(in srgb, #000 20%, transparent),
    inset 0 -4px 5px -3px color-mix(in srgb, #000 20%, transparent),
    inset 4px 0 5px -3px color-mix(in srgb, #000 20%, transparent),
    inset -4px 0 5px -3px color-mix(in srgb, #000 20%, transparent),
    /* Outer Drop Shadows */
    0px 0px 20px 0px color-mix(in srgb, #000 25%, transparent),
    0px 0px 40px 0px color-mix(in srgb, #000 20%, transparent);
  /* REFACTOR: Final overhaul for a hyper-realistic, 3D machined glass button edge with defined top/bottom bevels. */
  --button-edge:
    /* 1. Top Highlight: A sharper, brighter light-catching edge. (Increased opacity) */
    inset 0 1.5px 0 color-mix(in srgb, #fff 95%, transparent),
    /* 2. Bottom Highlight: A softer, more visible reflected light on the bottom inner edge. (Increased opacity) */
    inset 0 -1.5px 0 color-mix(in srgb, #fff 45%, transparent),
    /* 3. Outer Border & Drop Shadow */
    0 0 0 1px color-mix(in srgb, #000 15%, transparent),
    0px 5px 15px -5px color-mix(in srgb, #000 35%, transparent);
  transition: all 0.5s ease-in-out;
  --panel-blur-start: 10px;
  --blur-radius: 3px;

}
/* Dark mode variables based on device settings or manual override */
@media (prefers-color-scheme: dark) {
  :root {
    --main-bg: rgba(0,0,0,0.7);
    --moon-color:#fce38a;
    --notification-text:#f0f0f0;
    --search-placeholder:rgba(255,255,255,0.8);
    --pink-tint: #f750a0; /* NEW: A more vibrant pink for heart buttons */
    --tint-color:#888;
    --blue-tint:#00aaff;
    --purple-tint:#a366ff;
    --red-tint:#ff477e; /* A slightly softer, more pinkish hue */
    --green-tint: #4ade80;
    --golden-tint:gold;
    --glass-bg:rgba(0,0,0,0.35);
    --glass-text:#f0f0f0;
    /* REFACTOR: Advanced, multi-layered glass edge for a modern, high-tech look (dark mode). */
    /* REFACTOR: Enhanced glass edge with a high-contrast "double edge" highlight for a more defined, glassy feel (dark mode). */
    --glass-shadow: 
      /* 1. The primary, sharp inner highlight for the top edge. */
      inset 0 1.5px 1px color-mix(in srgb, #fff 70%, transparent),
      /* 2. A secondary, softer inner highlight to create a beveled look. */
      inset 0 2.5px 4px color-mix(in srgb, var(--blue-tint) 25%, transparent),      
      /* 3. A sharp highlight on the bottom edge to complete the glass look. */
      inset 0 -1.5px 1.5px color-mix(in srgb, #fff 50%, transparent),
      /* 4. Dark Inner Edges (all sides for curved look) */
      inset 0 2.5px 3px color-mix(in srgb, #000 20%, transparent), /* Top */
      inset 0 -2.5px 3px color-mix(in srgb, #000 20%, transparent), /* Bottom */
      inset 2.5px 0 3px color-mix(in srgb, #000 20%, transparent), /* Left */
      inset -2.5px 0 3px color-mix(in srgb, #000 20%, transparent), /* Right */
      /* 5. Soft Inner Shadows (all sides for smooth depth) */
      inset 0 4px 5px -3px color-mix(in srgb, #000 35%, transparent), /* Top */
      inset 0 -4px 5px -3px color-mix(in srgb, #000 35%, transparent), /* Bottom */
      inset 4px 0 5px -3px color-mix(in srgb, #000 35%, transparent), /* Left */
      inset -4px 0 5px -3px color-mix(in srgb, #000 35%, transparent), /* Right */
      /* Outer Drop Shadows (already centered) */ 0px 0px 20px 0px color-mix(in srgb, #000 40%, transparent),
      0px 0px 45px 0px color-mix(in srgb, #000 35%, transparent);
    --stack-shadow:
      /* White Highlights (all sides) */
      inset 0 1.5px 1px color-mix(in srgb, #fff 70%, transparent),
      inset 0 -1.5px 1.5px color-mix(in srgb, #fff 50%, transparent),
      inset 1.5px 0 1px color-mix(in srgb, #fff 70%, transparent),
      inset -1.5px 0 1.5px color-mix(in srgb, #fff 50%, transparent),
      /* Dark Inner Edges (all sides) */
      inset 0 2.5px 3px color-mix(in srgb, #000 20%, transparent),
      inset 0 -2.5px 3px color-mix(in srgb, #000 20%, transparent),
      inset 2.5px 0 3px color-mix(in srgb, #000 20%, transparent),
      inset -2.5px 0 3px color-mix(in srgb, #000 20%, transparent),
      /* Soft Inner Shadows (all sides) */
      inset 0 4px 5px -3px color-mix(in srgb, #000 35%, transparent),
      inset 0 -4px 5px -3px color-mix(in srgb, #000 35%, transparent),
      inset 4px 0 5px -3px color-mix(in srgb, #000 35%, transparent),
      inset -4px 0 5px -3px color-mix(in srgb, #000 35%, transparent),
      /* Outer Drop Shadows */
      0px 0px 20px 0px color-mix(in srgb, #000 40%, transparent),
      0px 0px 45px 0px color-mix(in srgb, #000 35%, transparent);
  /* REFACTOR: Final overhaul for a hyper-realistic, 3D machined glass button edge (dark mode). */
  --button-edge:
    inset 0 1.5px 0 color-mix(in srgb, #fff 80%, transparent),
    inset 0 -1.5px 0 color-mix(in srgb, #fff 40%, transparent),    
    0 0 0 1px color-mix(in srgb, #000 25%, transparent),
    0px 6px 18px -5px color-mix(in srgb, #000 50%, transparent);

  }
}
/* This class can be used for a manual toggle button if you add one later */
body.dark-mode {
  --main-bg: rgba(0,0,0,0.7);
  --moon-color:#fce38a;
  --notification-text:#f0f0f0;
  --search-placeholder:rgba(255,255,255,0.8);
  --pink-tint: #f750a0; /* NEW: A more vibrant pink for heart buttons */
  --tint-color:#888;
  --blue-tint:#00aaff;
  --purple-tint:#a366ff;
  --red-tint:#ff477e; /* A slightly softer, more pinkish hue */
  --green-tint: #4ade80;
  --golden-tint:gold;
  --glass-bg:rgba(0,0,0,0.35);
  --glass-text:#f0f0f0;
  /* REFACTOR: Advanced, multi-layered glass edge for a modern, high-tech look (dark mode). */
  /* REFACTOR: Enhanced glass edge with a high-contrast "double edge" highlight for a more defined, glassy feel (dark mode). */
  --glass-shadow: 
    /* 1. The primary, sharp inner highlight for the top edge. */
    inset 0 1.5px 1px color-mix(in srgb, #fff 70%, transparent),
    /* 2. A secondary, softer inner highlight to create a beveled look. */
    inset 0 2.5px 4px color-mix(in srgb, var(--blue-tint) 25%, transparent),      
    /* 3. A sharp highlight on the bottom edge to complete the glass look. */
    inset 0 -1.5px 1.5px color-mix(in srgb, #fff 50%, transparent),
    /* 4. Dark Inner Edges (all sides for curved look) */
    inset 0 2.5px 3px color-mix(in srgb, #000 20%, transparent), /* Top */
    inset 0 -2.5px 3px color-mix(in srgb, #000 20%, transparent), /* Bottom */
    inset 2.5px 0 3px color-mix(in srgb, #000 20%, transparent), /* Left */
    inset -2.5px 0 3px color-mix(in srgb, #000 20%, transparent), /* Right */
    /* 5. Soft Inner Shadows (all sides for smooth depth) */
    inset 0 4px 5px -3px color-mix(in srgb, #000 35%, transparent), /* Top */
    inset 0 -4px 5px -3px color-mix(in srgb, #000 35%, transparent), /* Bottom */
    inset 4px 0 5px -3px color-mix(in srgb, #000 35%, transparent), /* Left */
    inset -4px 0 5px -3px color-mix(in srgb, #000 35%, transparent), /* Right */
    /* Outer Drop Shadows (already centered) */ 0px 0px 20px 0px color-mix(in srgb, #000 40%, transparent),
    0px 0px 45px 0px color-mix(in srgb, #000 35%, transparent);
  --stack-shadow:
    /* White Highlights (all sides) */
    inset 0 1.5px 1px color-mix(in srgb, #fff 70%, transparent),
    inset 0 -1.5px 1.5px color-mix(in srgb, #fff 50%, transparent),
    inset 1.5px 0 1px color-mix(in srgb, #fff 70%, transparent),
    inset -1.5px 0 1.5px color-mix(in srgb, #fff 50%, transparent),
    /* Dark Inner Edges (all sides) */
    inset 0 2.5px 3px color-mix(in srgb, #000 20%, transparent),
    inset 0 -2.5px 3px color-mix(in srgb, #000 20%, transparent),
    inset 2.5px 0 3px color-mix(in srgb, #000 20%, transparent),
    inset -2.5px 0 3px color-mix(in srgb, #000 20%, transparent),
    /* Soft Inner Shadows (all sides) */
    inset 0 4px 5px -3px color-mix(in srgb, #000 35%, transparent),
    inset 0 -4px 5px -3px color-mix(in srgb, #000 35%, transparent),
    inset 4px 0 5px -3px color-mix(in srgb, #000 35%, transparent),
    inset -4px 0 5px -3px color-mix(in srgb, #000 35%, transparent),
    /* Outer Drop Shadows */
    0px 0px 20px 0px color-mix(in srgb, #000 40%, transparent),
    0px 0px 45px 0px color-mix(in srgb, #000 35%, transparent);
  /* REFACTOR: Final overhaul for a hyper-realistic, 3D machined glass button edge (dark mode). */
  --button-edge:
    inset 0 1.5px 0 color-mix(in srgb, #fff 80%, transparent),
    inset 0 -1.5px 0 color-mix(in srgb, #fff 40%, transparent),    
    0 0 0 1px color-mix(in srgb, #000 25%, transparent),
    0px 6px 18px -5px color-mix(in srgb, #000 50%, transparent);
}
html {
  height: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  color: #fff;
  font-family: sans-serif;
  padding: 40px;
  background-color: #2e3b55;
  position: relative;
  overflow-x: hidden;
  transition: all 0.5s ease-in-out;
  /* Use a CSS variable for viewport height, controlled by JS */
  min-height: calc(var(--vh, 1vh) * 100);
}

/* --- NEW: Mobile Keyboard Fix --- */
/* When the keyboard is active, switch fixed elements to absolute to prevent layout bugs on scroll. */
body.keyboard-active::before,
body.keyboard-active .top-left-fixed-wrapper,
body.keyboard-active .top-right-fixed-wrapper,
body.keyboard-active .floating-buttons-container {
  position: absolute;
}
/* Adjust the top position of the background when it's absolute. */
body.keyboard-active::before {
  top: var(--scroll-y, 0);
}
/* Adjust the top position of the header buttons when they're absolute. */
body.keyboard-active .top-left-fixed-wrapper,
body.keyboard-active .top-right-fixed-wrapper {
    top: var(--scroll-y, 0);
}
body::before {
  content: '';
  /* Fixed position for background */
  position: fixed; 
  top: 0;
  left: 0;
  width: 100vw;
  /* Use a CSS variable for viewport height, controlled by JS */
  height: calc(var(--vh, 1vh) * 100);
  background-image: var(--bg-url);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  z-index: -1;
  /*
    FIX: The Definitive iOS Backdrop-Filter Fix.
    By applying `transform: translateZ(0)`, we force this pseudo-element (the background) onto its own compositing layer. This isolates it from the grid items, preventing the common iOS bug where `backdrop-filter` fails during animations or transforms, resulting in a stable and reliable blur effect on all devices.
  */
  transform: translateZ(0);
  transition: background-image 1s ease-in-out, background-color 1s ease-in-out;
}
/* Applies the dark background for the manual button toggle */
body.dark-mode::before {
  background-image: var(--bg-url-dark);
}
/* Applies the dark background for device preference */
@media (prefers-color-scheme: dark) {
  body::before {
    background-image: var(--bg-url-dark);
  }
}
h1{margin:0 0 20px;}
.grid {
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-auto-rows: minmax(min-content, auto);
  gap:20px;
  margin-top: 100px;
  transition: all 0.5s ease-in-out;
  /* NEW: Add padding to the bottom to prevent the footer from hiding the last row. */
  padding-bottom: 100px;
}

.glass-container {
  background:var(--glass-bg);
  border-radius:3rem;
  padding:20px;
  box-shadow:var(--glass-shadow);
  /* OPTIMIZATION: Force layer promotion to the GPU for smoother animations. */
  transform: translateZ(0);
  will-change: transform, opacity;
  overflow: hidden; /* To contain the shine effect */
  transition: box-shadow 0.2s, background 0.5s ease-in-out, backdrop-filter 0.4s ease-out, -webkit-backdrop-filter 0.4s ease-out, opacity 0.5s ease-out;
  transform-style: preserve-3d; /* NEW: Enable 3D transformations for children */
  cursor:pointer;
  text-decoration: none;
  color: var(--glass-text);
}

/* --- NEW: Performance-Optimized Backdrop Filter --- */
/* The filter is now ONLY applied when the card is visible to save performance. */
.glass-container.is-visible {
  -webkit-backdrop-filter: blur(var(--blur-radius));
  backdrop-filter: blur(var(--blur-radius));
}

/* RECONSTRUCTION: The Definitive SVG Enhancement Layer.
   This rule is now only applied if the body has BOTH svg-filter-supported
   AND perf-level-2. This prevents iOS from ever trying to parse this rule on page load.
   FIX: Add the .is-visible class to ensure the filter is only applied to on-screen cards. */
body.svg-filter-supported.perf-level-2 .glass-container.is-visible {
  -webkit-backdrop-filter: blur(var(--blur-radius)) url(#filter-hq);
  backdrop-filter: blur(var(--blur-radius)) url(#filter-hq);
}

/* --- NEW: Fast Scroll Performance Boost --- */
/* When the user is scrolling, temporarily disable the expensive backdrop-filter on grid cards
   that are NOT currently visible to ensure smooth performance. */
body.is-scrolling .grid > .glass-container:not(.is-visible) {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* --- NEW: 3-Tier Performance Level Adjustments --- */

/* Level 1 (Weak): No blur, simple transparency. */
/* FIX: Increase specificity by adding 'body' to ensure these rules override the 'body.svg-filter-supported' rule. */
/* REFACTOR: Create an even more specific selector to win the specificity war against the .svg-filter-supported rule.
   This ensures that the solid background for level 1 is always applied correctly. */
body.perf-level-1 .search-bar,
body.perf-level-1 .modal-panel,
body.perf-level-1 .info-panel {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: var(--glass-shadow); /* FIX: Restore glass border for grids and panels */
    background: linear-gradient(145deg, #4a5568, #2d3748) !important; /* Solid gradient for panels */
    color: #ffffff;
}
body.dark-mode .perf-level-1 .modal-panel,
body.dark-mode.perf-level-1 .search-bar,
body.dark-mode.perf-level-1 .modal-panel,
body.dark-mode.perf-level-1 .info-panel {
    background: linear-gradient(145deg, #2d3748, #1a202c) !important; /* NEW: Darker solid gradient */
}
body.dark-mode .perf-level-1 .info-panel {
    background: linear-gradient(145deg, #2d3748, #1a202c) !important; /* NEW: Darker solid gradient */
}
/* RECONSTRUCTION: Apply the original gray gradient to non-favorited cards in performance level 1. */
body.perf-level-1 .glass-container:not(.favorited) {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: linear-gradient(145deg, #4a5568, #2d3748) !important; /* Original gray gradient */
}
/* FIX: Consolidate and increase specificity for favorited cards in level 1 to ensure they get their unique gradient. */
body.perf-level-1 .glass-container.favorited {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: linear-gradient(145deg, #ef4444, #d946ef, #8b5cf6) !important; /* Richer, multi-color gradient */
}
body.dark-mode.perf-level-1 .glass-container.favorited {
    background: linear-gradient(145deg, #c12a4d, #a855f7, #6d28d9) !important; /* Darker multi-color gradient */
}
/* FIX: Increase specificity to ensure solid colors are applied correctly. */
body.perf-level-1 .search-button, body.perf-level-1 .search-bar {
    background-color: var(--blue-tint);
}
body.perf-level-1 #contactBtn.floating-button {
    background-color: var(--green-tint);
}
body.perf-level-1 #filterBtn.floating-button {
    background-color: var(--red-tint);
}
body.perf-level-1 #infoButton.info-button {
    background-color: var(--red-tint);
}
body.perf-level-1 #perfBtn.floating-button {
    background-color: var(--golden-tint) !important;
}
/* FIX: Increase specificity for dark mode solid button backgrounds on level 1. */
body.dark-mode.perf-level-1 .search-button, body.dark-mode.perf-level-1 .search-bar {
    background-color: #005a8c; /* Dark solid blue */
}
body.dark-mode.perf-level-1 #contactBtn.floating-button {
    background-color: #166534; /* Dark solid green */
}
body.dark-mode .perf-level-1 #filterBtn.floating-button {
    background-color: #a62244; /* Dark solid red */
}
body.dark-mode .perf-level-1 #infoButton.info-button {
    background-color: #a62244; /* Dark solid red */
}
body.dark-mode .perf-level-1 #perfBtn.floating-button {
    background-color: #b38600; /* Dark solid gold */
}

/* --- REFACTOR: Advanced proximity shine effect for cards and buttons --- */
.glass-container::before {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  /* FIX: Use multiple layered gradients for a realistic edge shine effect. */
  background:
    /* 1. A sharp, bright highlight for the core reflection (further toned down) */
    radial-gradient(circle at var(--pointer-x) var(--pointer-y),
      rgba(255, 255, 255, 0.4) 0%, /* Even less intense center */
      rgba(255, 255, 255, 0.1) 35%, /* Much softer falloff */
      transparent 50%
    ),
    /* 2. A larger, softer underlying glow for a natural feel (further toned down) */
    radial-gradient(circle at var(--pointer-x) var(--pointer-y), rgba(255, 255, 255, 0.05) 0%, transparent 70%);
  opacity: var(--spotlight-opacity, 0);
  pointer-events: none; /* Ensure it doesn't block clicks on the card */
  transition: opacity 0.4s ease-out;
  content: ''; /* Required for pseudo-element */
}

/* NEW: Simpler, more focused shine effect specifically for buttons. */
.shine-effect {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: inherit;
  background: radial-gradient(120px circle at var(--pointer-x) var(--pointer-y), rgba(255, 255, 255, 0.25), transparent 40%);
  opacity: var(--spotlight-opacity, 0);
  pointer-events: none;
  transition: opacity 0.4s ease-out;
}

/* Disable expensive pseudo-elements on lower performance tiers */
.perf-level-1 .glass-container::before, .perf-level-1 .shine-effect, .perf-level-1 .glass-container:not(.series-stack)::after {
    display: none;
}

.glass-container.force-hover-off:hover {
  pointer-events: none;
}

.glass-content {
  text-align: left;
  padding: 3rem 2rem 3rem 2rem;
  position: relative;
  /*
    FIX: This z-index ensures the text content sits on top of the series-stack's
    pseudo-elements without disrupting the layout of sibling elements like the favorite button.
  */
  z-index: 1;
}
.glass-container.favorited, body.dark-mode .glass-container.favorited {
    background: var(--glass-bg);
}

/* NEW: Use a dedicated div for the favorite overlay to avoid all pseudo-element conflicts. */
.favorite-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit; /* Match the parent card's border-radius */
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.4), rgba(217, 70, 239, 0.4), rgba(139, 92, 246, 0.4));
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
    /* Sit just behind the content but on top of the background and shine effects. */
    z-index: 0;
}

body.dark-mode .favorite-overlay {
    background: linear-gradient(145deg, rgba(193, 42, 77, 0.4), rgba(168, 85, 247, 0.4), rgba(109, 40, 217, 0.4));
}

.glass-container.favorited .favorite-overlay {
    opacity: 1; /* Fade in the gradient overlay when favorited */
}
.title {
  /* FIX: Use a dominant serif font and a stronger, layered shadow for maximum clarity. */
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
  font-family: 'Playfair Display', serif;
  text-shadow: 0 2px 3px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.5);
  /* FIX: Add transition for smooth hover animation. */
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  /* FIX: Revert to left alignment for titles */
  text-align: left;
}
.description {
  font-size: 1rem;
  opacity: .8;
  font-family: 'Open Sans', sans-serif;
  /* FIX: Add a stronger, layered shadow to lift text from the background. */
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 5px rgba(0,0,0,0.5);
  /* FIX: Add transition for smooth hover animation. */
  transition: all 0.3s ease-out;
}

/* --- NEW: Premium Text Hover Effect (for non-touch devices) --- */
/* This media query applies hover effects only on devices that can truly hover. */
@media (hover: hover) and (pointer: fine) {
  body:not(.is-scrolling) .glass-container:hover .title {
    color: var(--golden-tint);
    text-shadow: 0 0 10px color-mix(in srgb, var(--golden-tint) 70%, transparent), 0 2px 3px rgba(0,0,0,0.8);
    transform: translateY(-2px) scale(1.02);
  }
  body:not(.is-scrolling) .glass-container:hover .description {
    opacity: 1;
    color: var(--glass-text);
    transform: translateY(-1px);
  }
}

/* --- NEW: Active/Tap Effect for Text on Mobile --- */
/* This applies a similar visual effect to the hover state, but triggers on tap. */
.glass-container:active .title {
  color: var(--golden-tint);
  text-shadow: 0 0 10px color-mix(in srgb, var(--golden-tint) 70%, transparent), 0 2px 3px rgba(0,0,0,0.8);
  transform: translateY(-2px) scale(1.02);
}
.glass-container:active .description {
  opacity: 1;
  color: var(--glass-text);
  transform: translateY(-1px);
}
/* Fixed wrapper for the top-right elements */
.top-right-fixed-wrapper {
    position: fixed;
    top: 0;
    right: 0;
    width: auto;
    height: auto;
    padding: 40px; /* Match body padding */
    z-index: 10;
    will-change: transform; 
    transform: translateZ(0);
    display: flex; 
    justify-content: flex-end; 
    align-items: center;
}
.search-container-wrapper {
  position: relative; 
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  transform: none; 
  padding: 0;
}
.search-bar {
  width:0;
  height:60px;
  border:none;
  border-radius:30px;
  padding:0;
  color:var(--glass-text);
  font-size:1rem;
  opacity:0;
  visibility:hidden;
  margin-right:0px;
  /* FIX: Add the button-color variable to be used by the inner shadow. */
  --button-color: var(--blue-tint);
  background-color:color-mix(in srgb,var(--blue-tint) 20%,transparent);
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
  /* FIX: Add the tinted inner shadow to match the other glass buttons. */
  box-shadow: var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
  /* FIX: Add visibility to the transition and set a delay for smooth closing. */
  transition: width 0.5s ease-in-out, padding 0.5s ease-in-out, opacity 0.5s ease-in-out, background-color 0.5s ease-in-out, visibility 0s 0.5s, transform 0.3s ease-out, box-shadow 0.3s ease-out;
  position: absolute;
  /* FIX: Anchor the search bar to the right, next to the button. */
  right: 70px; /* button width (60px) + gap (10px) */
  z-index: 1; /* Ensure it's on top */
}
.search-bar:focus{outline:none}
/* NEW: Add a subtle lift and glow on hover for the search bar. */
body:not(.is-scrolling) .search-bar:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 30%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}

.search-bar::placeholder{color:var(--search-placeholder);}
.search-bar.active{
  /* NEW: Add jello animation on expand. */
  animation: jello-wobble 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  /* FIX: Reset the transition delay so it becomes visible immediately. */
  transition-delay: 0s;
  width:300px; /* FIX: Extended the search bar width for better usability. */
  padding: 0 20px; /* Reset padding to normal */
  opacity:1;
  visibility:visible;
}
.search-button{
  position: relative;
  width:60px;
  height:60px;
  border-radius:30px;
  /* FIX: Apply the base edge effect and the new tinted inner shadows. */
  box-shadow: var(--button-edge),
    /* REFACTOR: Use a soft, tight inner shadow with transparency to create a gradient bevel. Use a medium mix for balanced depth. */
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
  cursor: pointer;
  /* FIX: Make the button brighter by increasing the color mix percentage. */
  background-color:color-mix(in srgb,var(--blue-tint) 30%,transparent);
  --button-color: var(--blue-tint);
  display: flex;
  justify-content: center;
  align-items: center;
  /* FIX: Consolidate transitions and ensure a smooth glow for the box-shadow. */
  transition: background-color 0.5s ease-in-out, box-shadow 0.5s ease-in-out, transform 0.3s ease-in-out;
  z-index: 2; /* Ensure button is on top */
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
  overflow: hidden; /* Contain the shine effect */
  /* REFACTOR: Start button as invisible for fade-in animation. */
  opacity: 0;
  transform: scale(0.95);
}
body:not(.is-scrolling) .search-button:hover, .search-button:focus-visible {
  transform: scale(1.05);
  box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.search-button.active {
  background-color: color-mix(in srgb, var(--red-tint) 30%, transparent);
  --button-color: var(--red-tint);
}
body:not(.is-scrolling) .search-button.active:hover, .search-button.active:focus-visible {
  /* FIX: Add a red glow on hover when the button is active (showing the 'X'). */
  box-shadow: 0 0 15px color-mix(in srgb, var(--red-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.search-button svg.search-icon {
  transform: rotate(0deg) scale(1);
}
.search-button.active svg.search-icon {
  transform: rotate(45deg) scale(0);
}
.search-button svg.close-icon {
  position: absolute;
  transform: rotate(-45deg) scale(0);
}
.search-button.active svg.close-icon {
  transform: rotate(0deg) scale(1);
}
.search-button svg{
  width:30px;
  height:30px;
  fill: none;
  stroke: var(--glass-text);
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
  transition: transform 0.5s ease-in-out, stroke 0.5s ease-in-out;
}
.highlight {
  color: var(--blue-tint);
  text-shadow:0 0 10px var(--blue-tint),0 0 20px var(--blue-tint);
}
/* --- NEW: Styles for Favorite Count and Container --- */
.favorite-container {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  /*
    FIX: Set a z-index to ensure the favorite button and count always appear
    on top of the card's content and any pseudo-elements (like the series stack).
  */
  z-index: 2;
  gap: 0.5rem; /* Space between the count and the button */
}

/* NEW: Style for the vertical separator line between actions. */
.action-separator {
  width: 1px;
  height: 20px; /* Adjust height to align with the buttons */
  background-color: color-mix(in srgb, var(--glass-text) 30%, transparent);
  border-radius: 1px;
  /* NEW: Add a slight tilt to the separator. */
  transform: rotate(15deg);
}

/* FIX: Add transition for smooth position changes on hover. */
.favorite-container, .new-pill { transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); }

/* REFACTOR: Style only the favorite count on the grid */
.favorite-count {
  /* FIX: Revert to the fancier, tilted font while keeping the scroll animation. */
  font-family: 'Quattrocento Sans', sans-serif;
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--glass-text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  transition: color 0.3s ease, transform 0.2s ease-out;
}

/* NEW: Style for the comment count, mirroring the favorite count. */
.comment-count {
  font-family: 'Quattrocento Sans', sans-serif;
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--glass-text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  transition: color 0.3s ease, transform 0.2s ease-out;
}

/* FIX: Change the animation to a vertical "scroll blur" effect. */
@keyframes count-scroll-blur {
  0% { opacity: 0; filter: blur(4px); transform: translateY(-100%); }
  50% { opacity: 1; filter: blur(0); transform: translateY(0); }
  70% { transform: translateY(-10%); }
  80% { transform: translateY(5%); }
  90% { transform: translateY(-2%); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0); }
}

.count-animated {
  /* A custom cubic-bezier for a more 'bouncy' and realistic feel */
  animation: count-scroll-blur 0.5s ease-out;
}

/* --- NEW: Animations for Favorite Button & Count --- */
@keyframes heart-glow-red {
  0% {
    fill: #ef4444; /* Start red */
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.8));
  }
  100% {
    fill: var(--heart-active); /* End at the active heart color */
    filter: drop-shadow(0 0 0 rgba(239, 68, 68, 0));
  }
}

@keyframes heart-glow-gray {
  0% {
    fill: #9ca3af; /* Start gray */
    filter: drop-shadow(0 0 6px rgba(156, 163, 175, 0.7));
  }
  100% {
    fill: var(--heart-color); /* End at the default heart color */
    filter: drop-shadow(0 0 0 rgba(156, 163, 175, 0));
  }
}

.heart-join-animation { animation: heart-glow-red 1.5s ease-out; }
.heart-leave-animation { animation: heart-glow-gray 1.5s ease-out; }

@keyframes count-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.count-pop-animation {
  display: inline-block; /* Required for transform to work correctly */
  animation: count-pop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* --- Buttons from the second code --- */
.favorite-btn{
  position:relative; /* No longer needs to be absolute */
  top:auto;
  right:auto;
  width:40px;
  height:40px;
  border-radius:50%;
  opacity:1;
  transform:scale(1);
  background-color: color-mix(in srgb,var(--pink-tint) 30%,transparent);
  --button-color: var(--pink-tint);
  display: flex;
  justify-content: center;
  align-items: center;
  /* FIX: Consolidate transitions and ensure a smooth glow for the box-shadow. */
  transition: background-color 0.5s ease-in-out, box-shadow 0.5s ease-in-out, transform 0.3s ease-in-out;
  /* FIX: Apply the base edge effect and the new tinted inner shadows. */
  box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
body:not(.is-scrolling) .favorite-btn:hover, .favorite-btn:focus-visible {
  /* REFACTOR: Combine the glow with the base button shadow for a more integrated look. */
  transform: scale(1.05);
  box-shadow: 0 0 20px 5px color-mix(in srgb, var(--pink-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.favorite-btn svg{
  position:relative;
  z-index:2;
  width:20px;
  height:20px;
  fill:var(--heart-color);
  transform:translateY(1px);
  transition:fill 0.5s ease-in-out;
  stroke:black;
  stroke-width:1.5px;
}
.favorite-btn.active svg{
  fill:var(--heart-active);
}
.floating-buttons-container{
  position:fixed;
  bottom:2rem;
  left:2rem;
  display:flex;
  gap:1rem;
  z-index:10;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
body.search-active .floating-buttons-container {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}
.floating-button{
  width:60px;
  height:60px;
  border-radius:50%;
  box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
  cursor:pointer;
  display:flex;
  justify-content:center;
  align-items:center;
  background-color: color-mix(in srgb,var(--purple-tint) 30%,transparent);
  --button-color: var(--purple-tint);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background-color 0.5s ease-in-out, box-shadow 0.5s ease-in-out, transform 0.3s ease-in-out, opacity 0.3s ease-in-out; /* FIX: Consolidate transitions */
  overflow: hidden; /* Contain the shine effect */
  transform-origin: center;
  /* FIX: Set the initial state for the load animation, previously handled by JS. */
  opacity: 0;
  transform: scale(0.95);
}
#filterBtn.floating-button {
    background-color: color-mix(in srgb,var(--pink-tint) 30%,transparent);
    --button-color: var(--pink-tint);
}
/* FIX: Remove generic hover rule that was causing color conflicts.
   Each button now has its own specific hover rule. */
body:not(.is-scrolling) #filterBtn.floating-button:hover, #filterBtn.floating-button:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 0 25px 5px color-mix(in srgb, var(--pink-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
/* FIX: Change contact button to use the new green tint. */
#contactBtn.floating-button {
    background-color: color-mix(in srgb,var(--green-tint) 30%,transparent);
    --button-color: var(--green-tint);
}
body:not(.is-scrolling) #contactBtn.floating-button:hover, #contactBtn.floating-button:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 0 25px 5px color-mix(in srgb, var(--green-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
/* NEW: Style for the performance button */
#perfBtn.floating-button {
    background-color: color-mix(in srgb, var(--golden-tint) 30%, transparent);
    --button-color: var(--golden-tint);
    /* FIX: Hide the button by default. The easter egg JS will override this with an inline style. */
    opacity: 0;
    pointer-events: none;
}
body:not(.is-scrolling) #perfBtn.floating-button:hover, #perfBtn.floating-button:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 0 25px 5px color-mix(in srgb, var(--golden-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.floating-button svg{
  width:30px;
  height:30px;
  fill:var(--glass-text);
  transition:fill 0.5s ease-in-out;
  stroke:black;
  stroke-width:1.5px;
}
#no-favorites-message{
  color:var(--glass-text);
  font-size:1.5rem;
  opacity:0;
  text-align:center;
  position:fixed;
  top:50%;
  left:50%;
  transform:translate(-50%,-40%);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
  pointer-events:none;
  width:100%;
  z-index:5;
}
#no-favorites-message.show{
  opacity:1;
  transform:translate(-50%,-55%);
}
.loading{
  position:fixed;top:0;left:0;width:100%;height:100%;background:#000;z-index:9999;
  display:flex;justify-content:center;align-items:center;opacity:1;transition:opacity 1s ease-in-out;
  pointer-events:all;
}
.loading.hidden{
  opacity:0;pointer-events:none;
}
.loading-text{
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* NEW: Wrapper for the "DODCH" text to keep it on one line */
.loading-dodch-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}

.loading-text-words{
  display:inline-block;margin:0 5px;color:#fff;font-family:'Quattrocento Sans',sans-serif;
  font-size:3rem;filter:blur(0);animation:blur-text 1.5s infinite linear alternate;
}
.loading-dodch-wrapper .loading-text-words:nth-child(1){animation-delay:0s}
.loading-dodch-wrapper .loading-text-words:nth-child(2){animation-delay:.2s}
.loading-dodch-wrapper .loading-text-words:nth-child(3){animation-delay:.4s}
.loading-dodch-wrapper .loading-text-words:nth-child(4) {animation-delay:.6s}
.loading-dodch-wrapper .loading-text-words:nth-child(5) {animation-delay:.8s}
@keyframes blur-text{0%{filter:blur(0)}100%{filter:blur(4px)}}

/* --- NEW: Handwritten "Stories" Animation --- */
.loading-stories-svg {
  width: 100%;
  max-width: 250px; /* Adjust size as needed */
  margin-top: 10px; /* Position it a bit lower */
  overflow: visible; /* Ensure glow isn't clipped */
}

.loading-stories-svg text {
  font-family: 'Licorice', cursive;
  font-size: 4.5rem;
  fill: none;
  stroke: #fff;
  stroke-width: 1;
  stroke-dasharray: 450; /* Approximate length of the text path */
  stroke-dashoffset: 450;
  animation: draw-in 2.5s ease-out 1s forwards; /* Start after 1s delay */
}

@keyframes draw-in {
  to {
    stroke-dashoffset: 0;
  }
}

.notifications-container{
  position:fixed;top:3.5rem;right:100px;display:flex;align-items:center;overflow:hidden;
  white-space:nowrap;z-index:7;height:60px;width:calc(100% - 100px);pointer-events:none;
  /* FIX: Promote the entire container to its own layer to fully isolate the animation from the main grid. */
  will-change: transform;
  transform: translateZ(0);
  /* NEW: Add transition for smooth fade-out when search is active. */
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
/* NEW: Hide the notification text when the search bar is active. */
body.search-active > .notifications-container {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}
.notifications-container .notification-item{
  color:var(--notification-text);font-size:1.25rem;font-weight:bold;
  animation:slide-left 15s linear infinite;display:inline-block;animation-delay:-5s;
  /* FIX: Promote the scrolling text to its own compositor layer to isolate it from the main grid's heavy animations, ensuring a smooth scroll. */
  will-change: transform;
  transform: translateZ(0);
}
@keyframes slide-left{0%{transform:translateX(100%)}100%{transform:translateX(-100%)}}
.panel-hidden{
  pointer-events:none;height:auto;padding:0;margin:0;border:none;min-height:0;
  overflow:visible;opacity:0;transform:scale(0.9) translateY(20px);display:none;
}
.scroll-fix{
  height:1px;
  margin-top:50px;
}
/* --- Media Query for smaller screens --- */
@media (max-width: 600px) {
  .top-right-fixed-wrapper {
    padding: 20px; /* Adjust padding for mobile */
  }
  .search-bar.active {
    width: 220px; /* FIX: Extended the search bar width for mobile. */
    padding: 0 15px;
    margin-right: 0.5rem;
  }
  body {
      padding: 20px;
  }
  .floating-buttons-container{
      left:1rem;
      bottom:1rem;
  }
}
.site-footer {
  /* REFACTOR: Make the footer a fixed element that floats at the bottom. */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 1rem;
  color: var(--glass-text);
  opacity: 0.7;
  font-size: 0.9rem;
  /* NEW: Add padding on the left to avoid overlapping with the floating buttons on mobile. */
  padding-left: 180px; /* Space for the floating buttons */
  /* NEW: Add a subtle background to separate it from content scrolling behind it. */
  background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
  /* Ensure it sits on top of the bottom vignette but below the floating buttons. */
  z-index: 7;
  transition: color 0.5s ease-in-out;
}
.site-footer p {
  margin-bottom: 0.5rem; /* Add some space between footer lines */
}
/* NEW: Style for the reCAPTCHA branding text in the footer */
.recaptcha-branding {
  font-size: 0.75rem;
  opacity: 0.6;
  max-width: 400px;
  margin: 0.5rem auto 0; /* Center the text block */
  line-height: 1.4;
}
.recaptcha-branding a {
  color: var(--blue-tint); /* Use the existing blue tint for links */
}
/* REFACTOR: On smaller screens, adjust the grid layout. */
@media (max-width: 600px) {
  .site-footer {
    /* Switch to a single-column layout and let padding handle the spacing. */
    grid-template-columns: 1fr;
    /* REFACTOR: Remove incorrect 'bottom' positioning. The footer should be at the very bottom. */
    bottom: 0;
    /* Add padding to the left to create space for the floating buttons. */
    padding-left: 180px;
    font-size: 0.8rem; /* REFACTOR: Make the footer text smaller on mobile. */
  }
  /* REFACTOR: Make the reCAPTCHA branding text even smaller on mobile. */
  .recaptcha-branding {
    font-size: 0.65rem;
    line-height: 1.3;
  }
}
.made-by-who {
  font-family: 'Quattrocento Sans', sans-serif;
  font-size: 1.2rem;
  color: var(--golden-tint);
  margin-top: 10px;
}
/* --- Jello Animation CSS --- */
.squash {
  transform: scale(0.85, 0.9);
}
@keyframes jello-wobble {
  0%   { transform: scale(1,1); }
  25%  { transform: scale(0.9, 1.15) rotate(-1deg); }
  50%  { transform: scale(1.1, 0.9) rotate(1deg); }
  75%  { transform: scale(0.95, 1.05) rotate(-0.5deg); }
  100% { transform: scale(1,1) rotate(0); }
}
.jello {
  /* A custom cubic-bezier for a more 'bouncy' and realistic feel */
  animation: jello-wobble 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- NEW: Enhanced Jello Animation for Grid Cards --- */
@keyframes jello-grid-squish {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(1.02, 0.98) rotate(-0.5deg); }
  50%  { transform: scale(0.98, 1.02) rotate(0.5deg); }
  70%  { transform: scale(1.01, 0.99) rotate(-0.2deg); }
  100% { transform: scale(1, 1) rotate(0); }
}
.jello-grid {
  /* FIX: Use the new, more detailed animation for a better visual effect. */
  animation: jello-grid-squish 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- Added CSS for story details and status pills --- */
.story-length {
  position: absolute;
  bottom: 40px;
  left: 20px;
  font-size: 0.8rem;
  opacity: 0.7;
  text-transform: capitalize;
  font-family: 'Open Sans', sans-serif;
  /* FIX: Add a stronger, layered shadow for readability. */
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.5);
  /* NEW: Add transition for hover animation */
  transition: all 0.3s ease-out;
}
.creation-date {
  position: absolute;
  bottom: 40px;
  right: 20px;
  font-size: 0.8rem;
  opacity: 0.7;
  text-transform: capitalize;
  font-family: 'Open Sans', sans-serif;
  /* FIX: Add a stronger, layered shadow for readability. */
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.5);
  /* NEW: Add transition for hover animation */
  transition: all 0.3s ease-out;
}
.story-creator {
  position: absolute;
  bottom: 20px;
  font-family: 'Quattrocento Sans', sans-serif;
  /* FIX: Use italic style for a signature feel and add a stronger shadow. */
  font-style: italic;
  font-size: 0.8rem;
  opacity: 0.8;
  color: var(--golden-tint);
  text-transform: capitalize;
  /* FIX: Revert to centered alignment for creator text */
  text-align: center;
  width: 100%;
  left: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 5px rgba(0,0,0,0.7);
  /* NEW: Add transition for hover animation */
  transition: all 0.3s ease-out;
}
body:not(.is-scrolling) .glass-container:hover .story-length,
body:not(.is-scrolling) .glass-container:hover .creation-date,
body:not(.is-scrolling) .glass-container:hover .story-creator {
  opacity: 1;
}
.glass-container.no-link {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    /* NEW: Add a grayscale filter to visually "grey out" the disabled cards. */
    filter: grayscale(1);
}
/* --- New 'status' pill CSS with glow animations --- */
.new-pill {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    z-index: 10;
    transform-origin: center;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    /* REFACTOR: Use a pseudo-element for a more performant glow animation. */
    /* FIX: Removed 'position: relative' which was causing a layout bug. 'position: absolute' is correct. */
    overflow: visible; /* Allow the glow to extend beyond the pill's bounds. */
}
/* NEW: Comment button styling */
.comment-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--blue-tint) 30%, transparent);
  --button-color: var(--blue-tint);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.5s ease-in-out, box-shadow 0.5s ease-in-out, transform 0.3s ease-in-out;
  box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.comment-btn svg {
  width: 20px; height: 20px; fill: none; stroke: var(--glass-text); stroke-width: 2;
}
/* NEW: Add hover and focus glow effect for the comment button */
body:not(.is-scrolling) .comment-btn:hover, .comment-btn:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 0 20px 5px color-mix(in srgb, var(--blue-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
/* REFACTOR: Create the glow effect using a pseudo-element with blur and opacity. */
.new-pill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background-color: inherit; /* Match the pill's color */
    filter: blur(12px); /* Create the soft glow */
    z-index: -1;
    opacity: 0.7;
    /* FIX: Use the CSS variables for the glow effect and ensure smooth transitions. */
    opacity: var(--glow-opacity, 0.7);
    transform: scale(var(--glow-scale, 1));
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}
.new-pill.red {
    background-color: var(--red-tint);
    /* REFACTOR: Animate the more performant transform and opacity properties. */
    animation: pulse-glow 1.5s infinite alternate ease-in-out;
}
.new-pill.purple {
    background-color: var(--purple-tint);
    animation: pulse-glow 1.5s infinite alternate ease-in-out;
}
.new-pill.golden {
    background-color: var(--golden-tint);
    color: black;
    animation: pulse-glow 1.5s infinite alternate ease-in-out;
}
/* REFACTOR: A single, performant keyframe animation for all glows. */
@keyframes pulse-glow {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.05);
        /* Animate the pseudo-element's opacity and scale for a breathing effect */
        --glow-opacity: 1;
        --glow-scale: 1.4;
    }
}
/* --- Info Panel CSS --- */
/* Fixed wrapper for the top-left elements */
.top-left-fixed-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: 40px; /* Match body padding */
  z-index: 20;
  will-change: transform;
  transform: translateZ(0);
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.info-container-wrapper {
  position: relative; 
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
  transform: none; 
  padding: 0;
}
body.search-active .info-container-wrapper {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}
.info-container-wrapper.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden; 
}
.info-button {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  /* FIX: Apply the base edge effect and the new tinted inner shadows. */
  box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
  cursor: pointer;
  background-color: color-mix(in srgb, var(--red-tint) 30%, transparent);
  --button-color: var(--red-tint);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: box-shadow 0.5s ease-in-out, background-color 0.5s ease-in-out, transform 0.3s ease-in-out, opacity 0.3s ease-in-out; /* FIX: Consolidate transitions */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow: hidden; /* Contain the shine effect */
  /* REFACTOR: Start button as invisible for fade-in animation. */
  opacity: 0;
  transform: scale(0.95);
}
body:not(.is-scrolling) .info-button:hover, .info-button:focus-visible {
  transform: scale(1.05);
  box-shadow: 0 0 15px color-mix(in srgb, var(--red-tint) 50%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.info-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--glass-text);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.5s ease-in-out;
}
.info-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  /* Use a CSS variable for viewport height, controlled by JS */
  height: calc(var(--vh, 1vh) * 100);
  padding: 80px 40px 40px;
  box-sizing: border-box;
  background-color: var(--glass-bg);
  backdrop-filter: blur(var(--panel-blur-start));
  -webkit-backdrop-filter: blur(var(--panel-blur-start));
  z-index: 100;
  /* FIX: Make the panel itself scrollable */
  overflow-y: auto;
  display: block; /* Change from flex to block */
  text-align: left;
  will-change: transform; /* Promote to its own layer for smooth scrolling */
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out, transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), backdrop-filter 0.5s ease-in-out;
}
.info-panel.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* --- NEW: Custom Scrollbar Styling --- */
/* For Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3); /* FIX: Use a dark, transparent track. */
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.2) 8%, rgba(255, 255, 255, 0.1) 90%, rgba(0, 0, 0, 0.2) 100%); /* FIX: Create a sharp 3D glass edge effect. */
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.4); /* FIX: Add a defined edge to the glass. */
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.4) 8%, rgba(255, 255, 255, 0.3) 90%, rgba(0, 0, 0, 0.1) 100%); /* FIX: Make hover state brighter. */
}

/* For Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.5) rgba(0, 0, 0, 0.3); /* thumb color, track color */
}
.info-content {
    max-width: 600px;
    /* FIX: Center the content block within the scrollable panel */
    margin: 0 auto;
    /* Let content define its own height */
    height: auto;
}
.info-intro {
  font-style: italic;
  opacity: 0.9;
  text-align: center; /* Keep the intro centered */
  margin-bottom: 2rem !important;
}
.info-panel hr {
  border: none;
  height: 1px;
  background-color: color-mix(in srgb, var(--glass-text) 20%, transparent);
  margin: 2rem 0;
}
.info-panel h3 {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--golden-tint);
  margin-bottom: 1rem;
  text-align: left; /* Ensure subheadings are left-aligned */
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.info-panel h2 {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 1rem;
  text-align: center; /* Keep main titles centered */
  color: var(--glass-text);
  z-index: 100;
}
.info-panel p {
  font-size: 1.1rem;
  line-height: 1.6;
  margin: 0 0 1rem;
  color: var(--glass-text);
  z-index: 100;
}
.info-panel ul {
  /* FIX: Add styling for lists to ensure consistent spacing and appearance. */
  list-style: none;
  padding-left: 1rem;
  margin: 0 0 1rem;
}
.info-panel li {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  color: var(--glass-text);
  position: relative;
  padding-left: 1.5rem;
}
.info-panel li::before {
  content: '•';
  color: var(--golden-tint);
  position: absolute;
  left: 0;
}
/* --- Styles for the new Contact Panel --- */
.contact-panel-content, .social-links-content {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.panel-button {
    padding: 1rem 2rem;
    border-radius: 2rem;
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
    color: var(--glass-text);
    box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
    transition: all 0.3s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* FIX: Prevent the button from being squashed by the textarea. */
    background-color: color-mix(in srgb, var(--blue-tint) 30%, transparent);
    cursor: pointer;
    --button-color: var(--blue-tint);
    /* FIX: Remove default browser border from <button> elements to match <a> tags. */
    border: none;
}
body:not(.is-scrolling) .panel-button:hover, .panel-button:focus-visible {
    /* FIX: Add the inset shadows back to the hover state to prevent them from disappearing. */
    transform: scale(1.02);
    box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 30%, transparent), var(--button-edge),
        inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
        inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
        inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
        inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.panel-button.social {
    background-color: color-mix(in srgb, var(--purple-tint) 30%, transparent);
    --button-color: var(--purple-tint);
}
body:not(.is-scrolling) .panel-button.social:hover, .panel-button.social:focus-visible {
    /* FIX: Add the inset shadows back to the hover state for social buttons. */
    box-shadow: 0 0 15px color-mix(in srgb, var(--purple-tint) 40%, transparent), var(--button-edge),
        inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}

/* REFACTOR: A smaller, circular icon button for compact UIs like the comment input. */
.panel-button-small {
    width: 44px; /* Fixed width */
    height: 44px; /* Fixed height */
    padding: 0; /* Remove padding */
    border-radius: 50%; /* Make it a circle */
    flex-shrink: 0; /* FIX: Prevent the button from shrinking when the textarea grows. */
    color: var(--glass-text);
    box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
    transition: all 0.3s ease-in-out;
    display: flex;
    position: relative; /* NEW: Add relative positioning for pseudo-elements. */
    justify-content: center;
    align-items: center;
    border: none;
    cursor: pointer;
    background-color: color-mix(in srgb, var(--blue-tint) 20%, transparent);
    --button-color: var(--blue-tint);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow: hidden; /* NEW: Ensure shine effect is contained. */
}

/* NEW: Add a hover/focus glow effect to the small icon button. */
body:not(.is-scrolling) .panel-button-small:hover, .panel-button-small:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 40%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.social-link-button {
    padding: 1rem;
    --button-color: var(--golden-tint);
    background-color: color-mix(in srgb, var(--golden-tint) 20%, transparent);
}
body:not(.is-scrolling) .social-link-button:hover, .social-link-button:focus-visible {
    /* FIX: Add the full box-shadow definition to prevent inheriting the problematic .panel-button:hover rule. */
    transform: scale(1.02);
    box-shadow: 0 0 15px color-mix(in srgb, var(--golden-tint) 30%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}

/* --- NEW: Social Media Icon Styling --- */
.social-link-button {
  gap: 0.75rem; /* Add space between the icon and the text */
  align-items: center; /* Ensure icon and text are perfectly centered vertically */
}

/* NEW: Style for the image-based icons */
.social-icon-img {
  width: 28px;  /* A slightly larger, explicit size for image icons */
  height: 28px;
  object-fit: contain; /* Ensure the image scales correctly */
}

/* Close button styling */
.close-button {
  /* FIX: Change position to 'fixed' to keep it from scrolling with the panel content. */
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid transparent; /* Reserve space for the border-like shadow */
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.4s ease-out, transform 0.4s ease-out, box-shadow 0.3s ease-out;
  z-index: 103; /* FIX: Increase z-index to ensure it's on top of vignettes and headers. */
  /* FIX: Hide the button by default; JS will show it when its panel is active. */
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  /* FIX: Apply the base edge effect and the new tinted inner shadows. */
  box-shadow: var(--button-edge),
    inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000),
    inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
  background-color: color-mix(in srgb, var(--red-tint) 30%, transparent);
  --button-color: var(--red-tint);
}
.close-button.active {
  /* FIX: Make the button visible when its panel is active. */
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.close-button:hover, .close-button:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 0 15px color-mix(in srgb, var(--red-tint) 40%, transparent), var(--button-edge), inset 0 2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 0 -2px 3px color-mix(in srgb, var(--button-color) 60%, #000), inset 2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000), inset -2px 0 3px color-mix(in srgb, var(--button-color) 60%, #000);
}
.close-button svg {
  width: 20px;
  height: 20px;
  stroke: var(--glass-text);
  stroke-width: 2;
}
body.info-panel-open {
  overflow: hidden;
}

/* --- REFACTOR: Disable background blur on grid cards ONLY when a panel is open --- */
/* This rule is now more specific to avoid conflicts and only targets the main grid. */
body.info-panel-open .grid > .glass-container,
body.info-panel-open .grid > .series-stack,
body.info-panel-open .search-bar,
body.info-panel-open .search-button,
body.info-panel-open .floating-button,
body.info-panel-open .info-button {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  transition: backdrop-filter 0.3s ease-in-out, -webkit-backdrop-filter 0.3s ease-in-out;
}

/* --- FIX: Override the above rule to ensure the comment input area is always visible --- */
/* The .info-panel-open rule was incorrectly hiding the .glass-button-base comment input. */
/* This highly specific rule ensures it remains visible inside the comments modal. */
body.info-panel-open #commentsModal .comment-input-area.glass-button-base {
  -webkit-backdrop-filter: blur(4px) !important;
  backdrop-filter: blur(4px) !important;
  opacity: 1 !important;
}

body.info-panel-open #seriesModal .glass-container:hover {
  pointer-events: auto;
}

/* --- NEW: Disable hover effects when a panel is open --- */
/* This selector specifically targets grid cards and disables their hover effects. */
body.info-panel-open .grid > .glass-container {
  pointer-events: none;
  cursor: default;
}

/* FIX: Re-enable interaction for elements inside ANY active modal panel. */
body.info-panel-open .modal-panel.active .glass-container,
body.info-panel-open .modal-panel.active .favorite-btn,
body.info-panel-open .modal-panel.active .glass-content {
    pointer-events: auto;
    cursor: pointer;
}
/* This re-enables interaction for elements inside the modals. */
body.info-panel-open #seriesModal .favorite-btn,
body.info-panel-open #seriesModal .glass-content {
    pointer-events: auto;
    cursor: pointer;
}

/* FIX: Add the enhanced text shadow to series part cards for better contrast and consistency. */
.series-parts-grid .title {
    text-shadow: 0 2px 3px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.5);
}
.series-parts-grid .description {
    text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 5px rgba(0,0,0,0.5);
}


@media (max-width: 600px) {
  .top-left-fixed-wrapper {
    padding: 20px;
  }
  .info-panel {
    padding: 60px 20px 20px;
  }
  .info-panel h2 {
    font-size: 1.5rem;
  }
  .info-panel p {
      font-size: 1rem;
  }

  /* NEW: Tutorial Panel specific styles for mobile */
  .tutorial-content ul {
    padding-left: 0;
    text-align: left;
  }
  .tutorial-content li {
    padding-left: 0;
    margin-bottom: 1rem;
  }
  .tutorial-content li::before {
    content: ''; /* Hide the bullet on mobile for a cleaner look */
  }

  /* FIX: Adjust padding on the series modal for mobile to ensure the grid is centered. */
  #seriesModal {
    padding-left: 20px;
    padding-right: 20px;
  }
}
.tutorial-icon, .tutorial-icon-text {
  width: 24px;
  height: 24px;
  flex-shrink: 0; /* Prevent icon from shrinking */
  display: flex; /* Use flex to center the icon/emoji */
  align-items: center;
  justify-content: center;
}
.tutorial-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--glass-text);
  stroke-width: 2;
  fill: none;
}

/* --- Tutorial Panel Specific Styles --- */
.tutorial-section {
  margin-bottom: 2rem;
}
.tutorial-heading {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--golden-tint);
  margin-bottom: 1rem;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
#tutorialStartButton {
  margin-top: 2rem;
  width: 100%;
  /* FIX: Explicitly set the background color and ensure the hover effect is smooth. */
  background-color: color-mix(in srgb, var(--blue-tint) 15%, transparent);
}
#tutorialStartButton:hover, #tutorialStartButton:focus-visible {
  /* FIX: Add back the scale transform to match other buttons, along with the box-shadow. */
  transform: scale(1.02);
  box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 40%, transparent), var(--button-edge);
}
#tutorialPanel .info-content li {
  display: flex;
  align-items: flex-start;
  /* FIX: Remove padding and use a larger gap for better spacing */
  padding-left: 0;
  gap: 1.5rem;
}
/* FIX: Add extra padding to the bottom of the tutorial content to create scroll space. */
#tutorialPanel .info-content {
  padding-bottom: 10vh; /* 10% of the viewport height */
}
#tutorialPanel .info-content li > div {
  line-height: 1.5;
}
#tutorialPanel li::before {
  content: none;
}

/* --- NEW: Styles for Panel Load Animation --- */
.panel-anim-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
/* REFACTOR: Animate items when they get the 'in-view' class, not just when the panel is active. */
.panel-anim-item.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* --- REFACTOR: Unified Modal Panel Styling --- */
.modal-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  height: calc(var(--vh, 1vh) * 100);
  background-color: var(--glass-bg);
  backdrop-filter: blur(var(--panel-blur-start));
  -webkit-backdrop-filter: blur(var(--panel-blur-start));
  z-index: 100;
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out, transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), backdrop-filter 0.5s ease-in-out;
  /* Default to a centered layout for simple modals like Contact/Social */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
.modal-panel.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
/* --- END REFACTOR --- */

/* --- NEW: Comments Modal Specific Styling --- */
/* Override the default centered flex layout for the comments modal */
#commentsModal {
    display: block; /* Change to block to allow for a scrolling layout */
    /* FIX: The definitive fix. Hide horizontal overflow on the modal itself. */
    overflow-x: hidden;
    padding: 0; /* Remove default padding */
}

/* NEW: Generic styling for fixed modal headers */
.modal-header-fixed {
    position: fixed;
    top: 0;
    left: 50%;
    width: 100%;
    max-width: 800px; /* Match content width */
    padding: 40px 40px 0;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 101;
    opacity: 0;
    transform: translate(-50%, -100%);
    transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.comments-panel-content {
    width: 100%;
    max-width: 800px; /* Set a max-width for the content area */
    margin: 0 auto; /* Center the content block */
    /* REFACTOR: This is now the main scrollable area */
    overflow-y: auto;
    /* FIX: The definitive fix to prevent any horizontal scrolling within the comments modal. */
    scroll-behavior: smooth; /* NEW: Enable smooth scrolling for this container */
    overflow-x: hidden;
    height: 100%;
    padding: 170px 0 140px 0; /* REFACTOR: Remove horizontal padding to allow comments to align to the edges. */
}

/* REFACTOR: New container for the truly fixed title */
.modal-header-fixed.active {
    opacity: 1;
    transform: translate(-50%, 0); /* Slide into view */
}

/* NEW: Styling for icons within panel buttons */
.panel-button {
  gap: 0.5rem; /* Space between icon and text/other icons */
}

.panel-button .button-icon {
  width: 1.25em; /* Size relative to font-size */
  height: 1.25em;
  fill: currentColor; /* Inherit color from button text */
  stroke: none; /* For filled icons */
  flex-shrink: 0;
}

/* NEW: Add outline style for the mail/send icon */
#submitStoryBtn .button-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2px;
}

/* NEW: Styling for inline social media icons */
.social-icons-inline {
  display: flex;
  align-items: center;
  gap: 0.25rem; /* Small gap between the inline social icons */
  flex-shrink: 0;
}

.social-icon-inline {
  width: 18px; /* Smaller size for inline icons */
  height: 18px;
  object-fit: contain;
  vertical-align: middle; /* Ensure they align with text */
}

#commentsModalTitle {
    font-family: 'Playfair Display', serif;
    color: var(--glass-text);
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    text-align: left; /* Align title to the left */
    /* Resetting properties as it's now inside a fixed container */
    position: relative;
    transform: none;
    width: 100%; /* Take full width to allow left alignment of children */
    /* REFACTOR: Use flexbox to stack the main title and subtitle */
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* Add a small gap between the title and subtitle */
}

/* NEW: Shared style for main modal titles */
.modal-main-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--glass-text);
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

#socialModalTitle {
    text-align: left; /* Align to the top-left */
}

/* NEW: Style for the main "Comments" heading */
.main-comment-title {
    font-size: 2.5rem;
    font-weight: 900;
}

/* NEW: Style for the story title subtitle */
.story-title-for-comments {
    font-size: 1rem;
    font-weight: normal;
    color: var(--golden-tint);
    opacity: 0.9;
}

/* REFACTOR: Target the count span more specifically */
#commentsModalTitle .main-comment-title #commentsModalCount {
    font-size: 1.5rem;
    opacity: 0.7;
    font-weight: normal;
    margin-left: 0.5rem;
}

.comments-list {
    flex-grow: 1; /* Allow the list to take up available space */
    /* REFACTOR: Add flex properties to enable bubble alignment. */
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.comment-input-area {
    /* REFACTOR: Make the input area a true fixed footer, independent of the modal. */
    position: fixed; /* Position relative to the viewport */
    bottom: 0;
    bottom: 1rem; /* REFACTOR: Raise the input area slightly from the bottom */
    left: 50%;
    width: 100%;
    max-width: 800px; /* Match the modal content width */
    padding: 0.5rem 25px 0.75rem 25px; /* TWEAK: Increased side padding to move send button further from the edge on mobile */
    box-sizing: border-box;
    display: flex;
    gap: 1rem;
    align-items: center;
    z-index: 101; /* Sit on top of the modal backdrop */
    /* Animation for appearing/disappearing */
    opacity: 0; /* REFACTOR: Align items to the bottom for better visual balance with the textarea. */ align-items: flex-end;
    transform: translate(-50%, 100%); /* Start off-screen and centered */
    transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}
.comment-input-area.active {
    opacity: 1;
    transform: translate(-50%, 0); /* Slide into view */
    pointer-events: auto; /* REFACTOR: Increased width for a more spacious input area */ max-width: 1100px;
}

/* --- NEW: CSS-Only Textarea Auto-Resize --- */
/* This wrapper uses a grid layout to stack the textarea and a hidden pseudo-element on top of each other. */
.textarea-wrapper {
    display: grid;
    flex-grow: 1;
}

/* The textarea and its pseudo-element twin share the same grid cell. */
.textarea-wrapper::after,
.comment-input-area #commentTextarea {
    grid-area: 1 / 1 / 2 / 2;
}

/* The ::after pseudo-element is a hidden copy of the textarea's content.
   It's what actually drives the height of the wrapper. */
.textarea-wrapper::after {
    content: attr(data-replicated-value) " "; /* Use the data attribute from JS */
    white-space: pre-wrap; /* Allow wrapping */
    visibility: hidden; /* Keep it from being seen */
    padding: inherit; /* Inherit padding from the textarea for accurate sizing */
}

/* REFACTOR: Apply the glass effect to the children of the input area, not the container itself. */
.comment-input-area #commentTextarea {
    /* REFACTOR: Remove min-height and set height to 100% to fill the wrapper. */
    height: 100%;
    max-height: 150px; /* NEW: Set a maximum height to prevent excessive growth */
    padding: 0.75rem 1rem; /* REFACTOR: Adjusted padding */
    border-radius: 1.25rem; /* REFACTOR: Adjusted radius */
    /* REFACTOR: Set rows to 1 for a single-line starting height. */
    rows: 1;
    resize: none;
    color: var(--glass-text);
    background-color: var(--glass-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: var(--button-edge);
    border: none;
    overflow: hidden; /* NEW: Ensure the shine effect is contained within the textarea's rounded corners. */
    transition: all 0.3s ease-out;
    flex-grow: 1; /* Allow the textarea to grow and fill the available space */
}
/* FIX: Set a dark color for the comment textarea in light mode for readability. */
.comment-input-area #commentTextarea {
    color: #374151; /* A dark gray color */
}
body.dark-mode .comment-input-area #commentTextarea {
    color: var(--glass-text); /* Revert to light text in dark mode */
}

/* FIX: Set a dark color for the comment textarea placeholder in light mode. */
.comment-input-area #commentTextarea::placeholder {
    color: #4b5563; /* A medium-dark gray */
}
body.dark-mode .comment-input-area #commentTextarea::placeholder {
    color: var(--search-placeholder); /* Revert to light placeholder in dark mode */
}

/* FIX: Set a dark color for the "no comments" message in light mode. */
.no-comments-message {
    color: var(--glass-text); /* Default to light text */
}
body.dark-mode .no-comments-message {
    color: var(--glass-text); /* Revert to light text in dark mode */
}
.comment-input-area #commentTextarea:focus {
    outline: none;
    box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 40%, transparent), var(--button-edge);
}
.comment-input-area #postCommentBtn {
    flex-shrink: 0; /* Prevent button from shrinking */
}

/* NEW: On mobile, reduce the padding of the input area even more. */
@media (max-width: 600px) {
    .comment-input-area {
        padding: 0.75rem 15px 1rem 15px;
    }
}

/* --- END Comments Modal Styling --- */

/* --- NEW: Vignettes for Modals (Comments, Series, etc.) --- */
.top-vignette-modal {
    position: fixed;
    /* REFACTOR: Hide by default. They will be shown when the modal is active. */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-out;
    top: 0; /* Align to the top of the viewport */
    left: 0; /* Align to the left edge */
    width: calc(100vw - 12px); /* FIX: Span viewport width minus the scrollbar width to prevent overlap. */
    height: 170px; /* Match the padding of the comments content */
    /* FIX: Add backdrop-filter to create the blur effect, matching the home page. */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 101; /* Sit on top of the modal content but behind the header/close button */
    background: linear-gradient(to bottom, 
        color-mix(in srgb, var(--glass-bg) 95%, black) 40%, 
        transparent 100%
    );
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

.bottom-vignette-modal {
    position: fixed;
    /* REFACTOR: Hide by default. */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-out;
    bottom: 0; /* Align to the bottom of the viewport */
    left: 0; /* Align to the left edge */
    width: calc(100vw - 12px); /* FIX: Span viewport width minus the scrollbar width to prevent overlap. */
    height: 140px; /* Match the padding of the comments content */
    /* FIX: Add backdrop-filter to the bottom vignette as well. */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 101; /* Sit on top of the modal content but behind the input area */
    background: linear-gradient(to top, 
        color-mix(in srgb, var(--glass-bg) 95%, black) 40%, 
        transparent 100%
    );
    /* FIX: Add a mask to make the blur effect fade out smoothly, matching the top vignette. */
    mask-image: linear-gradient(to top, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to top, black 70%, transparent 100%);
}

/* REFACTOR: Show the vignettes when they have the 'active' class. */
.top-vignette-modal.active,
.bottom-vignette-modal.active {
    opacity: 1;
}
/* ==========================================================================
   Comments Modal - New Bubble Style
   ========================================================================== */

/* REFACTOR: Replaced the bounce animation with a more playful "jello" wobble effect. */
@keyframes comment-jello-in {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.1, 0.9) rotate(1deg);
  }
  70% {
    transform: scale(0.95, 1.05) rotate(-1deg);
  }
  100% {
    opacity: 1;
    transform: scale(1, 1) rotate(0);
  }
}

/* NEW: Add a fade-out animation for deleted comments */
@keyframes comment-fade-out {
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.comment-item.fading-out {
  animation: comment-fade-out 0.4s ease-out forwards;
}

/* NEW: Style for comments made by the current user (right-aligned) */
/* REFACTOR: Use 'order' property to correctly position elements for user's own comments. */
.comment-item.is-user {
  flex-direction: row-reverse; /* Reverses the order to [content] [pic] */
  align-self: flex-end; /* Aligns the entire item to the right of the container */
  /* FIX: Removing 'justify-content' allows the container to shrink-to-fit its content, keeping the picture and bubble together. */
}

/* Main container for each comment */
.comment-item {
  display: flex;
  align-items: flex-start; /* Align items to the top */
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  /* REFACTOR: Apply the new jello-in animation. It will be triggered by the staggered delay in JS. */
  opacity: 0; /* Start hidden */
  animation: comment-jello-in 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  /* NEW: Align all comments to the left by default */
  align-self: flex-start;
}

.comment-item {
  display: flex;
  align-items: flex-start; /* Align items to the top */
  flex-shrink: 0; /* NEW: Prevent items from shrinking, which helps with smooth layout shifts */
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  /* The animation delay is set in script.js */
}
.comment-item:first-child { animation-delay: 0s !important; } /* NEW: Ensure the newest comment animates immediately */


.comment-item:last-child {
  border-bottom: none;
}

/* Small, circular profile picture */
.comment-author-pic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0; /* Prevent image from shrinking */
}
/* NEW: Wrapper for comment content to establish a positioning context for the delete button. */
.comment-content-wrapper {
  position: relative; /* This is the new positioning context */
  display: flex;
  flex-direction: column;
}

/* Container for the comment text and header */
.comment-body {
  /* REFACTOR: Increased background opacity and added a subtle drop shadow for better contrast and depth. */
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  padding: 10px 16px;
  position: relative;
  max-width: 85%; /* Prevent bubbles from getting too wide on large screens */
  /* FIX: Ensure the bubble itself can shrink within its flex container, forcing long content to wrap. */
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.2); /* REFACTOR: Slightly brighter border for a crisper edge. */
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); /* NEW: Add a stronger shadow to lift the bubble more. */
}

/* NEW: Style for the current user's comment bubble */
.comment-item.is-user .comment-body {
  background: color-mix(in srgb, var(--blue-tint) 30%, rgba(0,0,0,0.4)); /* Blue tint for user's own comments */
  border-color: color-mix(in srgb, var(--blue-tint) 50%, transparent);
}

/* NEW: Align text to the right for the current user's comment bubble */
.comment-item.is-user .comment-text {
  text-align: right;
}

/* REFACTOR: Align the header to the right for the user's comment, but keep the natural order of name and date. */
.comment-item.is-user .comment-header {
  justify-content: flex-end; /* Align items to the right */
  flex-direction: row; /* Keep the natural DOM order (Name, then Date) */
}


/* Comment header with author name and date */
.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 1rem; /* Add a minimum gap between the name and date */
}

.comment-author-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
}

.comment-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

/* The comment text itself */
.comment-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  /* REFACTOR: Use modern properties to force long words/strings to wrap and prevent horizontal overflow. */
  overflow-wrap: break-word;
  word-break: break-word;
  margin: 0;
}

/* Delete button styling */
.delete-comment-btn {
  position: relative; /* Change from absolute to relative */
  align-self: flex-end; /* Align to the right */
  margin-top: 4px; /* Add some space above the button */
  background: rgba(0,0,0,0.2); /* Add a subtle background */
  border: none;
  color: rgba(255, 255, 255, 0.5); /* Make text even more subtle */
  font-size: 0.65rem; /* Smaller font size for a text button */
  line-height: 1;
  padding: 1px 4px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
  border-radius: 6px; /* Keep the rounded corners */
}

.delete-comment-btn:hover {
  color: var(--red-tint);
  background: rgba(0,0,0,0.4);
}


/* --- NEW: Auth Container & Login Button Styles --- */
.auth-container {
  display: flex;
  align-items: center;
  border-radius: 30px;
  padding: 5px;
  margin-left: 1rem; /* Space between info and login button */
  transition: all 0.4s ease-in-out;
  overflow: hidden;
  /* FIX: Apply the glass effect and shine to the auth container */
  background: var(--glass-bg);
  box-shadow: var(--button-edge); 
  backdrop-filter: blur(4px);
  --button-color: var(--blue-tint);
  -webkit-backdrop-filter: blur(4px);
  position: relative; /* Needed for the shine effect */
  cursor: pointer;
}

/* NEW: When logged in, hide the glass effect by default */
.auth-container.logged-in {
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0; /* Remove padding to only show the picture */
  margin-left: 1.5rem; /* Adjust margin to compensate for padding removal */
}

/* NEW: Add hover effect for the auth container */
body:not(.is-scrolling) .auth-container:hover, .auth-container:focus-visible,
.auth-container.logged-in:hover { /* NEW: Re-apply glass effect on hover when logged in */
  transform: scale(1.05);
  box-shadow: 0 0 15px color-mix(in srgb, var(--blue-tint) 40%, transparent), var(--button-edge);
}

.auth-container:hover .logout-button {
  display: block; /* Show on hover */
}

.login-button {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--glass-text);
  font-weight: bold;
  padding: 0;
}

.login-button .login-text {
  margin: 0 10px;
  font-size: 0.9rem;
}
.login-button .profile-pic {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.auth-container.logged-in .profile-pic {
  width: 45px; /* Make the picture slightly larger when it's the only element */
  height: 45px;
  border: none; /* Remove the border in the default state */
  box-shadow: 0 2px 5px rgba(0,0,0,0.4); /* Add a subtle shadow for depth */
}

.logout-button {
  background: none;
  border: none;
  color: var(--glass-text);
  font-weight: bold;
  cursor: pointer;
  padding: 5px 10px;
  font-size: 0.8rem;
  opacity: 0.7;
  /* NEW: Hide logout button by default */
  display: none;
}

/* NEW: Re-apply glass styles on hover for logged-in state */
.auth-container.logged-in:hover {
    background: var(--glass-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 5px;
}

/* --- Series Stack Styles --- */
.series-stack {
  position: relative; /* Anchor for pseudo-elements and the main card */
  cursor: pointer;
  /* FIX: Restore the default glass background. This makes the top card opaque relative to the stack behind it. */
  background: var(--glass-bg);
}

/* On hover, the entire stack element lifts and scales */
body:not(.is-scrolling) .series-stack:hover {
  transform: scale(1.03) translateY(-10px);
  transition: transform 0.3s ease-out;
}

/* Create the "ghost" cards behind the main one using pseudo-elements on the container */
/* FIX: Increase specificity to ensure these rules only apply to the main grid on the index page. */
/* This prevents the rule from incorrectly hiding the bookmark icon on story pages. */
.grid > .series-stack::before,
.grid > .series-stack::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%; /* Perfectly match the container's size */
  height: 100%; /* Perfectly match the container's size */
  border-radius: 3rem; /* Exactly match the main card's border-radius */

  /* The backdrop-filter applies to the card body */
  z-index: -1; /* Sit behind the main card's content. */
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Smoother transition */
  /* FIX: Set the background and shadow for the stacked cards. */
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  /* FIX: Make the stacked cards invisible by default. */
  opacity: 0;
  /* FIX: Start the cards directly behind the main card. */
  transform: translateY(0) scale(1);
}

/* FIX: On hover, make the stacked cards visible and move them into position. */
body:not(.is-scrolling) .grid > .series-stack:hover::before {
  opacity: 1;
  transform: translateY(14px) scale(0.96); /* Furthest back card */
  z-index: -3;
  /* FIX: Add a distinctive golden tint to the third card in the stack. */
  background: color-mix(in srgb, var(--golden-tint) 20%, var(--glass-bg));
}

body:not(.is-scrolling) .grid > .series-stack:hover::after {
  opacity: 1;
  transform: translateY(7px) scale(0.98); /* Middle card */
  z-index: -2;
}
/* FIX: On hover, smoothly move the pill and favorite button down to make space for the stacked cards. */
body:not(.is-scrolling) .series-stack:hover .new-pill {
  top: 2.5rem;
}

body:not(.is-scrolling) .series-stack:hover .favorite-container {
  top: 2rem;
}

.series-stack.open {
  cursor: default;
  pointer-events: none;
}

/* --- NEW: Styles for the Series Modal, mimicking the Info Panel --- */
#seriesModal {
  /* This makes the modal scrollable if content overflows */
  overflow-y: auto;
  /* REFACTOR: Remove flex alignment to allow block-level centering and scrolling. */
  display: block;
  /* REFACTOR: Adjust padding to account for the new fixed title. */
  padding-top: 120px;
  padding-bottom: 40px;
}

#seriesModalTitle {
  /* REFACTOR: Make the title a fixed header within the modal for better context. */
  position: fixed;
  top: 40px; /* Position it below the close button */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;
  z-index: 101; /* Ensure it's above the grid but below the close button if needed */
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--glass-text);
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
  /* Prevent the title from blocking clicks on the modal background for closing */
  pointer-events: none;
}

.series-parts-grid {
  /* REFACTOR: Change from a multi-column grid to a single-column flex layout. */
  /* REFACTOR: Use a grid layout to perfectly match the main page's card sizing. */
  display: grid; /* FIX: Use the same responsive grid layout as the main page. */
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  /* REFACTOR: Add a small top margin to create space below the fixed title. */
  margin-top: 1rem; /* FIX: Ensure padding is included within the element's total width to prevent horizontal overflow. */
  box-sizing: border-box;
}

/* FIX: The grid container now handles sizing, so no special width is needed on the cards. */

/* --- NEW: Top & Bottom Vignettes for Main Page --- */
.top-vignette-main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 150px;
    z-index: 6; /* Sit behind the header buttons (z-index 10+) and notification bar (z-index 7) */
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, transparent 100%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.bottom-vignette-main {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 130px; /* TWEAK: Slightly increased height to better blend with the footer's new position. */
    z-index: 6; /* Sit behind the floating buttons (z-index 10) */
    pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,0.35) 0%, transparent 100%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    mask-image: linear-gradient(to top, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to top, black 50%, transparent 100%);
}

/* NEW: Hide vignettes on lowest performance level */
.perf-level-1 .top-vignette-main,
.perf-level-1 .bottom-vignette-main {
    display: none;
}

/* --- NEW: reCAPTCHA Badge Fix --- */
/* Hide the reCAPTCHA badge. Per Google's policy, the required branding and links have been added to the site footer. */
.grecaptcha-badge {
    visibility: hidden !important;
}

/* v1.0.1 */
