/* ==================================================
   MEDIA QUERIES (RESPONSIVIDADE OTIMIZADA)
   ================================================== */

/* ---------- Tablet pequeno / landscape (≤ 900px) ---------- */
@media (max-width: 900px) {
  .sobre-grid,
  .cae-grid,
  .eleicoes-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  .cta-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-brand {
    grid-column: span 2;
    text-align: center;
  }

  .footer-heading::after {
    left: 50%;
    transform: translateX(-50%);
  }

  .footer-links {
    align-items: center;
  }

  .footer-nav,
  .footer-contact {
    text-align: center;
  }

  .footer-social {
    justify-content: center;
  }
}

/* ---------- Dispositivos médios (≤ 768px) ---------- */
@media (max-width: 768px) {
  /* --- Menu / Navegação --- */
  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    z-index: 999;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a,
  .dropdown-toggle {
    padding: 0.6rem 0.9rem;
    font-size: 1rem;
  }

  /* Dropdown mobile */
  .dropdown {
    width: 100%;
  }

  .dropdown-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
    background: var(--bg-alt);
    border: none;
    box-shadow: none;
    padding-left: 1rem;
    margin-top: 0.25rem;
    width: 100%;
  }

  .dropdown-toggle[aria-expanded="true"] + .dropdown-menu {
    display: block;
  }

  .navbar {
    padding: 0 1rem;
  }

  .nav-inner {
    height: 60px;
  }

  .logo-img {
    height: 35px;
  }

  .logo-gepaf {
    font-size: 1.4rem;
  }

  .logo-sub {
    font-size: 0.5rem;
  }

  .nav-search-btn {
    padding: 6px 10px;
    font-size: 0.9rem;
  }

  /* --- Search Modal --- */
  .search-modal {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }

  .search-overlay {
    align-items: flex-end;
    padding-top: 0;
  }

  .search-input {
    font-size: 0.95rem;
  }

  .search-result-item {
    gap: 8px;
    padding: 8px 10px;
  }

  .search-result-type {
    font-size: 0.6rem;
    padding: 2px 6px;
  }

  .search-result-text {
    font-size: 0.85rem;
  }

  .search-result-snippet {
    font-size: 0.7rem;
  }

  /* --- Hero --- */
  .hero-title {
    gap: 0.2em;
  }
  .hero-big {
    font-size: clamp(2.5rem, 8vw, 5rem);
  }
  .hero-outline {
    font-size: clamp(1.2rem, 4vw, 2rem);
  }
  .hero-desc {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
  }
  .hero-stats {
    gap: 1rem;
  }
  .stat-num {
    font-size: 2rem;
  }
  .stat-label {
    font-size: 0.55rem;
  }

  /* --- Footer --- */
  .footer-inner {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1.5rem;
  }
  .footer-brand {
    grid-column: span 1;
  }
  .footer-logo {
    font-size: 3rem;
  }
  .ubes-logo {
    width: 90px;
  }
  .umes-logo {
    width: 70px;
  }

  /* --- Timeline --- */
  .timeline-full::before {
    display: none;
  }
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .timeline-year-badge {
    display: inline-block;
    width: auto;
    margin-bottom: 0.3rem;
  }

  /* --- Acessibilidade --- */
  .a11y-bar {
    bottom: 1rem;
    right: 1rem;
  }

  /* --- Abas --- */
  .tab-buttons {
    flex-direction: column;
    gap: 0;
  }
  .tab-btn {
    width: 100%;
    text-align: center;
    padding: 0.75rem;
    border-radius: 10px 10px 0 0;
    font-size: 0.9rem;
  }

  /* --- Tabela histórica --- */
  .historico-table thead {
    display: none;
  }
  .historico-table tbody,
  .historico-table tbody tr,
  .historico-table tbody td {
    display: block;
  }
  .historico-table tbody tr {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
  }
  .historico-table tbody td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    padding-left: 45%;
    font-size: 0.85rem;
  }
  .historico-table tbody td:last-child {
    border-bottom: none;
  }
  .historico-table tbody td::before {
    position: absolute;
    left: 1rem;
    top: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--verde);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .historico-table tbody td:nth-child(1)::before {
    content: "Ano";
  }
  .historico-table tbody td:nth-child(2)::before {
    content: "Evento";
  }
  .historico-table tbody td:nth-child(3)::before {
    content: "Status";
  }

  /* --- Eleições --- */
  .eleicoes-grid,
  .cae-grid {
    gap: 1rem;
  }
  .eleicao-year {
    font-size: 1.8rem;
    padding: 0.7rem 1rem;
  }
  .chapa {
    padding: 0.75rem;
  }

  /* --- Cards gerais --- */
  .sobre-card,
  .mob-card,
  .gestao-card,
  .eixo-card,
  .estrutura-card,
  .curiosidade {
    padding: 1.2rem;
  }

  /* --- Estrutura organizacional --- */
  .org-split {
    flex-direction: column;
    gap: 1rem;
  }
  .org-branch {
    min-width: unset;
  }
  .org-card {
    max-width: 100%;
  }
  .org-horizontal-connector {
    width: 100%;
    flex-wrap: wrap;
  }
  .connector-label {
    white-space: normal;
    text-align: center;
    font-size: 0.65rem;
  }

  .temp-cards {
    flex-direction: column;
    align-items: center;
  }

  .crb-blocos {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* --- Galeria --- */
  .galeria-breadcrumb {
    font-size: 0.7rem;
    padding: 0.5rem 0.8rem;
  }
  .album-card {
    max-width: 100%;
  }
  .galeria-item span {
    font-size: 0.7rem;
  }

  /* --- Biblioteca --- */
  .pdf-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .pdf-icon {
    font-size: 2rem;
  }
  .pdf-actions {
    flex-wrap: wrap;
  }

  /* --- Cartilha --- */
  .cartilha-card {
    flex-direction: column;
    text-align: center;
    padding: 1.2rem;
  }
  .cartilha-heading {
    font-size: 1.4rem;
  }
  .cartilha-desc {
    max-width: 100%;
  }

  /* --- Presidentes --- */
  .presidentes-cards-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .presidente-card-inner {
    padding: 1rem;
  }
  .presidente-avatar {
    width: 60px;
    height: 60px;
  }
  .presidente-initials {
    font-size: 1.5rem;
  }
  .presidente-nome {
    font-size: 1.1rem;
  }
  .presidente-resumo {
    font-size: 0.8rem;
  }

  /* --- Modal (membros/presidentes) --- */
  .membros-modal-content {
    width: 90%;
    padding: 1.5rem;
    max-height: 80vh;
    overflow-y: auto;
  }

  /* Modal estilo bottom sheet */
  .membros-modal-overlay {
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    padding: 0;
  }

  .membros-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem;
    margin: 0;
    background: var(--card-bg);
    border-top: 3px solid var(--verde-light);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
  }

  .membros-modal-overlay.active .membros-modal-content {
    transform: translateY(0);
  }

  .membros-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: var(--verde-dim);
    border-radius: 30px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    z-index: 10;
    transition: all 0.2s;
  }

  .membros-modal-close:hover {
    background: var(--verde-light);
    color: white;
  }

  #modal-global-title {
    font-size: 1.5rem;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
    padding-right: 2rem;
    color: var(--verde-light);
    font-family: var(--font-display);
    letter-spacing: -0.01em;
  }

  .membros-lista p {
    font-size: 0.9rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .membros-lista strong {
    min-width: 110px;
    color: var(--verde-accent);
  }

  .membros-modal-content ul {
    padding-left: 1.2rem;
    margin: 0.5rem 0;
  }

  .membros-modal-content li {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--muted);
  }

  .membros-modal-close i {
    font-size: 1.2rem;
  }
}

