/* ==========================================================================
   RESPONSIVE DESIGN - Mobile First Approach
   ========================================================================== */


   
/* ==========================================================================
   RESPONSIVE FIXES - Prevent horizontal overflow and adjust margins
   ========================================================================== */

/* Global overflow prevention */
html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure hero and main containers don't overflow */
.homepage-hero,
.hero-content,
.page__hero,
.page__content {
  max-width: 100%;
  overflow-x: hidden;
}

/* ==========================================================================
   Base Styles - Mobile First (320px and up)
   ========================================================================== */

/* Full width layout override */
.page,
.page__inner-wrap,
#main {
  max-width: 100% !important;
}

.page__content {
  max-width: 100%;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS - Organized by Screen Size
   ========================================================================== */

/* ==========================================================================
   MOBILE NAVIGATION (up to 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  /* Navigation structure */
  .masthead {
    position: relative;
  }

  .greedy-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0.5rem 0;
    position: relative;
    z-index: 1000;
  }

  .greedy-nav__toggle {
    order: 9;
    margin-left: 0.5rem;
    display: block !important;
    visibility: visible !important;
    outline: none;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
    z-index: 1001;
  }

  .search__toggle {
    order: 8;
    position: relative;
    flex-shrink: 0;
    margin-left: 0.25rem;
    z-index: 1001;
  }
  
  .greedy-nav .site-title {
    flex: 1;
    margin-right: auto;
    font-size: 1.1rem;
    padding-right: 0.5rem;
  }
  
  .greedy-nav .site-logo {
    max-width: 80px;
    margin-right: 0.5rem;
  }
  
  /* Hide navigation links on mobile */
  .greedy-nav .visible-links {
    display: none !important;
  }
  
  /* FORCE show the hamburger menu toggle on mobile - override any JS */
  .greedy-nav__toggle,
  .greedy-nav__toggle.hidden {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .greedy-nav__toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }
  
  .greedy-nav__toggle:focus {
    outline: 2px solid #007acc;
    outline-offset: 2px;
  }
  
  /* Ensure buttons don't get too cramped */
  .greedy-nav button {
    min-width: 44px;
    height: 44px;
  }
  
  /* Hamburger icon */
  .navicon {
    display: block !important;
    position: relative;
    width: 1.5rem;
    height: 0.25rem;
    background: currentColor;
    margin: auto;
    transition: 0.3s;
  }
  
  .navicon::before,
  .navicon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 1.5rem;
    height: 0.25rem;
    background: currentColor;
    transition: 0.3s;
  }
  
  .navicon:before {
    top: -0.5rem;
  }
  
  .navicon:after {
    bottom: -0.5rem;
  }
  
  /* Hamburger animation when menu is open */
  .greedy-nav__toggle.close .navicon {
    background: transparent;
  }
  
  .greedy-nav__toggle.close .navicon::before {
    transform: rotate(-45deg);
    top: 0;
  }
  
  .greedy-nav__toggle.close .navicon::after {
    transform: rotate(45deg);
    bottom: 0;
  }
  
  /* Dropdown menu styling */
  .greedy-nav .hidden-links {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    min-width: 200px !important;
    z-index: 1002 !important;
    padding: 0 !important;
    margin-top: 5px !important;
    overflow: hidden !important;
    pointer-events: auto !important;
  }
  
  .greedy-nav .hidden-links:not(.hidden) {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  .greedy-nav .hidden-links.hidden {
    display: none !important;
  }
  
  .greedy-nav .hidden-links li {
    display: block !important;
    margin: 0 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    pointer-events: auto !important;
  }
  
  .greedy-nav .hidden-links li:last-child {
    border-bottom: none !important;
  }
  
  .greedy-nav .hidden-links a {
    display: block !important;
    padding: 16px 20px !important;
    text-decoration: none !important;
    color: #333 !important;
    font-weight: 500 !important;
    transition: background-color 0.2s ease !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 1003 !important;
  }
  
  .greedy-nav .hidden-links a:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
    color: #007acc !important;
  }
  
  /* Background overlay when menu is open */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    pointer-events: none;
  }
  
  body.nav-open::before {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
  }
}

/* ==========================================================================
   TABLET NAVIGATION (768px - 1024px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  .greedy-nav .site-title {
    font-size: 1.25rem;
  }
  
  .greedy-nav__toggle {
    min-width: 48px;
    min-height: 48px;
  }
  
  .greedy-nav .hidden-links {
    min-width: 250px;
  }
}

/* ==========================================================================
   DESKTOP NAVIGATION (1025px+)
   ========================================================================== */
@media (min-width: 1025px) {
  .greedy-nav__toggle.hidden {
    display: none !important;
  }
  
  .greedy-nav .visible-links {
    display: flex !important;
  }
}

/* ==========================================================================
   SIDEBAR POSITIONING
   ========================================================================== */
/* Medium Desktops (64em / 1024px+) */
@media (min-width: 64em) {
  .layout--single .page,
  .layout--home .page,
  .layout--collection .page,
  .layout--archive .page,
  .layout--posts .page {
    float: left;
    width: calc(100% - 300px);
    padding-right: 3rem;
    padding-left: 3.5rem;
  }
  
  .layout--archive .page,
  .layout--posts .page,
  .layout--collection .page {
    padding-left: 4.5rem;
    padding-right: 3.5rem;
  }
  
  .sidebar {
    width: 250px;
    padding-right: 2rem;
  }
  
  .page__inner-wrap {
    float: left;
    width: 100%;
  }
}

