/* Custom CSS for InterpAscend Translator 
   — now with automatic text-color contrast */

/* ================================================
   1) Design tokens (CSS variables)
   ================================================ */
:root {
  --bg-color:    #36454F; /* charcoal */
  --text-color:  color-contrast(var(--bg-color) vs #000000, #ffffff);
  --muted-color: color-contrast(var(--bg-color) vs #555555, #aaaaaa);
  --link-color:  color-contrast(var(--bg-color) vs #007bff, #ADD8E6);
}

/* ================================================
   2) Base styling using variables
   ================================================ */
html {
  /* Always show scrollbar to prevent layout shift */
  overflow-y: scroll;
}

body {
  background-color: var(--bg-color);
  color:            var(--text-color);
  min-height:       100vh;
  margin:           0;
  padding:          0;
  display:          flex;
  flex-direction:   column;
}

main {
  flex-grow: 1;
}

/* ================================================
   3) Header & Navigation Improvements
   ================================================ */
.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  min-height: 80px;
  background-color: var(--bg-color);
  position: relative;
  z-index: 10;
}

.navbar {
  background-color: #2c3e50 !important;
}
.navbar-brand,
.navbar-nav .nav-link {
  color: var(--text-color) !important;
}

h1, h2, h3, h4, h5, h6,
p,
.card-body {
  color: var(--text-color);
}

.text-white {
  color: var(--text-color) !important;
}
.text-muted {
  color: var(--muted-color) !important;
}

.card a {
  color: var(--link-color);
  text-decoration: none;
}
.card a:hover {
  text-decoration: underline;
}

.form-control {
  background-color: #ffffff;
  color:            #343a40;
  border:           1px solid #ced4da;
  border-radius:    0.5rem;
  padding:          0.75rem 1.25rem;
}
.form-control::placeholder {
  color: #6c757d;
}
.form-control:focus {
  border-color: #80bdff;
  box-shadow:   0 0 0 0.25rem rgba(0,123,255,0.25);
}

.form-select {
  background-color: #ffffff;
  color:            #343a40;
  border:           1px solid #ced4da;
  border-radius:    0.5rem;
  padding:          0.75rem 2.25rem 0.75rem 1.25rem;
}

.btn-primary {
  background-color: #007bff;
  border-color:     #007bff;
  border-radius:    0.5rem;
  padding:          0.75rem 1.5rem;
  font-weight:      bold;
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: #0056b3;
  border-color:     #004085;
}

.card {
  background-color: #4a627a;
  border:           none;
  border-radius:    0.75rem;
  box-shadow:       0 4px 8px rgba(0,0,0,0.2);
}
.card-text {
  color: #e0e0e0;
}
.mx-2.text-muted {
  color: #e0e0e0 !important;
}

.alert-warning {
  background-color: #ffeeba;
  color:            #856404;
  border-color:     #ffeeba;
  border-radius:    0.5rem;
}

/* ================================================
   Responsive tweaks
   ================================================ */
@media (max-width: 768px) {
  .d-flex.flex-column.flex-md-row {
    flex-direction: column !important;
  }
  .form-control.mb-2.mb-md-0.me-md-2 {
    margin-right:  0 !important;
    margin-bottom: 0.5rem !important;
  }

  .header-container {
    padding: 12px 16px;
    min-height: 60px;
  }

  .home-button-glass {
    width: 56px;
    height: 56px;
    margin-right: 0.5rem;
  }
}

/* ================================================
   Time-of-Day Overrides (only set --bg-color)
   ================================================ */
body.morning {
  --bg-color: #F5F5DC; /* beige */
}

body.afternoon {
  --bg-color: #ADD8E6; /* light blue */
}

body.evening {
  --bg-color: #B0C4DE; /* light steel blue */
}

body.night {
  --bg-color: #36454F; /* charcoal */
}

/* ================================================
   Modern Home Button - Glassmorphism with PNG Icon
   ================================================ */
.home-button-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px; /* Enlarged */
  height: 72px;
  padding: 0;
  margin-right: 1.5rem;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  overflow: hidden;
}

.home-button-glass::before {
  content: none; /* removed decorative ◆ */
}

.home-button-glass img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.home-button-glass:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Light theme adaptations */
body.morning .home-button-text,
body.afternoon .home-button-text {
  background: linear-gradient(135deg, rgba(0,0,0,0.05), rgba(0,0,0,0.02));
  border-color: rgba(0,0,0,0.1);
}

body.morning .home-button-minimal,
body.afternoon .home-button-minimal {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}

body.morning .home-button-glass,
body.afternoon .home-button-glass {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

/* Accessibility */
.home-button-text:focus-visible,
.home-button-geo:focus-visible,
.home-button-minimal:focus-visible,
.home-button-badge:focus-visible,
.home-button-glass:focus-visible {
  outline: 3px solid var(--link-color);
  outline-offset: 2px;
}

/* Mobile bottom drawer styles */
@media (max-width: 767px) {
  .favorites-sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    height: 60vh;
    max-height: 400px;
    background: var(--bg-color);
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px 16px 0 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* No transition by default to prevent FOUC */
    transition: none;
    padding-top: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    /* Start hidden by default to prevent FOUC - aggressive approach */
    transform: translateY(100%) !important;
    visibility: hidden !important;
  }

  /* Enable transitions only after JavaScript initialization */
  .favorites-sidebar.transitions-enabled {
    transition: transform 0.3s ease;
  }

  .favorites-sidebar.is-hidden {
    transform: translateY(100%) !important;
    visibility: hidden !important;
  }

  /* Only show when explicitly visible */
  .favorites-sidebar:not(.is-hidden) {
    transform: translateY(0) !important;
    visibility: visible !important;
  }

  .favorites-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    animation: pulse-hint 3s ease-in-out infinite;
  }

  .favorites-sidebar.is-hidden ~ .favorites-toggle {
    bottom: 20px;
    animation: pulse-hint 3s ease-in-out infinite;
  }

  /* Subtle pulsing animation to hint at interaction */
  @keyframes pulse-hint {
    0%, 100% {
      transform: scale(1);
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    50% {
      transform: scale(1.05);
      box-shadow: 0 6px 16px rgba(0,123,255,0.4);
    }
  }

  /* Stop animation when user hovers/taps */
  .favorites-toggle:hover,
  .favorites-toggle:focus,
  .favorites-toggle:active {
    animation: none;
    transform: scale(1.1);
  }

  /* Add drag handle for mobile drawer */
  .favorites-sidebar::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
  }

  .favorites-header {
    padding-top: 20px !important;
  }

  /* No body padding on mobile */
  body {
    padding-right: 0;
  }
}