/* ---------- Telas menores que 640px ---------- */
@media (max-width: 640px) {
  body {
    font-size: 15px;
  }
  .section {
    padding: 3rem 0;
  }
  .section-heading {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 1rem;
  }
  .container {
    padding: 0 1rem;
  }

  /* Hero */
  .hero-tag {
    font-size: 0.6rem;
    padding: 0.3rem 0.8rem;
  }
  .hero-italic {
    font-size: 1.5rem;
  }
  .hero-big {
    font-size: clamp(2rem, 7vw, 4rem);
  }
  .hero-outline {
    font-size: 1rem;
    -webkit-text-stroke: 1px rgba(255,255,255,0.6);
  }
  .hero-desc {
    font-size: 0.85rem;
  }
  .hero-actions {
    gap: 0.8rem;
  }
  .btn-hero,
  .btn-hero-ghost {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
  }
  .hero-stats {
    gap: 0.8rem;
  }
  .stat-num {
    font-size: 1.5rem;
  }

  /* Grids únicos */
  .sobre-grid,
  .gestoes-grid,
  .eixos-grid,
  .curiosidades-grid,
  .estrutura-grid,
  .eventos-list,
  .comunicacao-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Cards */
  .sobre-card,
  .mob-card,
  .gestao-card,
  .eixo-card,
  .estrutura-card,
  .curiosidade {
    padding: 1rem;
  }

  /* Galeria */
  .albuns-grid,
  .galeria-items {
    grid-template-columns: 1fr;
  }
  .album-cover {
    aspect-ratio: 16/9;
  }

  /* Tabela de eventos */
  .evento-item {
    grid-template-columns: 60px 1fr auto;
    gap: 0.8rem;
    padding: 1rem 0;
  }
  .evento-ano {
    font-size: 1.2rem;
    padding: 0.2rem 0.5rem;
  }

  /* Curiosidades */
  .curio-num {
    font-size: 3rem;
  }

  /* Footer */
  .footer-inner {
    gap: 1.5rem;
  }
  .footer-logo {
    font-size: 2.5rem;
  }
  .footer-heading {
    font-size: 0.8rem;
  }
  .footer-links a,
  .footer-address p,
  .footer-email {
    font-size: 0.8rem;
  }
  .footer-social a {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  /* Arquivo histórico */
  .arquivo-historico {
    padding: 1.2rem;
  }
  .arquivo-header {
    flex-direction: column;
    text-align: center;
  }
  .arquivo-links {
    grid-template-columns: 1fr;
  }
}

/* ---------- Telas muito pequenas (≤ 480px) ---------- */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  /* Hero */
  .hero-stats {
    flex-wrap: wrap;
    justify-content: center;
  }
  .stat-item {
    min-width: 70px;
  }
  .stat-num {
    font-size: 1.3rem;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  .btn-hero,
  .btn-hero-ghost {
    width: 100%;
    justify-content: center;
  }

  /* Cards */
  .sobre-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .sobre-card .card-icon {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .tab-panel {
    padding: 1rem;
  }

  .timeline-full {
    padding: 0.5rem;
  }

  .composicoes-details summary,
  .timeline-details summary {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
  }

  .chapa-nome {
    font-size: 0.85rem;
  }
  .chapa-lema {
    font-size: 0.7rem;
  }

  .presidente-card-inner {
    padding: 0.8rem;
  }
  .presidente-avatar {
    width: 50px;
    height: 50px;
  }
  .presidente-initials {
    font-size: 1.2rem;
  }
  .btn-presidente-detalhes {
    padding: 0.3rem 0.8rem;
    font-size: 0.7rem;
  }

  /* Modal membros */
  .membros-modal-content {
    padding: 1.2rem;
    max-height: 80vh;
  }

  #modal-global-title {
    font-size: 1.3rem;
  }

  .membros-lista p {
    font-size: 0.8rem;
    padding: 0.5rem 0;
  }

  .membros-lista strong {
    min-width: 90px;
  }

  .back-to-top {
    width: 36px;
    height: 36px;
    bottom: 1rem;
    right: 1rem;
  }
}

/* ---------- Telas extremamente pequenas (≤ 375px) ---------- */
@media (max-width: 375px) {
  .hero-title {
    gap: 0.1em;
  }
  .hero-italic {
    font-size: 1.2rem;
  }
  .hero-big {
    font-size: 1.8rem;
  }
  .hero-outline {
    font-size: 0.9rem;
  }
  .hero-tag {
    font-size: 0.55rem;
  }
  .hero-desc {
    font-size: 0.75rem;
  }

  .section-heading {
    font-size: 1.8rem;
  }

  .timeline-year-badge {
    font-size: 0.7rem;
  }
  .timeline-events div {
    font-size: 0.75rem;
  }

  .evento-item {
    grid-template-columns: 50px 1fr auto;
    gap: 0.5rem;
  }
  .evento-ano {
    font-size: 1rem;
  }
  .evento-info strong {
    font-size: 0.85rem;
  }
  .evento-info span {
    font-size: 0.7rem;
  }

  .footer-logo {
    font-size: 2rem;
  }
  .ubes-logo {
    width: 70px;
  }
  .umes-logo {
    width: 55px;
  }
}

/* ---------- Dispositivos com touch (esconder cursor customizado) ---------- */
@media (pointer: coarse) {
  body {
    cursor: auto;
  }
  .cursor,
  .cursor-follower {
    display: none !important;
  }
}

/* ---------- Preferência de movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
@media (max-width: 480px) {
  .a11y-btn {
    width: auto;
    padding: 0 0.6rem;
    font-size: 0.8rem;
  }
}