/* === RESPONSIVE === */
/* Small mobile devices */
@media (max-width: 374px) {
  :root {
    --gutter: 0.75rem;
    --spacing-2xl: 2rem;
  }

  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .post__title {
    font-size: 1.5rem;
  }
}

/* Improved mobile layout and typography */
@media (max-width: 639px) {
  :root {
    --gutter: 1rem;
  }

  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Reduce heading scale on phones */
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.125rem;
  }

  h3 {
    font-size: 1rem;
  }

  /* Tighter nav for mobile */
  .nav-link {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    min-height: 36px;
  }

  /* Single column grids */
  .posts-index .post-grid,
  .post-grid--home {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .post-card {
    margin-bottom: 0;
  }

  /* Hero spacing */
  .hero {
    padding: 2rem 0 1.5rem;
  }

  .hero h1 {
    font-size: 1.625rem;
    margin-bottom: 0.75rem;
  }

  .hero p {
    font-size: 0.9375rem;
    line-height: 1.5;
  }

  /* Section spacing */
  .section-header {
    margin-bottom: 1.25rem;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }

  .footer-brand-title {
    font-size: 1.125rem;
  }

  /* Site main padding */
  .site-main {
    padding: 1.5rem 0;
  }

  /* Footer tighter */
  .site-footer {
    padding: 2rem 0 1.5rem;
    margin-top: 2rem;
  }

  /* About page mobile */
  .about-hero h1 {
    font-size: 1.5rem;
  }

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

  .about-content {
    padding: 1.5rem 0;
  }

  .about-content p,
  .about-content li {
    font-size: 0.9375rem;
    line-height: 1.6;
  }

  .about-content h2 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
  }

  .about-content h3 {
    font-size: 1.0625rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
  }

  .lead {
    font-size: 1rem;
    line-height: 1.6;
  }

  .about-intro {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
  }

  /* Hide category tag on post cards in mobile */
  .post-card-category-wrapper {
    display: none;
  }
}

/* Tablet and up */
@media (min-width: 640px) {
  :root {
    --gutter: 1.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;
  }

  h1 {
    font-size: 2.5rem;
  }

  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .hero h1 {
    font-size: 3rem;
  }

  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .insight-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .post-gallery__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .featured-post {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }

  .featured-post__media {
    height: 100%;
    min-height: 400px;
  }

  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  :root {
    --gutter: 2rem;
  }

  h1 {
    font-size: 3rem;
  }

  .post-header .post-title {
    font-size: 3.5rem;
  }

  .hero h1 {
    font-size: 3.5rem;
  }

  .post__title {
    font-size: 3rem;
  }

  .post__layout {
    grid-template-columns: 1fr 300px;
  }

  .post-sidebar {
    order: 0;
    position: sticky;
    top: 5.5rem;
    align-self: start;
  }

  .post-gallery__grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .post-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .featured-post__media {
    min-height: 500px;
  }

  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* === PRINT STYLES === */
@media print {

  /* Hide non-essential elements */
  .site-header,
  .site-nav,
  .reading-progress,
  .back-to-top,
  .share-buttons,
  .post__footer,
  .site-footer,
  footer {
    display: none !important;
  }

  /* Reset layout for print */
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  /* Ensure readable text */
  h1 {
    font-size: 24pt;
    page-break-after: avoid;
  }

  h2 {
    font-size: 18pt;
    page-break-after: avoid;
  }

  h3 {
    font-size: 14pt;
    page-break-after: avoid;
  }

  h4,
  h5,
  h6 {
    font-size: 12pt;
    page-break-after: avoid;
  }

  /* Avoid breaking inside elements */
  img,
  figure,
  table,
  pre,
  blockquote {
    page-break-inside: avoid;
  }

  /* Show link URLs */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 10pt;
    color: #666;
  }

  /* Remove link styling */
  a {
    color: #000;
    text-decoration: underline;
  }

  /* Optimize images */
  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Add page breaks */
  .post {
    page-break-before: always;
  }

  /* Ensure content width */
  .container,
  .content-wrapper,
  .post__content {
    max-width: 100%;
    width: 100%;
  }

  /* Hide interactive elements when printing */
  .nav-toggle,
  .search-toggle,
  .share-buttons,
  .language-switcher,
  button,
  .spinner {
    display: none !important;
  }

  /* Ensure links are visible */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Don't show link URLs for internal anchors */
  a[href^="#"]:after,
  a[href^="javascript:"]:after {
    content: "";
  }
}