/* Desktop sidebar styles */
@media (min-width: 768px) {
  .favorites-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-color);
    border-left: 1px solid rgba(255,255,255,0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
    padding-top: 70px; /* Add space at top to avoid button overlap */
    /* Start visible by default to prevent FOUC */
    transform: translateX(0);
  }

  /* Hide when explicitly hidden */
  body.favorites-hidden .favorites-sidebar {
    transform: translateX(100%);
  }

  .favorites-toggle {
    position: fixed;
    top: 20px;
    right: 340px;
    z-index: 1001;
    transition: right 0.3s ease;
    /* Start visible to prevent FOUC */
    opacity: 1;
    pointer-events: auto;
  }

  /* Move button to edge when sidebar is hidden */
  body.favorites-hidden .favorites-toggle {
    right: 20px;
  }

  /* Always reserve space for sidebar to prevent layout shift */
  body {
    padding-right: 320px;
    transition: padding-right 0.3s ease;
  }
  
  /* Remove padding when sidebar is explicitly hidden */
  body.favorites-hidden {
    padding-right: 0;
  }
  
  /* Ensure header navigation is never affected by sidebar padding */
  .header-container {
    padding-right: 20px !important;
    margin-right: 0 !important;
  }
  
  /* Keep navigation visible but don't interfere with favorites functionality */
  .desktop-nav {
    max-width: calc(100% - 380px);
    overflow: visible;
  }
}

/* Common styles for both mobile and desktop */
.favorites-list {
  flex: 1;
  overflow-y: auto;
}

.favorite-item:hover {
  background: rgba(255,255,255,0.05);
}

/* ================================================
   Footer Styles
   ================================================ */

.site-footer {
  background-color: rgba(0, 0, 0, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem 0 1rem;
  margin-top: auto;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.footer-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-link {
  color: var(--text-color);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
  font-weight: 500;
  opacity: 0.8;
}

.footer-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--link-color);
  opacity: 1;
}

.footer-separator {
  color: var(--muted-color);
  font-weight: 300;
  margin: 0 0.25rem;
}

.footer-info {
  margin-top: 0.5rem;
}

