/*
  Responsive CSS reorganized: grouped by component while preserving all original
  declarations and values. No property values were changed, only order and comments.
*/

/* ------------------------------
   Mobile (max-width: 768px)
   ------------------------------ */
@media (max-width: 768px) {
  /* Header / Navbar */
  .header-container,
  .navbar {
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Keep logo left and auth on right */
    justify-content: space-between;
    height: 85px;
  }


  .twitch-icon {
    margin-right: 0;
    width: 30px;
    height: 30px;
  }

  .main-logo {
    height: 60px;
    width: 60px;
  }

  .nav-right {
    gap: 20px;
  }

  /* Navigation - mobile dropdown behavior */
  /* By default the nav is hidden visually and from assistive technologies; when
     .mobile-active is set we force it visible as a dropdown panel under the header. */
  .nav-list {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%; /* place directly below the parent (.main-nav) */
    left: 0;
    right: 0;
    min-width: 200px; /* largeur minimum pour le menu */
    background: #18181b;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    z-index: 1400; /* above header */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
    pointer-events: none; /* don't block clicks when hidden */
    align-items: center; /* center items horizontally */
    gap: 1rem; /* spacing between items when opened */
  }

  /* Afficher la liste quand la classe mobile-active est présente */
  .nav-list.mobile-active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateY(8px) !important;
    pointer-events: auto !important;
  }

  /* Center nav links and make them easy to tap on mobile */
  .nav-list .nav-link,
  .nav-list .nav-active {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    margin: 6px 0;
    box-sizing: border-box;
  }

  /* Afficher le bouton de bascule et le placer après le logo */
  .mobile-nav-toggle {
    display: block;
    position: static;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.4rem;
    padding: 6px;
    cursor: pointer;
    z-index: 1100;
    margin-left: 8px; /* small gap to the right of logo */
    order: 1; /* logo is order 0, burger after it */
  }

  /* Logo must remain the first item on the left */
  .header-container .header-logo {
    order: 0;
    margin-right: 0;
  }

  /* Auth controls (connexion) should be pushed to the far right */
  .header-container .auth-section {
    order: 2;
    margin-left: auto; /* ensures auth stays to the right */
  }

  /* Simple hamburger glyph style */
  .mobile-nav-toggle .hamburger {
    display: inline-block;
    line-height: 1;
    font-size: 1.2em;
  }

  /* Hide category navigation squares on small screens to avoid clutter */
  .category-navigation .category-squares,
  .category-navigation .square {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .category-number {
    margin-top: 0px;
  }

  /* Hero / Hero-related */
  .hero-section {
    padding: var(--section-spacing) 0.5rem;
  }

  .hero-logo {
    height: 300px;
  }

  .hero-title {
    font-size: 2em;
    text-align: center;
  }

  .hero-subtitle {
    font-size: 1.1em;
    text-align: center;
    padding: 0 10px;
  }

  /* Centrer le bouton "Commencer à voter" */
  .hero-cta {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .twitch-connect-btn {
    padding: 15px 30px;
    font-size: 1em;
  }

  /* Rules and host area */
  .rules-container {
    flex-direction: column;
    align-items: center;
  }

  .rule-card {
    width: 100%;
    max-width: 400px;
  }

  .host-container {
    flex-direction: column;
    gap: 1.5rem;
  }

  .host-image {
    height: 300px;
  }

  .host-card {
    padding: 1.5rem;
  }

  .host-title {
    font-size: 2rem;
  }
}

@media (max-width:700px)  {
  
  .footer-content {
    gap: 10px;
    padding: 0 15px;
  }

  .footer-bottom {
    gap: 2rem;
  }

  .footer-item {
    font-size: 0.85rem;
  }
  
}


/* ------------------------------
   Very small screens (max-width: 520px)
   ------------------------------ */
@media (max-width:520px) {
  .footer-content {
    gap: 8px;
    padding: 0 10px;
  }

  .footer-bottom {
    gap: 1.5rem;
  }

  .footer-item {
    font-size: 0.8rem;
  }

  .footer-edition p {
    font-size: 0.9rem;
  }
}


/* ------------------------------
   Extra small screens (max-width: 480px)
   ------------------------------ */
@media (max-width: 480px) {

  .header-container,
  .navbar {
    padding: 0 10px;
  }

  .nav-list {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .nav-link,
  .nav-active {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .main-logo {
    height: 40px;
    width: 40px;
  }

  .hero-section {
    padding: var(--section-spacing) 0.5rem;
  }

  .hero-logo {
    max-height: 240px;
    width: auto;
  }

  .hero-title {
    font-size: 1.8em;
    margin: 0.5em 0;
    text-align: center;
  }

  .hero-subtitle {
    font-size: 1em;
    text-align: center;
    margin-bottom: 1em;
    padding: 0 10px;
  }

  .twitch-connect-btn {
    display: inline-flex;
    padding: 12px 25px;
    font-size: 0.9em;
  }

  .twitch-glitch {
    display: none; /* Masquer l'effet glitch si nécessaire sur petit écran */
  }

  /* Footer ultra compact - empiler verticalement si nécessaire */
  .footer-bottom {
    flex-direction: column;
    gap: 0.8rem;
    text-align: center;
  }

  .footer-item {
    font-size: 0.75rem;
    justify-content: center;
  }

  .footer-edition p {
    font-size: 0.85rem;
  }
}


/* ------------------------------
   Small screens: vote summary layout (max-width: 600px)
   ------------------------------ */
@media (max-width: 600px) {
  #voteSummary {
    grid-template-columns: 1fr;
  }
  .nominee-card-final {
    flex: 1 1 calc(50% - 10px);
  }
}

/* Accessible focus states for keyboard navigation */
.mobile-nav-toggle:focus-visible {
  outline: 2px solid var(--vtafr-purple, #9147ff);
  outline-offset: 3px;
  border-radius: 6px;
}

.nav-list a:focus-visible,
.nav-list .nav-link:focus-visible,
.nav-list .nav-active:focus-visible {
  outline: 2px solid var(--vtafr-purple, #9147ff);
  border-radius: 6px;
}

/* Ultra-compact header for very small widths */
@media (max-width: 460px) {
  .twitch-connect-btn {
    padding: 10px 14px;
    font-size: 0.9rem;
  }
  .header-container,
  .navbar {
    gap: 0.25rem;
  }
  .nav-right {
    gap: 10px;
  }
  .mobile-nav-toggle {
    font-size: 1.2rem;
    padding: 4px;
  }
}

@media (max-width: 380px) {
  /* Hide optional text label if present to keep button on-screen */
  .twitch-connect-btn .btn-text { display: none; }
  .twitch-connect-btn {
    padding: 10px;
    min-width: 44px;
    justify-content: center;
  }
  .twitch-icon {
    width: 26px;
    height: 26px;
  }
}

/* ------------------------------
   Ultra small screens (max-width: 400px)
   - Keep header elements on-screen
   ------------------------------ */
@media (max-width: 400px) {
  /* Reduce excessive side margins from header nav */
  .main-nav { margin: 0 0.5rem; }
  .header-container { padding: 0 8px; gap: 0.25rem; }

  /* Shrink logo a bit more to free space */
  .logo-image { height: 50px; }

  /* Compact Twitch login button: icon-only, tighter padding */
  .twitch-login { padding: 6px 10px; gap: 0.5rem; }
  .twitch-login .login-text { display: none; }
  .twitch-icon { width: 24px; height: 24px; }

  /* Ensure auth stays aligned right */
  .header-container .auth-section { margin-left: auto; }

  /* Keep the user dropdown within the viewport */
  #user-dropdown {
    right: 8px;           /* stick to the right edge with small padding */
    left: auto;
    max-width: calc(100vw - 16px);
    width: min(280px, calc(100vw - 16px));
  }
  /* Hero logo: shrink further so it never overflows */
  .hero-logo {
    max-height: 150px;
    width: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
  }
}

/* Hide the mobile toggle on wider screens where the full nav is visible */
@media (min-width: 769px) {
  .mobile-nav-toggle { 
    display: none !important; 
  }
  
  /* Assurer que le menu est visible sur desktop */
  .nav-list {
    display: flex !important;
    position: static !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
}