/**
 * PHC TOP Pro 2.0.0 - RESPONSIVE GRID STYLES
 * 
 * Intelligent grid system with responsive columns
 * Mobile-first, CSS Grid based, fully flexible
 * 
 * @package PHC_TOP
 * 
 */

/* ========================================
   GRID BASE STYLES
   ======================================== */

.phc-grid {
  display: grid;
  grid-template-columns: repeat(var(--phc-grid-cols, 3), 1fr);
  gap: var(--component-gap, 24px);
  width: 100%;
  margin-bottom: var(--block-gap);
}

/* ========================================
   MOBILE BREAKPOINT (320px - 479px)
   ======================================== */

@media (max-width: 479px) {
  .phc-grid {
    grid-template-columns: repeat(var(--phc-grid-cols-mobile, 1), 1fr);
    gap: var(--space-md);
  }
}

/* ========================================
   LARGE MOBILE BREAKPOINT (480px - 767px)
   ======================================== */

@media (min-width: 480px) and (max-width: 767px) {
  .phc-grid {
    grid-template-columns: repeat(var(--phc-grid-cols-tablet, 2), 1fr);
    gap: var(--space-lg);
  }
}

/* ========================================
   TABLET BREAKPOINT (768px - 1023px)
   ======================================== */

@media (min-width: 768px) {
  .phc-grid {
    grid-template-columns: repeat(var(--phc-grid-cols-tablet, 2), 1fr);
    gap: var(--component-gap, 24px);
  }
}

/* ========================================
   DESKTOP BREAKPOINT (1024px+)
   ======================================== */

@media (min-width: 1024px) {
  .phc-grid {
    grid-template-columns: repeat(var(--phc-grid-cols, 3), 1fr);
    gap: var(--component-gap, 24px);
  }
}

/* ========================================
   PRESET COLUMN COUNTS
   ======================================== */

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

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

@media (max-width: 767px) {
  .phc-grid-2 {
    grid-template-columns: repeat(1, 1fr);
  }
}

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

@media (max-width: 1023px) {
  .phc-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .phc-grid-3 {
    grid-template-columns: repeat(1, 1fr);
  }
}

.phc-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1023px) {
  .phc-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .phc-grid-4 {
    grid-template-columns: repeat(1, 1fr);
  }
}

.phc-grid-6 {
  grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 1023px) {
  .phc-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 767px) {
  .phc-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   GAP SIZES
   ======================================== */

.phc-grid-gap-xs {
  gap: 8px;
}

.phc-grid-gap-sm {
  gap: 16px;
}

.phc-grid-gap-md {
  gap: 24px;
}

.phc-grid-gap-lg {
  gap: 32px;
}

.phc-grid-gap-xl {
  gap: 48px;
}

.phc-grid-gap-2xl {
  gap: 64px;
}

/* ========================================
   ALIGNMENT OPTIONS
   ======================================== */

.phc-grid-align-stretch {
  align-items: stretch;
}

.phc-grid-align-start {
  align-items: start;
}

.phc-grid-align-center {
  align-items: center;
}

.phc-grid-align-end {
  align-items: end;
}

/* ========================================
   GRID ITEMS
   ======================================== */

.phc-grid-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: var(--phc-grid-height, auto);
}

/* ========================================
   COLUMN SPANNING
   ======================================== */

/* Desktop (1024px+) spanning */
.phc-grid-span-1 {
  grid-column: span 1;
}

.phc-grid-span-2 {
  grid-column: span 2;
}

@media (max-width: 1023px) {
  .phc-grid-span-2 {
    grid-column: span 1;
  }
}

.phc-grid-span-3 {
  grid-column: span 3;
}

@media (max-width: 1023px) {
  .phc-grid-span-3 {
    grid-column: span 1;
  }
}

.phc-grid-span-4 {
  grid-column: span 4;
}

@media (max-width: 1023px) {
  .phc-grid-span-4 {
    grid-column: span 1;
  }
}

/* Tablet (768px-1023px) spanning */
.phc-grid-span-tablet-1 {
  grid-column: span 1;
}

.phc-grid-span-tablet-2 {
  grid-column: span 2;
}

@media (max-width: 767px) {
  .phc-grid-span-tablet-2 {
    grid-column: span 1;
  }
}

/* Mobile (320px-767px) spanning */
.phc-grid-span-mobile-1 {
  grid-column: span 1;
}

.phc-grid-span-mobile-2 {
  grid-column: span 2;
}

@media (max-width: 479px) {
  .phc-grid-span-mobile-2 {
    grid-column: span 1;
  }
}

/* ========================================
   AUTO GRID (Responsive columns)
   ======================================== */

.phc-grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--component-gap);
  grid-auto-flow: dense;
}

/* ========================================
   DENSE PACKING
   ======================================== */

.phc-grid-dense {
  grid-auto-flow: dense;
}

/* ========================================
   NESTED GRIDS
   ======================================== */

.phc-grid .phc-grid {
  margin-bottom: 0;
}

/* ========================================
   LOADING STATE
   ======================================== */

.phc-grid.phc-grid-loading {
  opacity: 0.6;
  pointer-events: none;
}

.phc-grid-item.phc-grid-loading {
  animation: phc-skeleton-loading 1s infinite;
}

@keyframes phc-skeleton-loading {
  0% {
    background-color: #f0f0f0;
  }
  50% {
    background-color: #e0e0e0;
  }
  100% {
    background-color: #f0f0f0;
  }
}

/* ========================================
   EMPTY STATE
   ======================================== */

.phc-grid-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: #999;
  font-style: italic;
  background: rgba(255, 145, 86, 0.05);
  border-radius: 8px;
  border: 2px dashed rgba(255, 145, 86, 0.2);
}

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

/* Hide on mobile */
@media (max-width: 767px) {
  .phc-grid-hide-mobile {
    display: none;
  }
}

/* Show only on mobile */
.phc-grid-show-mobile {
  display: none;
}

@media (max-width: 767px) {
  .phc-grid-show-mobile {
    display: flex;
  }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .phc-grid-hide-tablet {
    display: none;
  }
}

/* Hide on desktop */
@media (min-width: 1024px) {
  .phc-grid-hide-desktop {
    display: none;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.phc-grid-item:focus-within {
  outline: 2px solid #FF9156;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .phc-grid-item {
    animation: none;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .phc-grid {
    page-break-inside: avoid;
  }
  
  .phc-grid-item {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* ========================================
   CONTAINER QUERIES (Future Support)
   ======================================== */

@supports (grid-template-columns: repeat(auto-fit, minmax(250px, 1fr))) {
  .phc-grid-responsive {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

/* ── Full-width grid (full_width="true") ─────────────────────────────────── */
.phc-grid--full-width {
  max-width: none !important;
  width: 100%;
}