/* ===  COMPREHENSIVE MOBILE OPTIMIZATION === */
@media (max-width: 768px) {
  .category-hero {
    padding: var(--spacing-2xl) 0 var(--spacing-xl);
  }

  .category-hero h1 {
    font-size: clamp(1.9rem, 6vw, 2.3rem);
  }

  .category-hero__subtitle {
    font-size: 0.95rem;
    margin-bottom: var(--spacing-lg);
  }

  .category-stats {
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: center;
  }

  .category-stat {
    width: 100%;
    max-width: 220px;
  }

  .category-stat strong {
    font-size: 1.6rem;
  }

  .category-showcase {
    padding: var(--spacing-2xl) 0;
  }

  .category-showcase .section-header {
    margin-bottom: var(--spacing-xl);
  }

  .category-showcase .section-header h2 {
    font-size: 1.6rem;
  }

  .category-showcase .section-header p {
    font-size: 0.95rem;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(0.65rem, 4vw, 1rem);
  }

  .category-card-new {
    padding: clamp(1.1rem, 4vw, 1.4rem);
    min-height: 200px;
    border-radius: 18px;
    align-items: center;
    text-align: center;
  }

  .category-card-new__content {
    align-items: center;
  }

  .category-card-new__badge {
    font-size: 0.6rem;
    padding: 0.25rem 0.6rem;
    top: 0.75rem;
    right: 0.75rem;
  }

  .category-card-new__icon {
    width: min(110px, 64%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
  }

  .category-card-new__title {
    font-size: 1.1rem;
  }

  .category-card-new__desc {
    font-size: 0.82rem;
    line-height: 1.45;
    max-width: 24ch;
  }

  .category-card-new__footer {
    gap: 0.45rem;
    padding-top: 0.7rem;
  }

  .category-card-new__count {
    padding: 0.4rem 0.75rem;
    font-size: 0.76rem;
  }

  .category-card-new__link {
    font-size: 0.8rem;
  }

  /* Share buttons mobile */
  .share-buttons {
    gap: 0.5rem;
  }

  .share-btn {
    padding: 0.55rem 1rem;
    font-size: 0.8125rem;
    gap: 0.4rem;
  }

  .share-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Language switcher mobile */
  .language-switcher__button {
    padding: 0.65rem 1.2rem;
    font-size: 0.8125rem;
    gap: 0.5rem;
  }

  /* Post meta tags mobile */
  .post__meta-tags {
    gap: 0.4rem;
  }

  .post__meta-tags a {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
  }

  /* Category cards mobile - 2 COLUMNS */
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .category-card-new {
    min-height: auto;
    aspect-ratio: 1 / 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .category-card-new__circle {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
  }

  .category-card-new__circle img {
    width: 32px;
    height: 32px;
  }

  .category-card-new__title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
  }

  .category-card-new__desc {
    display: none; /* Hide description on mobile to keep it square/clean */
  }

  .category-card-new__footer {
    padding-top: 0.25rem;
    font-size: 0.75rem;
  }

  /* Post cards mobile - Single column for professional look */
  .post-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .post-card {
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  .post-card-image {
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    height: 110px;
    min-height: 110px;
    max-height: 110px;
    border-radius: 8px 0 0 8px;
    object-fit: cover;
    flex-shrink: 0;
  }

  .post-card-content {
    padding: 0.625rem 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
  }

  .post-card-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .post-card-excerpt {
    font-size: 0.6875rem;
    margin-bottom: 0.375rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    color: #64748b;
  }

  .post-card-meta {
    font-size: 0.625rem;
    margin-bottom: 0;
    padding-top: 0;
    border-top: none;
    color: #94a3b8;
  }

  .post-card-divider {
    display: none;
  }

  .post-card-reading-time {
    display: none;
  }

  /* Hero section mobile */
  .hero {
    padding: 2.5rem 0 1.75rem;
  }

  .hero h1 {
    font-size: 1.75rem;
    line-height: 1.25;
  }

  .hero p {
    font-size: 0.9375rem;
  }

  /* Container mobile */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Featured post mobile */
  .featured-post {
    flex-direction: column;
    border-radius: 12px;
  }

  .featured-post__media {
    border-radius: 12px 12px 0 0;
    height: 180px;
  }

  .featured-post__body {
    padding: 1rem 1.25rem 1.25rem;
  }

  .featured-post__body h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
  }

  .featured-post__body p {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
  }

  .featured-badge {
    font-size: 0.625rem;
    margin-bottom: 0.5rem;
  }

  .featured-post__meta {
    font-size: 0.75rem;
  }

  .featured-post__link {
    font-size: 0.8125rem;
  }

  /* Navigation mobile - keep horizontal */
  .header-inner {
    gap: 1rem;
  }

  .nav-menu {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav__logo {
    max-width: 140px;
  }

  /* Post header mobile */
  .post__header {
    padding: 2rem 0;
  }

  .post__title {
    font-size: 1.75rem;
    margin-bottom: 1rem;
  }

  .post__description {
    font-size: 1rem;
  }

  /* Related posts mobile */
  .related-posts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  /* Extra small devices */
  .container {
    padding-left: 0.875rem;
    padding-right: 0.875rem;
  }

  .share-btn span {
    display: none;
  }

  .share-btn {
    padding: 0.5rem;
    min-width: 40px;
    min-height: 40px;
  }

  /* Compact post cards */
  .post-card-image {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    height: 90px;
    min-height: 90px;
    max-height: 90px;
  }

  .post-card-content {
    padding: 0.5rem;
  }

  .post-card-title {
    font-size: 0.8125rem;
  }

  .post-card-excerpt {
    font-size: 0.6875rem;
  }

  .post-card-meta {
    font-size: 0.625rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero p {
    font-size: 0.875rem;
  }

  /* Tighter section spacing */
  .section-header h2 {
    font-size: 1.125rem;
  }

  .eyebrow {
    font-size: 0.6875rem;
  }
}

/* === MODERN RESPONSIVE UTILITIES === */

/* Orientation-based styles */
@media (orientation: landscape) and (max-height: 600px) {
  .hero {
    padding: var(--spacing-lg) 0;
  }

  .search-modal {
    padding: 1rem;
  }

  .site-header {
    padding: 0.5rem 0;
  }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

  /* Optimize images for retina */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
  }
}

/* Hover-capable devices only */
@media (hover: hover) and (pointer: fine) {

  /* Enable advanced hover effects only on devices that support hovering */
  .post-card:hover {
    transform: translateY(-6px);
  }

  .nav-link:hover {
    transform: translateY(-1px) translateZ(0);
  }

  .hover-lift:hover {
    transform: translateY(-2px) translateZ(0);
  }
}

/* Touch-only devices */
@media (hover: none) and (pointer: coarse) {

  /* Disable transforms on hover for touch devices */
  .post-card:hover {
    transform: none;
  }

  /* Larger tap targets */
  button,
  a,
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects that don't work well on touch */
  .nav-link:hover {
    transform: none;
  }
}

/* Prefer reduced data usage */
@media (prefers-reduced-data: reduce) {

  /* Disable heavy animations */
  *,
  *::before,
  *::after {
    animation-duration: 0.1ms !important;
    transition-duration: 0.1ms !important;
  }

  /* Simplify gradients */
  .post-card {
    background: #ffffff;
  }

  /* Disable backdrop blur (expensive) */
  .site-header {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.98);
  }
}

/* Dark mode support (future-proof) */
/* Placeholder for future dark mode styles using @media (prefers-color-scheme: dark) */
/* Add them here when ready. */