* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@font-face {
  font-family: "JMH Typewriter";
  src: url('../webfonts/JMH Typewriter.eot');
  src: url('../webfonts/JMH Typewriter.eot') format('embedded-opentype'),
       url('../webfonts/JMH Typewriter.woff2') format('woff2'),
       url('../webfonts/JMH Typewriter.woff') format('woff'),
       url('../webfonts/JMH Typewriter.ttf') format('truetype');
}

@font-face {
   font-family: "AnotherDanger";
  src: url("../webfonts/Another Danger - Demo.eot");
  src: url("../webfonts/Another Danger - Demo.eot?#iefix") format("embedded-opentype"),
       url("../webfonts/Another Danger - Demo.woff2") format("woff2"),
       url("../webfonts/Another Danger - Demo.woff") format("woff"),
       url("../webfonts/Another Danger - Demo.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

html, body {
  height: 100%;  
  padding: 0;
  margin: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: calc(14px + (20 - 14) * ((100vw - 300px) / (1600 - 300)));
  line-height: 1.6;
  display: flex;
  flex-direction: column; 
  color: #FEFEFE;
  background: linear-gradient(135deg, #0c0c0c 0%, #1a1a1a 50%, #0c0c0c 100%);
  background-attachment: fixed;
}

/* Enhanced Links */
a {
  color: #89c403;
  text-decoration: none;
  transition: all 0.3s ease;
}

a:hover {
  color: #77a809;
  text-decoration: underline;
}

a:visited {
  color: #6a9508;
}

a:visited:hover {
  color: #89c403;
}

main {
  flex: 1 0 auto;
  padding: 2rem 0;
}

footer {
  flex-shrink: 0;
}

/* Enhanced Header */
header {
  align-items: center;
  display: flex;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  text-align: center;
  padding: 1rem;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(128, 0, 0, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

header.scroll {
  background: rgba(0, 0, 0, 0.98);
  padding: 0.75rem;
}

header h1 {   
  margin: 0;
  letter-spacing: 0.2em;
  font-size: clamp(1.5rem, 4vw, 3rem);
  background: linear-gradient(45deg, #800000 0%, #ff4444 50%, #800000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'AnotherDanger', sans-serif;
  text-shadow: 0 0 30px rgba(255, 68, 68, 0.3);
  transition: all 0.3s ease;
  cursor: default;
}

header h1:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 0 10px rgba(255, 68, 68, 0.5));
}

header h1 small {
  display: block;
  font-size: 0.6em;
  margin-top: 0.5rem;
}

/* Improved Main Content */
main {
  margin-top: 120px; /* Account for fixed header */
  padding: 2rem 0;
}

main > a {
  display: block;
  text-align: center;
  margin: 2rem auto;
  padding: 1rem 2rem;
  background: linear-gradient(45deg, #800000, #a00000);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: all 0.3s ease;
  max-width: 400px;
  box-shadow: 0 4px 15px rgba(128, 0, 0, 0.3);
}

main > a:hover {
  background: linear-gradient(45deg, #a00000, #c00000);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(128, 0, 0, 0.4);
  color: white;
  text-decoration: none;
}
main > a:visited,
main > a:visited:hover {
  color: white;
}

/* Enhanced Filter Buttons */
.filter-button-group {
  text-align: center;
  padding: 2rem 0;
  margin-bottom: 2rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

.filter-button-group button {
  font-family: "JMH Typewriter", monospace;
  cursor: pointer;
  color: #fff;
  border-radius: 25px;
  padding: 0.75rem 1.5rem;
  margin: 0.25rem;
  border: 2px solid transparent;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  background: linear-gradient(45deg, #333, #555);
  position: relative;
  overflow: hidden;
}

.filter-button-group button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.filter-button-group button:hover::before {
  left: 100%;
}

.filter-button-group button:hover {
  color: #fff;
  border-color: #89c403;
  background: linear-gradient(45deg, #89c403, #77a809);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(137, 196, 3, 0.3);
}

.filter-button-group button.active {
  color: #fff;
  background: linear-gradient(45deg, #800000, #a00000);
  border-color: #ff4444;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.4);
}

/* Improved Cards */
.element-item {
  width: 100%;
  text-align: center;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}   

a.card {  
  font-family: "JMH Typewriter", monospace;
  border-radius: 15px;
  color: #fff;
  text-decoration: none;
  text-align: center; 
  background: linear-gradient(135deg, #1CB807 0%, #159806 100%);
  width: 100%;
  padding: 2rem 1rem;
  position: relative; 
  display: block;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  transition: all 0.4s ease;
  border: 2px solid transparent;
  overflow: hidden;
  font-weight: 600;
  letter-spacing: 0.5px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

a.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

a.card:hover::before {
  transform: translateX(100%);
}

a.external.card { 
  background: linear-gradient(135deg, #800000 0%, #600000 100%);
}

a.card:visited:hover,
a.card:hover {
  color: #fff;
  background: linear-gradient(135deg, #7C0200 0%, #5C0000 100%);
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.3);
}

a.external.card:hover {
  background: linear-gradient(135deg, #a00000 0%, #800000 100%);
}

/* Enhanced Back to Top Button */
#backTop {
  cursor: pointer;
  position: fixed;
  padding: 1rem;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  outline: none;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
  background: linear-gradient(45deg, #800000, #a00000);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(128, 0, 0, 0.3);
}

#backTop.visible {
  visibility: visible;
  opacity: 0.9;
}

#backTop:hover {
  opacity: 1;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(128, 0, 0, 0.4);
}

#backTop i {
  color: white;
  font-size: 1.2rem;
}

/* Container improvements */
.container-fluid {
  margin-right: auto;
  margin-left: auto;
  padding-right: 2rem;
  padding-left: 2rem;
  max-width: 1400px;
}

/* Responsive improvements */
@media (max-width: 768px) {
  header h1 {
    font-size: clamp(1.2rem, 6vw, 2rem);
    letter-spacing: 0.1em;
  }
  
  .filter-button-group button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    margin: 0.2rem;
  }
  
  a.card {
    padding: 1.5rem 1rem;
    min-height: 100px;
  }
  
  main {
    margin-top: 100px;
  }
  
  .modal {
    max-width: 95vw !important;
    margin: 1rem !important;
  }
  
  .modal .modal-content {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .filter-button-group {
    padding: 1rem 0;
  }
  
  .filter-button-group button {
    display: block;
    width: 80%;
    margin: 0.5rem auto;
  }
  
  a.card {
    margin-bottom: 1rem;
  }
}

/* Enhanced footer */
footer {
  text-align: center;
  margin-bottom: 3rem !important;
  padding: 2rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Smooth animations for grid items */
.element-item {
  transition: all 0.4s ease;
}

.element-item.isotope-hidden {
  opacity: 0;
  transform: scale(0.8);
}

.element-item.isotope-item {
  opacity: 1;
  transform: scale(1);
}
.modal.pdf-modal .modal-content {
    max-width: 95vw;
    max-height: 95vh;
    padding: 1.5rem;
}

.pdf-actions {
    text-align: center;
    margin: 1rem 0;
}

.pdf-actions .btn {
    display: inline-block;
    margin: 0 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(45deg, #800000, #a00000);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.pdf-actions .btn:hover {
    background: linear-gradient(45deg, #a00000, #c00000);
    transform: translateY(-2px);
}

.pdf-container iframe {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
}

.pdf-error {
    text-align: center;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

.pdf-error i {
    font-size: 3rem;
    color: #ffc107;
    margin-bottom: 1rem;
}

 /* Fixed Modal Styles with Enhanced Overflow Handling */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    backdrop-filter: blur(5px);
    overflow: hidden; /* Prevent scrolling on overlay */
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #333;
    border-radius: 15px;
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* Hide overflow on modal container */
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

.modal-content {
    padding: 2rem;
    overflow-y: auto; /* Allow scrolling within content area */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    flex: 1;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #800000 #f1f1f1;
}

/* Webkit scrollbar styling for modal content */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #800000;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a00000;
}

.modal h1, .modal h2, .modal h3 {
    color: #800000;
    margin-top: 0;
    margin-bottom: 1rem;
}

.modal p {
    margin-bottom: 1rem;
    text-align: justify;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #800000;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: #a00000;
    transform: scale(1.1);
}

/* PDF Modal Specific Styles */
.pdf-actions {
    text-align: center;
    margin: 1rem 0;
}

.pdf-actions .btn {
    display: inline-block;
    margin: 0 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(45deg, #800000, #a00000);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.pdf-actions .btn:hover {
    background: linear-gradient(45deg, #a00000, #c00000);
    transform: translateY(-2px);
}

.pdf-container iframe {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
}

.pdf-error {
    text-align: center;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

/* Body overflow control when modal is open */
body.modal-open {
    overflow: hidden; /* Prevent background page scrolling */
    padding-right: 15px; /* Compensate for scrollbar disappearing */
}

/* Additional overflow considerations for responsive design */
@media (max-width: 768px) {
    .modal {
        max-width: 95vw;
        max-height: 95vh;
        margin: 1rem;
        width: calc(100vw - 2rem);
    }
    
    .modal-content {
        padding: 1.5rem;
        /* Ensure content doesn't overflow on small screens */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    body.modal-open {
        padding-right: 0; /* No scrollbar compensation on mobile */
    }
}

/* Handle very long content gracefully */
.modal-content img {
    max-width: 100%;
    height: auto;
}

.modal-content table {
    width: 100%;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

.modal-content pre {
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}