/* StudyBuddy Animated Menu System - GSAP + SplitText Integration */

/* Reset styles for the animated header */
.animated-header-container {
  position: relative;
  z-index: 1000;
}

body.overlay-active {
  overflow: hidden;
}

/* Main header pill */
header.animated-header {
  background: linear-gradient(135deg, rgba(59,130,246,0.95), rgba(129,140,248,0.9));
  padding: 18px 24px;
  border-radius: 100vmax;
  color: #fff;
  width: 85%;
  margin: 2rem auto;
  position: relative;
  align-content: center;
  min-height: 102px;
  transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

/* JavaScript will animate from 100px to 85% - but start at 85% as fallback */
header.animated-header.js-animating {
  width: 100px;
}

/* Logo styles */
.animated-header .logo img,
.animated-header .logo-section img {
  max-width: 40px;
  height: 40px;
}

.animated-header .logo-text {
  font-size: 20px;
  font-weight: 700;
  text-transform: none;
  color: #fff;
  margin-left: 10px;
}

.animated-header .logo-section {
  justify-self: start;
}

.animated-header .logo-section .logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 10px;
}

.animated-header .logo-section .beta-badge {
  background: #fbbf24;
  color: #000;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.animated-header .logo,
.animated-header .logo-section,
.animated-header nav ul,
.animated-header .desktop-actions,
.animated-header .menu-toggle {
  opacity: 1;
  visibility: visible;
}

/* JavaScript will set these to hidden initially for animation */
.animated-header.js-animating .logo,
.animated-header.js-animating .logo-section,
.animated-header.js-animating nav ul,
.animated-header.js-animating .desktop-actions,
.animated-header.js-animating .menu-toggle {
  opacity: 0;
  visibility: hidden;
}

/* Header wrapper grid */
.header-wrapper {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  justify-content: center;
  justify-items: stretch;
  align-items: center;
  gap: 1rem;
}

/* Alternative layout: Direct children of animated-header (no header-wrapper) */
header.animated-header:not(:has(.header-wrapper)) {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 2rem;
}

/* Desktop Actions (theme toggle, feedback) */
.desktop-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: start;
}

.desktop-actions .btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.desktop-actions .btn-icon:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.desktop-actions .btn-primary {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.desktop-actions .btn-primary:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.desktop-actions .btn-primary i {
  margin-right: 0.375rem;
}

/* User auth elements in desktop nav */
.desktop-actions #desktop-user-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.desktop-actions .user-name-link {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
  white-space: nowrap;
}

.desktop-actions .user-name-link:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.desktop-actions #desktop-signout {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* Desktop navigation */
nav.main-nav {
  justify-self: center;
}

nav.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  position: relative;
  z-index: 1;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  backdrop-filter: blur(10px);
}

nav.main-nav ul li a {
  text-decoration: none;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  padding: 16px 20px;
  display: block;
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

/* CSS-only hover effect (fallback) */
nav.main-nav ul li a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
}

nav.main-nav ul li a:hover {
  color: #fef3c7;
}

nav.main-nav ul li a:hover::before {
  opacity: 1;
}

/* Hover effect block for desktop nav */
.nav-links-hover-block {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  transition: none;
  will-change: transform, width, height, opacity;
}

/* Menu Toggle Button (Hamburger/Close Icon) */
.menu-toggle {
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  border-radius: 100vmax;
  border: 0;
  background: transparent;
  color: #fff;
  transition: transform 0.3s ease;
}

.menu-toggle:hover {
  transform: scale(1.1);
}

.menu-toggle svg {
  width: 32px;
  height: 32px;
}

