/* Image Gallery & Lightbox */
.image-gallery {
  display: flex;
  gap: 1.5rem;
  margin: 2rem 0;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-flex-container {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  flex-wrap: nowrap;
}

.search-container-fixed {
  position: absolute;
  top: 4px;
  right: 2rem;
  z-index: 100;
  display: flex;
  align-items: center;
}

.search-input-inner {
  width: 364px;
}

@media screen and (max-width: 768px) {
  .nav-flex-container {
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .search-container-fixed {
    position: static !important;
    width: 100% !important;
    margin-top: 1rem;
    margin-left: 0 !important;
  }
  .search-input-inner {
    width: 100% !important;
  }
}

.main-container {
  padding-top: 0.5rem !important;
  padding-bottom: 2rem !important;
}

h1 {
  margin-top: 0.5rem !important;
  margin-bottom: 0.75rem !important;
}

.breadcrumbs ul {
  margin-bottom: 0.5rem !important;
}

.athelas {
  margin-top: 0.5rem !important;
}

.gallery-item {
  cursor: pointer;
  flex: 0 1 300px;
  border: 1px solid var(--accent-cyan);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(56, 158, 189, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.gallery-caption {
  padding: 0.75rem;
  font-size: 0.9rem;
  font-family: 'Michroma', sans-serif;
  color: var(--accent-cyan);
  text-align: center;
  border-top: 1px solid var(--accent-cyan);
  text-transform: uppercase;
}

/* Modal / Lightbox */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 10, 20, 0.95);
  backdrop-filter: blur(5px);
  cursor: zoom-out;
}

.modal-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 85vh;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 30px rgba(56, 158, 189, 0.5);
}

.modal-caption {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: 'Michroma', sans-serif;
  font-size: 1.1rem;
  text-shadow: 0 0 10px var(--accent-cyan);
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #fff;
  font-size: 50px;
  font-weight: bold;
  cursor: pointer;
}

.close-modal:hover {
  color: var(--accent-cyan);
}

/* Interactive Table Overrides */
.interactive-table td a,
.interactive-table td a:hover,
.data-row td a,
.data-row td a:hover {
  border-bottom: none !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

/* Responsive Heading Fixes */
@media (max-width: 600px) {
  html, body, .scifi-body {
    font-size: 17px !important; /* Slightly smaller base for mobile */
  }
}

h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
}

h1 {
  display: block !important;
  font-size: clamp(1.4rem, 7vw, 2rem) !important;
  line-height: 1.15;
}

h2 {
  font-size: clamp(1.1rem, 5vw, 1.6rem) !important;
  line-height: 1.2;
}

h3 {
  font-size: clamp(0.95rem, 4vw, 1.2rem) !important;
  line-height: 1.2;
  text-transform: none !important; /* Attribute subtitles look better in mixed case */
  opacity: 0.85; /* Subtle subtitle feel */
}

.table-wrapper {
  overflow-x: auto !important;
}

/* Agnostic 3-Tier Hierarchy Styling */
.tier-1 {
  background: rgba(75, 181, 193, 0.08) !important;
  font-weight: 600;
  border-top: 2px solid rgba(75, 181, 193, 0.15);
}

.tier-1 [class*="cell-"], .tier-1 td:first-child {
  color: var(--accent-cyan) !important;
  letter-spacing: 0.05em;
}

.tier-2 {
  font-size: 0.95em;
}

.tier-2 [class*="cell-"]:first-child, .tier-2 td:first-child {
  padding-left: 2.2rem !important;
  position: relative;
  text-align: left !important;
}

.tier-2 [class*="cell-"]:first-child::before, .tier-2 td:first-child::before {
  content: "↳";
  position: absolute;
  left: 0.8rem;
  color: var(--accent-cyan);
  opacity: 0.6;
}

/* Search UI */
.neon-border-cyan {
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 5px rgba(56, 158, 189, 0.2);
}

.focus-neon-glow:focus {
  box-shadow: 0 0 15px rgba(56, 158, 189, 0.6);
  border-color: #fff;
}

#search-results {
  backdrop-filter: blur(10px);
  border-top: none;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.hover-bg-neon-cyan-20:hover {
  background: rgba(56, 158, 189, 0.2);
}

.hidden {
  display: none !important;
}

.search-container input::placeholder {
  color: rgba(255, 255, 255, 0.4);
  font-family: 'Michroma', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.search-input {
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 158, 189, 0.4);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 0 5px rgba(56, 158, 189, 0.1);
}

.search-input:focus {
  border-color: #fff;
  box-shadow: 0 0 20px rgba(56, 158, 189, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.5);
}

#search-results {
  backdrop-filter: blur(15px);
  background: rgba(0, 10, 20, 0.95);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(56, 158, 189, 0.2);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan) transparent;
  max-height: 400px;
  overflow-y: auto;
}

#search-results::-webkit-scrollbar {
  width: 6px;
}

#search-results::-webkit-scrollbar-thumb {
  background-color: var(--accent-cyan);
  border-radius: 10px;
}

.search-result-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-result-item:hover {
  background: linear-gradient(90deg, rgba(56, 158, 189, 0.15) 0%, rgba(56, 158, 189, 0.05) 100%);
}

.search-result-item .neon-cyan {
  transition: all 0.2s ease;
}

.search-result-item:hover .neon-cyan {
  text-shadow: 0 0 8px var(--accent-cyan);
  color: #fff !important;
}

.search-result-item .badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(56, 158, 189, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 158, 189, 0.3);
}

.search-result-item:hover .badge {
  background: var(--accent-cyan);
  color: #fff;
}

.search-highlight {
  background: rgba(56, 158, 189, 0.3);
  color: #fff;
  padding: 0 2px;
  border-radius: 2px;
  text-shadow: 0 0 5px var(--accent-cyan);
}

/* Themed Scrollbars for auto-overflow containers */
.overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan) transparent;
}

.overflow-y-auto::-webkit-scrollbar {
  width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
  background-color: var(--accent-cyan);
  border-radius: 10px;
}

.overflow-y-auto::-webkit-scrollbar-track {
  background: transparent;
}

/* Index Card Responsive Height */
.sci-fi-card {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow-x: hidden; /* Prevent horizontal overflow from content */
}

@media screen and (min-width: 768px) {
    .index-card-content {
        max-height: 700px;
    }
}

.toc-dotted-line {
    flex: 1 1 auto;
    border-bottom: 2px dotted rgba(56, 158, 189, 0.4);
    height: 1.1em;
    margin: 0 10px;
    min-width: 15px;
}

.toc-description {
    flex-shrink: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: auto;
    max-width: 70%;
    min-width: 0; /* Enable shrinking/truncation in flexbox */
}

.index-card-content li {
    min-width: 0; /* Allow children to shrink below their content size */
}
