/**
 * Modern Theme Styles for ngeran[io] Blog
 * Provides comprehensive dark/light mode support with Moonlet + Nord color palette
 */

/* ===== Base Styles ===== */
* {
  transition-property: background-color, border-color, color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 250ms;
}

/* ===== Homepage Layout - Sticky Footer ===== */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body > div {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: calc(100vh - 4rem);
}

/* Force hero section to fill available space (homepage) */
#main-content > section {
  height: 100% !important;
  min-height: calc(100vh - 14rem) !important;
  display: flex !important;
  flex-direction: column;
}

#main-content > section > div {
  height: 100% !important;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* List pages - ensure footer is always at bottom */
#main-content > section.list-page-section {
  min-height: calc(100vh - 16rem) !important;
  display: block !important;
  margin-top: 4rem !important;
}

#main-content > section.list-page-section > div {
  height: auto !important;
  flex: none !important;
  display: block !important;
}

/* ===== Custom Background Colors ===== */
.bg-dust-800 {
  background-color: #22242a;
}

.bg-dust-900 {
  background-color: #191a1f;
}

/* ===== Custom Text Colors ===== */
.text-gray-100 {
  color: #f0f0f0;
}

.text-moon {
  color: #00daff;
}

.text-nord-frost-pale {
  color: #81a1c1;
}

.text-nord-aurora-yellow {
  color: #ebcb8b;
}

.text-dust-400 {
  color: #787a80;
}

.text-white {
  color: #ffffff;
}

/* ===== Navigation Link Styles ===== */
.nav-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none !important;
  color: #f0f0f0;
  border-radius: 0.25rem;
  padding: 0.75rem 1rem 0.75rem 0.5rem;
  font-size: 1rem;
  line-height: 1.5;
  transition: background-color 0.4s, color 0.2s;
}

.nav-link:hover {
  text-decoration: none !important;
}

.nav-link svg {
  flex-shrink: 0;
}

/* ===== Navbar Separator ===== */
.navbar-separator {
  background-color: #42495f;
  flex: none;
  width: 1px;
  height: 2.3rem;
  margin-left: 1.5rem;
  margin-right: 1.5rem;
  display: block;
}

/* ===== Mega Menu Styles ===== */
.megamenu-container {
  background-color: #22242a;
  flex-flow: column;
  width: 25rem;
  padding: 1.25rem;
  grid-column-gap: 0.88rem;
  grid-row-gap: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  position: absolute;
  top: 0;
  left: 0;
}

.group:hover .megamenu-container {
  opacity: 1;
  pointer-events: auto;
}

.megamenu-link {
  position: relative;
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid #42495f;
}

.megamenu-link:last-child {
  border-bottom: none;
}

.megamenu-link-col-1 {
  display: flex;
  flex-direction: column;
}

.megamenu-link-title {
  font-size: 1rem;
  font-weight: 600;
  color: #00daff;
  margin-bottom: 0.25rem;
}

.megamenu-link-subtitle {
  font-size: 0.875rem;
  color: #787a80;
}

.megamenu-link:hover .megamenu-link-title {
  color: #f0f0f0;
}