.menu-toggle svg line {
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

/* Animate hamburger to X when menu is active */
body.overlay-active .menu-toggle svg line:nth-child(1) {
  transform: rotate(45deg) translateY(0);
  opacity: 1;
}

body.overlay-active .menu-toggle svg line:nth-child(2) {
  transform: rotate(-45deg) translateY(0);
  opacity: 1;
}

body.overlay-active .menu-toggle svg line:nth-child(3) {
  opacity: 0;
}

/* Full-Width Overlay Menu */
.full-width-overlay-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 0;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
  backdrop-filter: blur(20px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-around;
  visibility: hidden;
  opacity: 0;
  overflow: hidden;
  z-index: 999;
  transition: opacity 0.3s ease, visibility 0.3s ease, height 0.3s ease;
}

/* Active state - make overlay visible */
.full-width-overlay-menu.is-active {
  height: 100vh;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.overlay-menu-content {
  text-align: left;
  width: 100%;
  max-width: 600px;
  padding: 40px;
  box-sizing: border-box;
  opacity: 1;
  transform: translateY(0);
  z-index: 10;
}

.overlay-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.overlay-nav-list li {
  margin-bottom: 20px;
}

.overlay-nav-list li:last-child {
  margin-bottom: 0;
}

.overlay-nav-list li a {
  text-decoration: none;
  color: #fff;
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: bold;
  text-transform: uppercase;
  display: inline-block;
  padding: 10px 15px;
  position: relative;
  overflow: hidden;
  letter-spacing: -1px;
  transition: color 0.3s ease;
}

.overlay-nav-list li a:hover {
  color: #fbbf24;
}

.overlay-nav-list li a .mask {
  overflow: hidden;
  display: block;
}

.overlay-nav-list li a .line-inner {
  display: inline-block;
  transform: none !important;
  color:black !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.full-width-overlay-menu.is-active .overlay-menu-images {
  display: block;
}

/* Overlay menu images (background) */
.overlay-menu-image {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.overlay-menu-image img {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  object-fit: cover;
  border-radius: 0;
  filter: brightness(0.7) saturate(1.2);
}

.overlay-menu-image:first-child {
  opacity: 1;
  visibility: visible;
}

.overlay-menu-image {
  max-width: 50vw;
}

/* Auth/user info in overlay */
.overlay-user-info {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 1 !important;
  visibility: visible !important;
}

.overlay-user-info .user-name {
  font-size: 1.2rem;
  color: #fbbf24;
  margin-bottom: 1rem;
}

.overlay-user-info .user-name-link {
  font-size: 1.2rem;
  color: #fbbf24;
  text-decoration: none;
  margin-bottom: 1rem;
  display: inline-block;
  transition: all 0.3s ease;
  font-weight: 600;
}

.overlay-user-info .user-name-link:hover {
  color: #fcd34d;
  transform: translateX(4px);
}

.overlay-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.overlay-user-actions .btn {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  transition: all 0.3s ease;
}

/* Media Queries */
@media only screen and (max-width: 1100px) {
  nav.main-nav,
  .desktop-actions {
    display: none;
  }

  .header-wrapper {
    grid-template-columns: 1fr auto;
  }
  
  .logo {
    grid-column: 1 / 2;
  }
  
  .menu-toggle {
    grid-column: 2 / 3;
    justify-self: end;
  }
}

@media (min-width: 1101px) {
  .logo {
    grid-column: 1 / 2;
  }

  nav.main-nav {
    grid-column: 2 / 3;
  }

  .desktop-actions {
    grid-column: 3 / 4;
  }

  .menu-toggle {
    grid-column: 4 / 5;
    justify-self: end;
  }
}

@media only screen and (max-width: 768px) {
  header.animated-header {
    width: 94%;
    min-height: 82px;
    margin: 1rem auto;
  }

  header.animated-header.js-animating {
    width: 100px;
  }

  .animated-header .logo img {
    max-width: 34px;
    height: 34px;
  }

  .animated-header .logo-text {
    font-size: 18px;
  }

  .overlay-menu-content {
    min-height: 100%;
    place-content: center;
    padding: 20px;
  }

  .overlay-menu-image {
    max-width: 100%;
  }

  .overlay-menu-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6));
    pointer-events: none;
    z-index: 1;
  }

  .overlay-nav-list li a {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
  }
}

/* Light mode support */
body.home-light-mode header.animated-header,
body.study-light-mode header.animated-header {
  background: linear-gradient(135deg, rgba(59,130,246,0.95), rgba(129,140,248,0.9));
}

body.home-light-mode .full-width-overlay-menu,
body.study-light-mode .full-width-overlay-menu {
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.98));
}

body.home-light-mode .overlay-nav-list li a,
body.study-light-mode .overlay-nav-list li a {
  color: #0f172a;
}

body.home-light-mode .overlay-nav-list li a:hover,
body.study-light-mode .overlay-nav-list li a:hover {
  color: #3b82f6;
}

body.home-light-mode .overlay-user-info,
body.study-light-mode .overlay-user-info {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.home-light-mode .overlay-user-info .user-name,
body.study-light-mode .overlay-user-info .user-name {
  color: #3b82f6;
}

/* Badge on logo */
.logo .badge {
  font-size: 0.65rem;
  padding: 0.25rem 0.5rem;
  vertical-align: middle;
  margin-left: 0.5rem;
}

/* Smooth transitions */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