.footer-info p {
  color: var(--muted-color);
  font-size: 0.875rem;
  margin: 0;
  opacity: 0.7;
}

/* Light theme footer adaptations */
body.morning .site-footer,
body.afternoon .site-footer {
  background-color: rgba(0, 0, 0, 0.05);
  border-top-color: rgba(0, 0, 0, 0.1);
}

body.morning .footer-link,
body.afternoon .footer-link {
  color: #343a40;
}

body.morning .footer-link:hover,
body.afternoon .footer-link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #007bff;
}

body.morning .footer-separator,
body.afternoon .footer-separator {
  color: #6c757d;
}

body.morning .footer-info p,
body.afternoon .footer-info p {
  color: #6c757d;
}

/* Responsive footer */
@media (max-width: 768px) {
  .site-footer {
    padding: 1.5rem 0 1rem;
  }
  
  .footer-nav {
    font-size: 0.875rem;
  }
  
  .footer-link {
    padding: 0.375rem 0.75rem;
  }
}

/* ================================================
   Navigation Styles
   ================================================ */

/* Desktop Navigation */
.desktop-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  white-space: nowrap;
  position: relative;
  z-index: 10;
  margin-right: 340px; /* Space for favorites button */
}

.desktop-nav .nav-link {
  color: var(--text-color);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
  font-weight: 500;
  flex-shrink: 0;
}

.desktop-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--link-color);
}

.desktop-nav .nav-separator {
  color: var(--muted-color);
  font-weight: 300;
  margin: 0 0.25rem;
  flex-shrink: 0;
}

/* Mobile Hamburger Button */
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 44px;
  height: 44px;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.hamburger-line {
  width: 28px;
  height: 3px;
  background-color: var(--text-color);
  border-radius: 2px;
  transition: all 0.3s ease;
  display: block;
  opacity: 1;
  z-index: 1;
}

/* Ensure hamburger lines are visible on all themes */
.hamburger-line {
  background-color: #ffffff !important;
}

/* Light theme hamburger lines */
body.morning .hamburger-line,
body.afternoon .hamburger-line {
  background-color: #343a40 !important;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile Off-Canvas Menu */
.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--bg-color);
  z-index: 999;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.mobile-menu.active {
  transform: translateX(0);
}

.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-header h5 {
  margin: 0;
  color: var(--text-color);
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  transition: all 0.3s ease;
  border-radius: 4px;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.mobile-menu-content {
  flex: 1;
  padding: 20px;
}

.mobile-nav-link {
  display: block;
  color: var(--text-color);
  text-decoration: none;
  padding: 16px 20px;
  margin-bottom: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--link-color);
  transform: translateX(4px);
}

/* Footer navigation for mobile */
.mobile-footer-nav {
  margin-top: auto;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-footer-link {
  display: inline-block;
  color: var(--muted-color);
  text-decoration: none;
  font-size: 0.875rem;
  margin-right: 16px;
  padding: 8px 0;
  transition: color 0.3s ease;
}

.mobile-footer-link:hover {
  color: var(--link-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header-container {
    padding: 12px 16px;
    min-height: 60px;
  }
  
  .mobile-menu {
    width: 100%;
    max-width: 320px;
  }
}

@media (max-width: 480px) {
  .mobile-menu {
    width: 100%;
  }
}

/* Light theme adaptations for navigation */
body.morning .desktop-nav .nav-link,
body.afternoon .desktop-nav .nav-link {
  color: #343a40;
}

body.morning .desktop-nav .nav-link:hover,
body.afternoon .desktop-nav .nav-link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #007bff;
}

body.morning .desktop-nav .nav-separator,
body.afternoon .desktop-nav .nav-separator {
  color: #6c757d;
}

body.morning .hamburger-btn,
body.afternoon .hamburger-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

body.morning .hamburger-btn:hover,
body.afternoon .hamburger-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

body.morning .hamburger-line,
body.afternoon .hamburger-line {
  background: #343a40;
}

body.morning .mobile-menu,
body.afternoon .mobile-menu {
  border-left-color: rgba(0, 0, 0, 0.1);
}

body.morning .mobile-menu-header,
body.afternoon .mobile-menu-header {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

body.morning .mobile-nav-link,
body.afternoon .mobile-nav-link {
  color: #343a40;
  border-color: rgba(0, 0, 0, 0.1);
}

body.morning .mobile-nav-link:hover,
body.afternoon .mobile-nav-link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #007bff;
}