.megamenu-link:hover .megamenu-link-subtitle {
  color: #cdcfd5;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter Tight', 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Card Styles ===== */
.resource-item {
  position: relative;
}

.resource-link {
  text-decoration: none;
  display: block;
}

.resource-link:hover {
  text-decoration: none;
}

/* Image container */
.resource-link-top {
  position: relative;
  margin: 0;
  width: 100%;
}

.highlighted-resource-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Card shadow on hover */
.resource-link-top::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.resource-item:hover .resource-link-top::after {
  opacity: 1;
}

/* Card bottom content */
.resource-link-bottom {
  /* Let Tailwind p-6 class handle padding */
}

/* Card hover effect */
.group:hover .resource-link-bottom {
  background-color: #191a1f !important;
}

/* Mega menu hover effect */
.group:hover .group-hover\:opacity-100 {
  opacity: 1 !important;
}

.group:hover .group-hover\:pointer-events-auto {
  pointer-events: auto !important;
}

.group:hover .group-hover\:translate-y-0 {
  transform: translateY(0) !important;
}

/* Metadata row */
.resource-metadata {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}

.resource-metadata .text-style-uppercase {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Typography */
.heading-style-h5 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover .heading-style-h5 {
  color: #00daff !important;
}

.text-size-regular {
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* Text clamping for multiline truncation */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Dropdown Animations ===== */
.group:hover .group-hover\:block {
  animation: fadeIn 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #191a1f;
}

::-webkit-scrollbar-thumb {
  background: #42495f;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #787a80;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #42495f #191a1f;
}

/* ===== Table of Contents ===== */
.toc {
  position: sticky;
  top: 140px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.toc a {
  display: block;
  padding: 0.25rem 0;
  color: inherit;
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 1rem;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.toc a:hover {
  color: #00daff;
  border-left-color: #00daff;
}

.toc a.active {
  color: #00daff;
  border-left-color: #00daff;
  font-weight: 600;
}

/* ===== Focus States for Accessibility ===== */
:focus-visible {
  outline: 2px solid #00daff;
  outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #00daff;
  color: #191a1f;
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-to-content:focus {
  top: 0;
}

/* ===== Loading States ===== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading {
  animation: spin 1s linear infinite;
}

/* ===== Footer ===== */
footer {
  margin-top: 3rem;
  padding-top: 2rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .prose h1 {
    font-size: 2rem;
  }

  .prose h2 {
    font-size: 1.75rem;
  }

  .prose h3 {
    font-size: 1.25rem;
  }
}

/* ===== Print Styles ===== */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  a {
    color: inherit;
    text-decoration: underline;
  }
}

/* ===== Mega Menu Item Borders ===== */
.menu-item-border:last-child {
  border-bottom: none !important;
}

/* ===== Mega Menu Hover Fix ===== */
/* Show mega menu dropdown when hovering over the parent group */
.relative.group:hover .megamenu-dropdown {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

/* Also work when hovering directly on the dropdown itself */
.megamenu-dropdown:hover {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

/* ===== Dropdown Item Hover Effects ===== */
/* Target menu items using the custom class */
.menu-item-border:hover {
  background-color: #1a1b20 !important;
}

/* Blue border animation - ensure it's visible */
.menu-item-border:hover .absolute.bottom-0 {
  transform: scaleX(1) !important;
}

/* Arrow color change on hover */
.menu-item-border:hover svg:last-child {
  color: #00daff !important;
}

/* Title color change on hover */
.menu-item-border:hover h4 {
  color: #00daff !important;
}

/* Icon color change on hover */
.menu-item-border:hover .w-10.h-10 svg {
  color: #00daff !important;
}

/* =============================================
   MODERN DROPDOWN MENU STYLES
   ============================================= */

/* Chevron rotation on hover */
.group:hover .chevron-icon {
  transform: rotate(180deg);
}

/* Dropdown menu container */
.dropdown-menu {
  transform-origin: top center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Dropdown item animations */
.dropdown-item {
  position: relative;
  overflow: hidden;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(to bottom, #06b6d4, #3b82f6);
  transform: scaleY(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-item:hover::before {
  transform: scaleY(1);
}

/* Add subtle glow effect on dropdown */
.dropdown-menu::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(59, 130, 246, 0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.group:hover .dropdown-menu::after {
  opacity: 1;
}

/* Enhanced hover states for nav items */
.nav-item-dropdown {
  position: relative;
}

.nav-item-dropdown::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(to right, #06b6d4, #3b82f6);
  transform: translateX(-50%);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item-dropdown:hover::after {
  width: 80%;
}

/* Dropdown entrance animation with stagger */
@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.group:hover .dropdown-menu .dropdown-item {
  animation: dropdownSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

/* Stagger animation for each item */
.group:hover .dropdown-menu .dropdown-item:nth-child(1) { animation-delay: 0.05s; }
.group:hover .dropdown-menu .dropdown-item:nth-child(2) { animation-delay: 0.1s; }
.group:hover .dropdown-menu .dropdown-item:nth-child(3) { animation-delay: 0.15s; }
.group:hover .dropdown-menu .dropdown-item:nth-child(4) { animation-delay: 0.2s; }
.group:hover .dropdown-menu .dropdown-item:nth-child(5) { animation-delay: 0.25s; }

/* Focus visible styles for accessibility */
.dropdown-item:focus-visible {
  outline: 2px solid #06b6d4;
  outline-offset: -2px;
  background: rgba(6, 182, 212, 0.1);
}

/* Mobile dropdown improvements */
@media (max-width: 768px) {
  .dropdown-menu {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    width: 100%;
    margin-top: 0.5rem;
    box-shadow: none;
    background: rgba(31, 41, 55, 0.95);
  }

  .chevron-icon {
    transition: transform 0.2s;
  }

  .nav-item-dropdown.active .chevron-icon {
    transform: rotate(180deg);
  }

  .dropdown-item {
    padding-left: 2rem;
  }
}

/* =============================================
   ENHANCED DROPDOWN EFFECTS
   ============================================= */

/* Nav link underline effect */
.nav-link-enhanced::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(to right, #06b6d4, #3b82f6);
  transform: translateX(-50%);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link-enhanced:hover::after {
  width: 70%;
}

/* Enhanced dropdown item animations */
@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered animations for dropdown items */
.group:hover .dropdown-item-enhanced-1 {
  animation: dropdownSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.05s;
}

.group:hover .dropdown-item-enhanced-2 {
  animation: dropdownSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.1s;
}

.group:hover .dropdown-item-enhanced-3 {
  animation: dropdownSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.15s;
}

.group:hover .dropdown-item-enhanced-4 {
  animation: dropdownSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.2s;
}

.group:hover .dropdown-item-enhanced-5 {
  animation: dropdownSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.25s;
}
