/* ============================================================
   ALYRIAZ — Mobile & PWA styles
   Design natif : bottom nav, hamburger, touch optimisé
   ============================================================ */

/* ── Variables mobile ───────────────────────────────────────── */
:root {
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Hamburger button ───────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.hamburger:active { background: rgba(255,255,255,0.08); }
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.23,1,0.32,1), opacity 0.2s;
  transform-origin: center;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile slide menu ──────────────────────────────────────── */
.mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
}
.mobile-menu.open { pointer-events: all; }

.mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s;
}
.mobile-menu.open .mobile-menu-backdrop { opacity: 1; }

.mobile-menu-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(320px, 85vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.23,1,0.32,1);
  display: flex;
  flex-direction: column;
  padding: calc(var(--nav-h) + 16px) 0 calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  overflow-y: auto;
}
.mobile-menu.open .mobile-menu-panel { transform: translateX(0); }

.mobile-menu-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.mobile-menu-section:last-child { border-bottom: none; }

.mobile-menu-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 24px 6px;
}

.mobile-menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0;
  min-height: 52px;
}
.mobile-menu-link:active { background: rgba(124,58,237,0.1); }
.mobile-menu-link .link-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(124,58,237,0.1);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.mobile-cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
}
.mobile-cat-btn {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.mobile-cat-btn:active { background: rgba(124,58,237,0.15); border-color: var(--accent); }

/* ── Bottom navigation bar ──────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(10, 10, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 800;
  display: none;
  align-items: stretch;
  justify-content: space-around;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.62rem;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item:active { opacity: 0.7; }

.bottom-nav-item svg {
  width: 22px; height: 22px;
  transition: transform 0.2s;
}
.bottom-nav-item.active svg { transform: scale(1.1); }

.bottom-nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 64px; }

/* Bottom nav write button (center, elevated) */
.bottom-nav-center {
  position: relative;
  top: -10px;
}
.bottom-nav-center .bnav-bubble {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(124,58,237,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}
.bottom-nav-center:active .bnav-bubble {
  transform: scale(0.92);
  box-shadow: 0 2px 10px rgba(124,58,237,0.4);
}

/* ── Search overlay ─────────────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(4,4,12,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 60px 20px 20px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.23,1,0.32,1);
}
.search-overlay.open { transform: translateY(0); }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 16px;
  margin-bottom: 24px;
}
.search-input-wrap svg { color: var(--muted); flex-shrink: 0; }
#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1.05rem;
  font-family: var(--font-body);
  padding: 16px 0;
}
#search-input::placeholder { color: var(--muted); }
.search-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-mono);
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}

#search-results {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.search-result {
  display: block;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.search-result:active { border-color: var(--accent); background: rgba(124,58,237,0.08); }
.search-result-cat { font-family: var(--font-mono); font-size: 0.68rem; color: var(--accent2); margin-bottom: 6px; }
.search-result-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.search-result-excerpt { font-size: 0.8rem; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-empty { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 40px 0; }

/* ── Global overflow guards (all viewports) ─────────────────── */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}
img, video, canvas, iframe { max-width: 100%; }

/* ── Mobile-only responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  /* Show mobile elements */
  .hamburger { display: flex !important; }
  .mobile-menu { display: block; }
  .bottom-nav { display: flex; }

  /* Containers : padding serré + respect viewport */
  .main-container { padding: 0 16px; max-width: 100%; }
  .section { padding: 40px 0 !important; }
  .section-header { margin-bottom: 20px; flex-wrap: wrap; gap: 8px; }

  /* Safe-area top pour la navbar (iPhone notch) */
  #navbar { padding-top: env(safe-area-inset-top, 0px); }

  /* Casser les grilles inline de la page About */
  #about [style*="grid-template-columns: 1fr 1fr"],
  #about [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Typographie : éviter débordement de mots longs */
  h1, h2, h3, .hero-title, .featured-title, .card-title, .article-page-title {
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
  }

  /* Navbar mobile : logo + hamburger seulement */
  .nav-links { display: none !important; }
  .nav-cta   { display: none !important; }

  /* User area sur mobile : compact */
  .nav-actions .user-area { min-width: 0; }
  .nav-actions .user-avatar-wrap { display: flex; }
  .nav-actions .user-avatar { width: 30px; height: 30px; }
  /* Cache l'icône search de la navbar sur mobile (déjà dans bottom nav) */
  .nav-search-btn { display: none !important; }
  /* Bouton "Se connecter" compact */
  .auth-open-btn { padding: 6px 12px !important; font-size: 0.78rem !important; }

  /* Navbar layout serré */
  #navbar { padding: 0 16px; }
  .nav-actions { gap: 8px; }

  /* Pad body for bottom nav */
  body { padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom)); }

  /* ── Hero mobile ─────────────────── */
  .hero { min-height: 100svh; }
  .hero-title { font-size: clamp(2rem, 8vw, 3rem); }
  .hero-sub { font-size: 0.95rem; }
  .hero-cta-group { gap: 10px; }
  .btn-primary, .btn-ghost { padding: 12px 24px; font-size: 0.9rem; }
  .hero-scroll { display: none; }

  /* ── Stats bar mobile ─────────────── */
  .stats-bar {
    grid-template-columns: 1fr 1fr !important;
    gap: 0;
    margin: 0 16px;
  }
  .stat-item {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .stat-item:nth-child(2n) { border-right: none; }
  .stat-item:nth-last-child(-n+2) { border-bottom: none; }
  .stat-num { font-size: 1.4rem; }
  .stat-label { font-size: 0.68rem; }

  /* ── Filters mobile ──────────────── */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    margin-left: -clamp(16px, 4vw, 48px);
    margin-right: -clamp(16px, 4vw, 48px);
    padding-left: clamp(16px, 4vw, 48px);
    padding-right: clamp(16px, 4vw, 48px);
  }
  .filters::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; }

  /* ── Featured card mobile ────────── */
  .featured-card { min-height: 320px; }
  .featured-content { padding: 24px; }
  .featured-title { font-size: 1.6rem; }
  .featured-subtitle { font-size: 0.9rem; }
  .featured-excerpt { display: none; }
  .featured-tags { position: static; margin-top: 16px; justify-content: flex-start; }

  /* ── Article grid mobile ─────────── */
  #articles-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .article-card.wide { grid-column: span 1; }
  .card-thumb { height: 180px; }
  .card-thumb-gradient { height: 4px !important; }
  .card-body { padding: 16px; }
  .card-title { font-size: 1rem; }

  /* ── Section ─────────────────────── */
  .section { padding: 48px 0; }
  .section-header { margin-bottom: 24px; }

  /* ── Stats ───────────────────────── */
  #about > div:last-child { grid-template-columns: 1fr !important; }

  /* ── Footer mobile ───────────────── */
  footer { padding: 32px 16px; margin-top: 40px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }

  /* ── Disable 3D tilt on touch ────── */
  [data-tilt]:hover { transform: none !important; }

  /* ── Tap highlight sur les cards ─── */
  .article-card:active {
    border-color: rgba(124,58,237,0.45);
    transform: scale(0.98) !important;
    transition: transform 0.1s !important;
  }
  .featured-card:active {
    transform: scale(0.99) !important;
    transition: transform 0.1s !important;
  }

  /* ── About grid ───────────────────── */
  #about > .section > div,
  #about > div { grid-template-columns: 1fr !important; }

  /* ── Article page mobile ──────────── */
  .article-hero { min-height: 60svh; padding: 0 16px; }
  .article-page-title { font-size: clamp(1.6rem, 6.5vw, 2.2rem); }
  .article-page-subtitle { font-size: 0.95rem; }
  .article-layout, .article-content { padding-left: 16px; padding-right: 16px; }
  .article-content { font-size: 1rem; line-height: 1.7; }
  .article-content pre { font-size: 0.78rem; overflow-x: auto; }
  .article-content img { border-radius: 10px; }
  .back-link { top: calc(var(--nav-h) + 8px); left: 12px; font-size: 0.8rem; }
  .article-footer-section { padding: 0 16px; }
  #related-grid { grid-template-columns: 1fr !important; }

  /* ── Ticker : réduire ─────────────── */
  .ticker { font-size: 0.75rem; }

  /* ── Social bar mobile ────────────── */
  .article-social-bar { flex-wrap: wrap; gap: 8px; padding: 12px; }
}

/* ── Très petit écran ───────────────────────────────────────── */
@media (max-width: 380px) {
  .hero-title { font-size: 1.9rem; }
  .stat-num { font-size: 1.2rem; }
  .bottom-nav-item span { display: none; }
  .bottom-nav-item { gap: 0; }
}

/* ── Tablet ─────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  #articles-grid { grid-template-columns: repeat(2, 1fr); }
  .article-card.wide { grid-column: span 2; }
}

/* ── Haptic feedback simulation (active states desktop) ─────── */
@media (hover: none) {
  .btn-primary:active { transform: scale(0.97); }
  .btn-ghost:active   { transform: scale(0.97); }
  .filter-btn:active  { transform: scale(0.95); }
}
