/* ============================================
   CALIUS DIGITAL - Responsive Styles
   Mobile-First Responsive Design
   ============================================ */

/* ============================================
   Mobile First Base (320px+)
   ============================================ */

/* Already covered in main.css */

/* Small-screen header & hero tweaks to prevent clipping */
@media (max-width: 600px) {
  :root {
    --header-height: 56px;
  }

  .hero {
    padding-top: calc(var(--header-height) + 1rem);
    padding-bottom: var(--spacing-2xl);
  }

  .hero-title {
    line-height: 1.15;
  }

  .hero-subtitle {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }
}

/* ============================================
   Small Devices (480px+)
   ============================================ */

@media (min-width: 480px) {
  .hero-cta {
    flex-direction: row;
  }
  
  .btn {
    width: auto;
  }
  
  .card-grid-mobile {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   Tablets (768px+)
   ============================================ */

@media (min-width: 768px) {
  :root {
    --header-height: 70px;
  }
  
  /* Typography */
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.75rem; }
  
  .hero-title { font-size: 3rem; }
  
  /* Navigation */
  .nav-menu {
    display: flex;
  }
  
  .mobile-menu-toggle {
    display: none;
  }
  
  /* Grid */
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Template Cards */
  .template-card {
    display: flex;
    flex-direction: column;
  }
  
  .template-card-image {
    height: 250px;
  }
  
  /* Blog Cards */
  .blog-card-featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
  }
  
  .blog-card-featured .card-image {
    height: 100%;
  }
  
  /* Footer */
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Forms */
  .form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
  }
  
  /* Checkout */
  .checkout-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: var(--spacing-2xl);
  }
}

/* ============================================
   Desktop (1024px+)
   ============================================ */

@media (min-width: 1024px) {
  /* Typography */
  h1 { font-size: 3rem; }
  h2 { font-size: 2.5rem; }
  
  .hero-title { font-size: 3.5rem; }
  
  /* Grid */
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  
  /* Template Grid */
  .template-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Blog Grid */
  .blog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Footer */
  .footer-content {
    grid-template-columns: repeat(4, 1fr);
  }
  
  /* Sidebar Layout */
  .sidebar-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: var(--spacing-2xl);
  }
  
  /* Two Column Layout */
  .two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-2xl);
  }
  
  /* Three Column Layout */
  .three-column {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-2xl);
  }
}

/* ============================================
   Large Desktop (1280px+)
   ============================================ */

@media (min-width: 1280px) {
  .hero-title { font-size: 4rem; }
  
  .template-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .container-wide {
    max-width: 1440px;
  }
}

/* ============================================
   Extra Large Desktop (1536px+)
   ============================================ */

@media (min-width: 1536px) {
  .hero-title { font-size: 4.5rem; }
  
  .container-xl {
    max-width: 1600px;
  }
}

/* ============================================
   Responsive Images
   ============================================ */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.img-responsive {
  width: 100%;
  height: auto;
}

.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-contain {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============================================
   Responsive Typography
   ============================================ */

.text-responsive {
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.heading-responsive {
  font-size: clamp(2rem, 5vw, 4rem);
}

/* ============================================
   Responsive Spacing
   ============================================ */

.section-responsive {
  padding: clamp(2rem, 5vw, 4rem) 0;
}

.container-responsive {
  padding: 0 clamp(1rem, 3vw, 1.5rem);
}

/* ============================================
   Responsive Navigation
   ============================================ */

@media (max-width: 767px) {
  .nav-menu-mobile {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-xl);
    transition: left var(--transition-base);
    overflow-y: auto;
    z-index: 999;
  }
  
  .nav-menu-mobile.active {
    left: 0;
  }
  
  .nav-menu-mobile .nav-menu {
    flex-direction: column;
    padding: var(--spacing-lg);
  }
  
  .nav-menu-mobile .nav-link {
    width: 100%;
    padding: var(--spacing-md);
  }
  
  .mobile-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 998;
  }
  
  .mobile-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* Support using the primary .nav-menu as an off-canvas mobile menu */
  .nav-menu {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    width: 80%;
    max-width: 320px;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-xl);
    transition: left var(--transition-base);
    overflow-y: auto;
    z-index: 999;
    flex-direction: column;
    padding: var(--spacing-lg);
  }

  .nav-menu.active { left: 0; }

  .nav-menu .nav-link { width: 100%; padding: var(--spacing-md); }
}

/* ============================================
   Responsive Tables
   ============================================ */

@media (max-width: 767px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table-mobile-cards {
    display: block;
  }
  
  .table-mobile-cards thead {
    display: none;
  }
  
  .table-mobile-cards tbody,
  .table-mobile-cards tr,
  .table-mobile-cards td {
    display: block;
    width: 100%;
  }
  
  .table-mobile-cards tr {
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
  }
  
  .table-mobile-cards td {
    text-align: right;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
  }
  
  .table-mobile-cards td:last-child {
    border-bottom: none;
  }
  
  .table-mobile-cards td::before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    color: var(--text-primary);
  }
}

/* ============================================
   Responsive Modals
   ============================================ */

@media (max-width: 767px) {
  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 5vh auto;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-md);
  }
}

/* ============================================
   Responsive Cards
   ============================================ */

@media (max-width: 767px) {
  .card-horizontal {
    flex-direction: column;
  }
  
  .card-horizontal .card-image {
    width: 100%;
    height: 200px;
  }
}

/* ============================================
   Hide/Show Elements by Screen Size
   ============================================ */

/* Hide on mobile */
.hide-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
}

/* Show only on mobile */
.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none;
  }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .hide-tablet {
    display: none;
  }
}

/* Hide on desktop */
@media (min-width: 1024px) {
  .hide-desktop {
    display: none;
  }
}

/* ============================================
   Responsive Utilities
   ============================================ */

.flex-mobile-column {
  display: flex;
}

@media (max-width: 767px) {
  .flex-mobile-column {
    flex-direction: column;
  }
}

.stack-mobile {
  display: flex;
  gap: var(--spacing-md);
}

@media (max-width: 767px) {
  .stack-mobile {
    flex-direction: column;
  }
  
  .stack-mobile > * {
    width: 100%;
  }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .btn,
  .nav-link,
  a {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Remove hover effects on touch devices */
  .card:hover {
    transform: none;
  }
  
  /* Optimize scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================
   Landscape Orientation
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    padding-top: calc(var(--header-height) + var(--spacing-xl));
    padding-bottom: var(--spacing-xl);
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .section {
    padding: var(--spacing-xl) 0;
  }
}

/* ============================================
   High DPI Displays
   ============================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Optimize for retina displays */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* ============================================
   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;
  }
}

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Uncomment to enable dark mode
  :root {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --border-color: #374151;
  }
  */
}
