/* ==========================================================================
   Responsive CSS — JeffAPierson.com
   Supplements style.css breakpoints with additional responsive adjustments.
   Main breakpoints (480px, 768px, 1024px) are in style.css.
   This file covers: sidebar overlay, touch targets, zoom prevention,
   reduced motion, and print styles.
   ========================================================================== */

/* ==========================================================================
   Desktop Large — 1400px+
   ========================================================================== */

@media (min-width: 1400px) {
  .main-content {
    max-width: 1200px;
  }
}

/* ==========================================================================
   Tablet — additional 1024px tweaks
   ========================================================================== */

@media (max-width: 1024px) {
  /* Stats grid: stays 3 columns at tablet */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  /* Article grid: 2 columns */
  .article-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

/* ==========================================================================
   Mobile — additional 768px tweaks
   ========================================================================== */

@media (max-width: 768px) {
  /* Stats grid: single column */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Article grid: single column */
  .article-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Tables: horizontal scroll wrapper */
  .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrapper table {
    min-width: 600px;
  }

  /* Footer: single column */
  .footer-grid,
  .footer-columns {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
  }

  /* Section headers: stack vertically */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ==========================================================================
   Small Mobile — additional 480px tweaks
   ========================================================================== */

@media (max-width: 480px) {
  /* Cards: tighter padding */
  .card,
  .stat-card,
  .article-card,
  .feature-card {
    padding: 16px;
  }

  /* Buttons: full width (except small variants) */
  .btn:not(.btn-sm) {
    width: 100%;
    text-align: center;
  }

  /* Reduce heading sizes */
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }

  /* Form elements: full width stack */
  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  /* Compact spacing */
  .section {
    padding: 24px 0;
  }
}

/* ==========================================================================
   Sidebar Overlay (supplemental to style.css)
   ========================================================================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 898;
}

.sidebar-overlay.active {
  display: block;
}

/* ==========================================================================
   Touch Targets — min 44px on touch devices
   ========================================================================== */

@media (pointer: coarse) {
  button,
  a,
  input[type="submit"],
  input[type="button"],
  .btn,
  .nav-link,
  select {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-link {
    padding: 10px 16px;
  }

  .sidebar-nav a {
    padding: 12px 16px;
  }
}

/* ==========================================================================
   Input Zoom Prevention — iOS
   16px font-size prevents Safari from zooming on focus
   ========================================================================== */

@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="url"],
  input[type="tel"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px;
    min-height: 44px;
    padding: 8px 12px;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@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;
  }

  .sidebar,
  .sidebar-overlay {
    transition: none !important;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  /* Hide non-essential UI */
  .sidebar,
  .sidebar-overlay,
  .site-header,
  .hamburger,
  .btn,
  button,
  .footer-nav,
  .back-to-top {
    display: none !important;
  }

  /* White background, black text */
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
    line-height: 1.5;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .site-footer {
    margin-left: 0 !important;
  }

  /* Remove dark backgrounds from cards and sections */
  .card,
  .stat-card,
  .article-card,
  .feature-card,
  .hero,
  .section,
  .site-footer {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }

  /* Links: show URLs after text */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
    word-break: break-all;
  }

  /* Don't show URL for anchor links or JS links */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  /* Headings: keep with next content */
  h1, h2, h3, h4, h5, h6 {
    color: #000 !important;
    break-after: avoid;
  }

  /* Images: grayscale for ink saving */
  img {
    max-width: 100% !important;
    filter: grayscale(100%);
    break-inside: avoid;
  }

  /* Tables: borders for readability */
  table {
    border-collapse: collapse;
    width: 100%;
  }

  th, td {
    border: 1px solid #999 !important;
    padding: 6px 8px;
    color: #000 !important;
    background: #fff !important;
  }

  /* Footer: visible but simplified */
  .site-footer {
    display: block !important;
    border-top: 1px solid #999;
    padding-top: 12px !important;
  }

  /* Page margins */
  @page {
    margin: 1.5cm;
  }
}
