/*
 * responsive.css — Comprehensive mobile-first responsive rules
 * Add to HTML: <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
 * Include AFTER style.css in the HTML <head>.
 */

/* ── Safe area & iOS scroll helpers ── */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.sidebar, .result, .search-results, .nav-search .search-results {
  -webkit-overflow-scrolling: touch;
}

/* ── Container padding (mobile-first) ── */
.container {
  padding: 32px 16px;
}

/* ── Nav: hide links below 768px ── */
@media (max-width: 767px) {
  .nav-links { display: none !important; }
}

@media (min-width: 768px) {
  .hamburger { display: none !important; }
}

/* ── Hero font sizes ── */
@media (max-width: 359px) {
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: 0.82rem; }
}
@media (min-width: 360px) and (max-width: 413px) {
  .hero h1 { font-size: 1.6rem; }
  .hero p { font-size: 0.88rem; }
}
@media (min-width: 414px) and (max-width: 599px) {
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.92rem; }
}
@media (min-width: 600px) and (max-width: 767px) {
  .hero h1 { font-size: 2.2rem; }
  .hero p { font-size: 1rem; }
}
@media (min-width: 768px) {
  .hero h1 { font-size: 2.5rem; }
  .hero p { font-size: 1rem; }
}

/* ── Card grid (homepage) ── */
@media (max-width: 413px) {
  .grid { grid-template-columns: 1fr; }
}
@media (min-width: 414px) and (max-width: 767px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Forms ── */
@media (max-width: 413px) {
  .card-form { padding: 18px; }
  .form-group { margin-bottom: 10px; }
  .form-group input, .form-group select { padding: 10px 12px; }
  .btn {
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .file-drop-zone { padding: 16px 14px; }
  .file-drop-zone .dz-icon { font-size: 1.5rem; }
  .file-drop-zone .dz-text { font-size: 0.78rem; }
}
@media (min-width: 414px) {
  .btn { min-height: 44px; }
}

/* ── Tab buttons stack on tiny screens ── */
@media (max-width: 374px) {
  .card-form > div:first-child { flex-direction: column; gap: 6px; }
  .tab-btn {
    font-size: 0.78rem;
    padding: 10px 6px;
    min-height: 44px;
  }
}

/* ── Result box ── */
@media (max-width: 413px) {
  .result {
    max-height: 250px;
    font-size: 0.7rem;
    padding: 10px;
  }
}

/* ── Footer ── */
@media (max-width: 480px) {
  footer { padding: 16px 12px; margin-top: 24px; }
  .footer-links { flex-direction: column; gap: 8px; }
  .footer-links a { font-size: 0.78rem; }
  .footer-copy { font-size: 0.72rem; }
}

/* ── Search (nav) ── */
@media (max-width: 359px) {
  .nav-search { width: 100%; margin: 0; }
  .nav-search.focused { width: 100%; }
  .nav-search .search-results {
    width: calc(100vw - 24px);
    left: -4px;
    max-height: 280px;
  }
}
@media (max-width: 767px) {
  .nav-search input { font-size: 0.75rem; }
}

/* ── Language dropdown overflow fix ── */
@media (max-width: 480px) {
  .lang-menu { right: 0; left: auto; }
}
@media (max-width: 359px) {
  .lang-menu { left: 0; right: auto; min-width: 120px; }
  .lang-btn { font-size: 0.75rem; padding: 6px 8px; min-width: 60px; }
}

/* ── Download modal grid ── */
@media (max-width: 413px) {
  .dl-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 414px) {
  .dl-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 413px) {
  .modal-box { padding: 20px 16px; }
  .dl-option { padding: 14px 6px; min-height: 44px; font-size: 0.75rem; }
}
@media (max-width: 359px) {
  .dl-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
}

/* ── Static pages (About, Privacy, Contact, Social) ── */
@media (max-width: 767px) {
  .static-page { padding: 0 4px; }
  .static-page h2 { font-size: 1.3rem; }
  .static-page p { font-size: 0.85rem; }
}
@media (max-width: 480px) {
  .static-page h2 { font-size: 1.15rem; }
  .contact-card { padding: 14px; }
}
@media (max-width: 413px) {
  .contact-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .contact-icon { font-size: 1.5rem; }
}

/* ── Social grid ── */
@media (max-width: 413px) {
  .social-grid { grid-template-columns: 1fr; }
}
@media (min-width: 414px) {
  .social-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 413px) {
  .social-card { padding: 20px 16px; gap: 4px; }
  .social-icon { font-size: 1.8rem; }
}

/* ── Metadata table → card layout on small screens ── */
@media (max-width: 480px) {
  .meta-table, .meta-table tbody, .meta-table tr, .meta-table td {
    display: block; width: 100%;
  }
  .meta-table tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 8px;
  }
  .meta-table td {
    border: none; padding: 3px 0;
    display: flex; flex-wrap: wrap; gap: 4px;
  }
  .meta-table td:first-child {
    width: auto; white-space: normal;
    font-weight: 600; font-size: 0.72rem;
    text-transform: uppercase; letter-spacing: 0.5px;
  }
  .meta-table td:last-child { font-size: 0.75rem; }
}

/* ── 404 error page ── */
@media (max-width: 480px) {
  .error-code { font-size: 4rem; }
  .error-title { font-size: 1.1rem; }
  .error-desc { font-size: 0.82rem; }
  .error-shapes { display: none; }
}
@media (max-width: 359px) {
  .error-code { font-size: 3rem; }
  .error-title { font-size: 1rem; }
}
@media (min-width: 481px) and (max-width: 767px) {
  .error-shape { animation-duration: 40s; opacity: 0.03; }
}

/* ── Container padding breakpoints ── */
@media (min-width: 414px) {
  .container { padding: 32px 20px; }
}
@media (min-width: 768px) {
  .container { padding: 40px 32px; }
}
@media (max-width: 359px) {
  .container { padding: 24px 12px; }
}

/* ── Sidebar refinements ── */
@media (min-width: 768px) {
  .sidebar { left: -300px; width: 280px; }
  .sidebar.open { left: 0; }
}

/* ── Section gap tightening on small screens ── */
@media (max-width: 480px) {
  section, .page > .card-form { margin-bottom: 14px; }
  .hero { padding: 32px 0; }
}
@media (min-width: 481px) and (max-width: 767px) {
  .hero { padding: 44px 0; }
}

/* ── General mobile tweaks ── */
@media (max-width: 767px) {
  .card { padding: 18px; }
  .card .icon { font-size: 1.5rem; }
  .card h3 { font-size: 0.9rem; }
  .card p { font-size: 0.75rem; }
  .badge { font-size: 0.65rem; padding: 2px 10px; }
}

/* ── Clamp-based fluid typography for modern browsers ── */
.hero h1 {
  font-size: clamp(1.4rem, 4.5vw, 2.5rem);
}
.hero p {
  font-size: clamp(0.82rem, 2.5vw, 1rem);
}

/* ── Responsive iframe / embedded content ── */
iframe, img, video {
  max-width: 100%; height: auto;
}

/* ── Touch-friendly overscroll ── */
.sidebar, .result, .nav-search .search-results {
  overscroll-behavior: contain;
}

/* ── Prevent horizontal overflow on very small devices ── */
body {
  max-width: 100vw;
}

/* ── Theme toggle & lang dropdown compact on small nav ── */
@media (max-width: 767px) {
  .theme-btn { width: 28px; height: 28px; font-size: 0.85rem; }
  .lang-btn { font-size: 0.75rem; padding: 4px 8px; min-width: 56px; }
  nav .logo-img { height: 24px; }
  nav { padding: 8px 12px; gap: 6px; }
  .nav-left { gap: 6px; }
}

/* ── Card-form heading on small screens ── */
@media (max-width: 413px) {
  .card-form h2 { font-size: 1.1rem; margin-bottom: 14px; }
}

/* ── Search results page mobile width ── */
@media (max-width: 480px) {
  #page-search .search-result-item { padding: 12px 14px; }
  #page-search .search-result-title { font-size: 0.85rem; }
  #page-search .search-result-snippet { font-size: 0.72rem; }
}

/* ── Sidebar close button always usable ── */
.sidebar-close {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Nav items alignment on tight screens ── */
@media (max-width: 374px) {
  .nav-left .theme-btn { display: none; }
}
