/* 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;
  color:            white !important;
}
.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 12px rgba(0,0,0,0.25);
  transition:       all 0.3s ease;
}

.card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}

.card-text {
  color: #e2e8f0;
}

.card-title {
  color: #e2e8f0;
}

.mx-2.text-muted {
  color: #e0e0e0 !important;
}

/* Light theme card styles */
body.morning .card,
body.afternoon .card {
  background-color: #ffffff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.08);
}

body.morning .card:hover,
body.afternoon .card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

body.morning .card-text,
body.morning .card-title,
body.afternoon .card-text,
body.afternoon .card-title {
  color: #1a202c;
}

.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: 20px;
    z-index: 1001;
    transition: all 0.3s ease;
    /* Start visible to prevent FOUC */
    opacity: 1;
    pointer-events: auto;
  }
  
  /* Disabled state for toggle button when popout is active */
  .favorites-toggle:disabled {
    cursor: not-allowed;
    opacity: 0.5 !important;
  }
  
  .favorites-toggle:disabled:hover {
    transform: none !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
  }

  /* Button always stays in top-right corner */

  /* Reserve space for sidebar only when sidebar is visible */
  body:not(.favorites-hidden) .favorites-sidebar.js-safe-to-show.js-visible {
    /* This rule ensures body padding is applied when sidebar is actually visible */
  }
  
  body:not(.favorites-hidden) {
    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 {
    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: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.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;
}

/* ================================================
   Phonetic Spelling Styles
   ================================================ */

.phonetic-container {
  margin: 1.5rem 0;
  padding: 1.2rem 1.5rem;
  background-color: rgba(255, 255, 255, 0.08);
  border-left: 5px solid var(--link-color);
  border-radius: 0.5rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.phonetic-container:hover {
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.phonetic-spelling {
  margin: 0.5rem 0;
  font-size: 1.1rem;
  line-height: 1.4;
}

.phonetic-label {
  font-weight: 700;
  color: var(--text-color);
  margin-right: 0.75rem;
  opacity: 1;
  text-transform: uppercase;
  font-size: 0.9em;
  letter-spacing: 0.5px;
}

.phonetic-text {
  font-family: 'Doulos SIL', 'Charis SIL', 'Gentium Plus', 'Times New Roman', serif;
  font-style: normal;
  color: var(--link-color);
  font-size: 1.4em;
  letter-spacing: 1px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  padding: 0.2rem 0;
}

.phonetic-spelling.english .phonetic-text,
.phonetic-spelling.spanish .phonetic-text {
  color: var(--text-color); /* Same color as the pronunciation labels */
}

/* Light theme phonetic adaptations */
body.morning .phonetic-container,
body.afternoon .phonetic-container {
  background-color: rgba(0, 0, 0, 0.03);
  border-left-color: #007bff;
}

body.morning .phonetic-label,
body.afternoon .phonetic-label {
  color: #343a40;
}

body.morning .phonetic-spelling.english .phonetic-text,
body.afternoon .phonetic-spelling.english .phonetic-text,
body.morning .phonetic-spelling.spanish .phonetic-text,
body.afternoon .phonetic-spelling.spanish .phonetic-text {
  color: var(--text-color); /* Same color as labels for consistency */
}

/* Responsive adjustments for phonetic display */
@media (max-width: 768px) {
  .phonetic-container {
    margin: 0.5rem 0;
    padding: 0.5rem;
  }
  
  .phonetic-text {
    font-size: 1em;
  }
  
  .phonetic-spelling {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .phonetic-container {
    padding: 0.4rem;
  }
  
  .phonetic-label {
    display: block;
    margin-bottom: 0.2rem;
  }
  
  .phonetic-text {
    font-size: 0.95em;
  }
}

/* ================================================
   Add to Favorites Button - Enhanced Pill Style
   ================================================ */

/* Enhanced Add to Favorites button with pill shape and yellow highlight */
.js-add-fav,
.btn-outline-primary.js-add-fav {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  border: 2px solid #f6d55c;
  color: #1a202c !important;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: 50px; /* Pill shape */
  box-shadow: 0 3px 10px rgba(255, 215, 0, 0.3);
  transition: all 0.3s ease;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
  position: relative;
  overflow: hidden;
}

.js-add-fav::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s ease;
}

.js-add-fav:hover {
  background: linear-gradient(135deg, #ffed4e, #fbbf24);
  border-color: #f59e0b;
  box-shadow: 0 5px 15px rgba(255, 215, 0, 0.5);
  transform: translateY(-2px) scale(1.02);
}

.js-add-fav:hover::before {
  left: 100%;
}

.js-add-fav:focus {
  outline: 3px solid rgba(255, 215, 0, 0.6);
  outline-offset: 2px;
}

.js-add-fav:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 6px rgba(255, 215, 0, 0.4);
}

/* Light theme favorites button */
body.morning .js-add-fav,
body.afternoon .js-add-fav {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

body.morning .js-add-fav:hover,
body.afternoon .js-add-fav:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #b45309;
}

/* Mobile-specific styling for Add to Favorites button */
@media (max-width: 767px) {
  .js-add-fav {
    font-size: 0; /* Hide the text */
    padding: 0.75rem; /* Adjust padding for just the star */
    min-width: 48px; /* Ensure touch target size */
    min-height: 48px;
    border-radius: 50%; /* Make it circular on mobile */
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .js-add-fav::after {
    content: "⭐"; /* Show just the star */
    font-size: 1.25rem; /* Restore font size for the star */
    display: inline-block;
  }

  /* Center audio controls on mobile */
  audio {
    width: 100%;
    max-width: 100%;
    display: block;
    margin: 0 auto;
  }
  
  /* Center the audio container */
  .mt-3:has(audio) {
    text-align: center;
  }
  
  /* Fallback for browsers that don't support :has() */
  .card-body > div:has(audio),
  .card-body .mt-3 {
    text-align: center;
  }
  
  /* Reset text alignment for other content */
  .card-body .mt-3 p {
    text-align: left;
  }

  /* Truncate blog post content on mobile for better aesthetics */
  .update-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Limit to 3 lines on mobile */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    max-height: calc(1.4em * 3); /* Fallback for non-webkit browsers */
  }

  /* Blog list page content truncation - only for blog list previews */
  .max-w-4xl .prose {
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Limit to 4 lines on mobile */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    max-height: calc(1.5em * 4); /* Fallback for non-webkit browsers */
  }
}

/* ================================================
   Popout-specific styles to prevent flash - AGGRESSIVE APPROACH
   ================================================ */

/* AGGRESSIVE APPROACH: Hide sidebar by default, only show when explicitly allowed */

/* Global sidebar hiding - start hidden but allow JavaScript to show it */
.favorites-sidebar {
  opacity: 0;
  visibility: hidden;
  transition: none;
}

/* Show sidebar when JavaScript marks it as safe to show AND not hidden for popout */
.favorites-sidebar.js-safe-to-show:not([data-hidden-for-popout="true"]) {
  display: flex !important;
  opacity: 0;
  visibility: visible;
  transition: opacity 0.15s ease;
}

/* Make visible after determining correct state - but only if not hidden for popout */
.favorites-sidebar.js-safe-to-show.js-visible:not([data-hidden-for-popout="true"]) {
  opacity: 1 !important;
}

/* Fallback: If JavaScript fails to load, show sidebar after 2 seconds */
.favorites-sidebar:not(.js-safe-to-show):not([data-hidden-for-popout="true"]) {
  animation: fallback-show 0.5s ease 2s forwards;
}

@keyframes fallback-show {
  to {
    display: flex;
    opacity: 1;
    visibility: visible;
  }
}

/* Removed emergency/nuclear overrides to allow proper mobile toggle behavior.
   The sidebar visibility is now controlled solely by:
   - .js-safe-to-show + .js-visible
   - .is-hidden on mobile
   - body.favorites-hidden on desktop
   - [data-hidden-for-popout="true"] when popout is active */

/* Prevent any transitions during initial load */
.favorites-sidebar:not(.transitions-enabled) {
  transition: none !important;
}

.favorites-sidebar.transitions-enabled {
  transition: transform 0.3s ease-in-out, opacity 0.15s ease;
}

/* Ensure popout state overrides everything */
html.popout-active .favorites-sidebar,
.favorites-sidebar[data-hidden-for-popout="true"] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateX(100%) !important;
}

/* Desktop-specific styles */
@media (min-width: 768px) {
  .favorites-sidebar.js-safe-to-show:not([data-hidden-for-popout="true"]) {
    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;
    flex-direction: column;
    overflow: hidden;
    padding-top: 70px;
    transform: translateX(0);
  }

  /* Hide when user preference says hidden */
  body.favorites-hidden .favorites-sidebar.js-safe-to-show:not([data-hidden-for-popout="true"]) {
    transform: translateX(100%);
  }

  /* Ensure body padding is handled correctly - only when sidebar is actually visible */
  body:not(.favorites-hidden):has(.favorites-sidebar.js-safe-to-show.js-visible:not([data-hidden-for-popout="true"])) {
    padding-right: 320px;
    transition: padding-right 0.3s ease;
  }
  
  /* Fallback for browsers that don't support :has() */
  body:not(.favorites-hidden) {
    padding-right: 320px;
    transition: padding-right 0.3s ease;
  }
  
  body.favorites-hidden,
  body:has(.favorites-sidebar[data-hidden-for-popout="true"]) {
    padding-right: 0;
  }
}

/* Mobile-specific styles */
@media (max-width: 767px) {
  .favorites-sidebar.js-safe-to-show:not([data-hidden-for-popout="true"]) {
    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;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    transform: translateY(100%);
    visibility: hidden;
  }

  /* Show when not hidden */
  .favorites-sidebar.js-safe-to-show:not(.is-hidden):not([data-hidden-for-popout="true"]) {
    transform: translateY(0);
    visibility: visible;
  }

  /* Mobile drag handle */
  .favorites-sidebar.js-safe-to-show:not([data-hidden-for-popout="true"])::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;
  }
}

/* Popout-specific overrides - highest specificity to override any other classes */
.favorites-sidebar[data-hidden-for-popout="true"],
.favorites-sidebar[data-hidden-for-popout="true"].js-safe-to-show,
.favorites-sidebar[data-hidden-for-popout="true"].js-safe-to-show.js-visible {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateX(100%) !important;
}