/* Large Desktops (80em / 1280px+) */
@media (min-width: 80em) {
  .layout--single .page,
  .layout--home .page,
  .layout--collection .page,
  .layout--archive .page,
  .layout--posts .page {
    width: calc(100% - 320px);
    padding-right: 3.5rem;
    padding-left: 4rem;
  }
  
  .layout--archive .page,
  .layout--posts .page,
  .layout--collection .page {
    padding-left: 5rem;
    padding-right: 4rem;
  }
  
  .page__related {
    max-width: 100%;
  }
  
  .sidebar {
    width: 280px;
    padding-right: 2.5rem;
  }
}

/* ==========================================================================
   MOBILE (up to 767px) - Base Styles
   ========================================================================== */
@media (max-width: 375px) {
  .homepage-hero {
    padding: 1.5rem 1rem; /* Reduced left/right padding */
  }

  .homepage-hero .hero-title {
    font-size: 1.375rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 0.8125rem;
  }

  .blog-card .blog-header h3 {
    font-size: 1rem;
  }

  .page__hero .btn {
    width: 100%;
    text-align: center;
    margin: 0.3rem 0;
  }
  
  .masthead__inner-wrap {
    padding: 0.5rem 0.75rem;
  }
}

/* ==========================================================================
   Small Tablets and Large Phones (376px - 575px)
   ========================================================================== */
@media (min-width: 376px) and (max-width: 575px) {
  .homepage-hero {
    padding: 1.8rem 1rem;
  }

  .homepage-hero .hero-title {
    font-size: 1.625rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 0.9375rem;
  }

  .blog-grid {
    padding: 0 0.8rem;
  }
  
  .blog-card .blog-header h3 {
    font-size: 1.0625rem;
  }
}

/* ==========================================================================
   Tablets (576px - 767px)
   ========================================================================== */
@media (min-width: 576px) and (max-width: 767px) {
  
  .homepage-hero {
    padding: 2rem 1.2rem;
  }

  .homepage-hero .hero-title {
    font-size: 1.75rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 1rem;
  }

  .homepage-hero .hero-description {
    font-size: 0.9375rem;
  }

  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0 1rem;
  }

  .blog-meta {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .author__avatar {
    width: 100px;
    height: 100px;
  }
  
  .blog-card .blog-header h3 {
    font-size: 1.0625rem;
  }
  
  .blog-excerpt {
    font-size: 0.875rem;
  }
}

/* ==========================================================================
   Large Tablets and Small Laptops (768px - 991px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 991px) {
  .homepage-hero {
    padding: 2.2rem 1.5rem;
  }

  .homepage-hero .hero-title {
    font-size: 2rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 1.125rem;
  }

  .homepage-hero .hero-description {
    font-size: 1rem;
  }

  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    padding: 0 1rem;
  }

  .page__hero .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }

  .author__avatar {
    width: 120px;
    height: 120px;
  }
  
  .blog-card .blog-header h3 {
    font-size: 1.125rem;
  }
  
  .blog-excerpt {
    font-size: 0.875rem;
  }
}

/* ==========================================================================
   Laptops and Desktops (992px - 1199px)
   ========================================================================== */
@media (min-width: 992px) and (max-width: 1199px) {
  .homepage-hero {
    padding: 2.5rem 1.5rem;
  }

  .homepage-hero .hero-title {
    font-size: 2.25rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 1.25rem;
  }

  .homepage-hero .hero-description {
    font-size: 1rem;
    max-width: 800px;
  }

  .blog-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
  }

  .author__avatar {
    width: 140px;
    height: 140px;
  }
  
  .blog-card .blog-header h3 {
    font-size: 1.125rem;
  }
  
  .blog-excerpt {
    font-size: 0.875rem;
  }
}

/* ==========================================================================
   Large Desktops (1200px and up)
   ========================================================================== */
@media (min-width: 1200px) {
  .homepage-hero {
    padding: 3rem 2rem;
  }

  .homepage-hero .hero-title {
    font-size: 2.5rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 1.375rem;
  }

  .homepage-hero .hero-description {
    font-size: 1rem;
    max-width: 900px;
  }

  .blog-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.3rem;
    max-width: 100%;
  }

  .blog-card {
    padding: 1.3rem;
  }
  
  .blog-card .blog-header h3 {
    font-size: 1.125rem;
  }
  
  .blog-excerpt {
    font-size: 0.875rem;
  }

  .author__avatar {
    width: 180px;
    height: 180px;
  }
}

/* ==========================================================================
   Extra Large Desktops (1400px and up)
   ========================================================================== */
@media (min-width: 1400px) {
  .hero-content {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .blog-section,
  .page__content {
    max-width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .homepage-hero .hero-title {
    font-size: 2.75rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 1.5rem;
  }
  
  .blog-grid {
    max-width: 100%;
  }
}

/* ==========================================================================
   SPECIAL CONDITIONS
   ========================================================================== */

/* Landscape Orientation */
@media (max-height: 600px) and (orientation: landscape) {
  .homepage-hero {
    padding: 2rem 1.5rem;
  }

  .homepage-hero .hero-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  .homepage-hero .hero-subtitle {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }

  .homepage-hero .hero-description {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .page__hero--overlay {
    padding: 1.5rem 1rem;
  }
}

/* Print Styles */
@media print {
  .homepage-hero,
  .blog-grid {
    page-break-inside: avoid;
  }

  .blog-card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .page__hero .btn,
  .read-more,
  .floating-toggle {
    display: none;
  }
}

/* Reduced Motion (Accessibility) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .blog-card:hover {
    transform: none;
  }

  .author__avatar img:hover {
    transform: none;
  }
}

/* High Contrast Mode (Accessibility) */
@media (prefers-contrast: high) {
  .blog-card {
    border: 2px solid currentColor;
  }

  .btn {
    border: 2px solid currentColor;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets for mobile */
  .btn,
  .read-more,
  a {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
  }

  .blog-card {
    /* Remove hover effects on touch devices */
    transform: none !important;
  }
}
