/*
 * Responsive Design System - Mobile-First Framework
 * Provides fluid typography, touch-friendly controls, and responsive grids
 * Import after customer.css to extend base styles
 */

/* ============================================================
 * MOBILE BREAKPOINTS
 * ============================================================ */

/* Mobile: 320px-375px */
/* Tablet: 376px-767px */
/* Desktop: 768px-1023px */
/* Large Desktop: 1024px+ */

/* ============================================================
 * FLUID TYPOGRAPHY CLASSES
 * ============================================================ */

.fluid-text-xs {
  font-size: clamp(0.75rem, 1.5vw, 0.875rem);
}

.fluid-text-sm {
  font-size: clamp(0.875rem, 1.75vw, 1rem);
}

.fluid-text-base {
  font-size: clamp(1rem, 2vw, 1.125rem);
}

.fluid-text-lg {
  font-size: clamp(1.125rem, 2.5vw, 1.25rem);
}

.fluid-text-xl {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.fluid-text-2xl {
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.fluid-text-3xl {
  font-size: clamp(1.875rem, 5vw, 2.25rem);
}

/* ============================================================
 * TOUCH-FRIENDLY CONTROLS
 * ============================================================ */

/* Ensure minimum touch target size (44px × 44px per WCAG 2.1) */
.touch-button,
.touch-input {
  min-width: 44px;
  min-height: 44px;
  padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.75rem, 2.5vw, 1rem);
  touch-action: manipulation;
}

button.touch-button,
a.touch-button,
input[type="button"].touch-button,
input[type="submit"].touch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

input.touch-input[type="text"],
input.touch-input[type="email"],
input.touch-input[type="password"],
input.touch-input[type="tel"],
input.touch-input[type="number"] {
  font-size: 16px; /* Prevents zoom on iOS */
}

/* ============================================================
 * RESPONSIVE GRID SYSTEM
 * ============================================================ */

/* Mobile-first grid (1 column) */
.grid-auto {
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
  grid-template-columns: 1fr;
}

/* 2-column grid on tablets */
@media (min-width: 376px) {
  .grid-2-tablet {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 3-column grid on desktop */
@media (min-width: 768px) {
  .grid-3-desktop {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 4-column grid on large desktop */
@media (min-width: 1024px) {
  .grid-4-large {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Auto-fit responsive grid (product cards, etc.) */
.grid-cards {
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

@media (min-width: 376px) {
  .grid-cards {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (min-width: 768px) {
  .grid-cards {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-cards {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* ============================================================
 * RESPONSIVE LAYOUTS
 * ============================================================ */

/* Flex: Stack on mobile, row on desktop */
.flex-stack {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3vw, 1.5rem);
}

@media (min-width: 768px) {
  .flex-stack-desktop {
    flex-direction: row;
  }
}

/* Sidebar layout: Full-width on mobile, sidebar on desktop */
.sidebar-layout {
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .sidebar-layout-desktop {
    grid-template-columns: 1fr 300px;
  }

  .sidebar-layout-desktop-left {
    grid-template-columns: 300px 1fr;
  }
}

/* ============================================================
 * RESPONSIVE CONTAINERS
 * ============================================================ */

/* Full-width mobile, constrained desktop */
.container-responsive {
  width: 100%;
  padding-left: clamp(1rem, 5vw, 2rem);
  padding-right: clamp(1rem, 5vw, 2rem);
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 768px) {
  .container-responsive {
    max-width: 90%;
  }
}

@media (min-width: 1024px) {
  .container-responsive {
    max-width: 1200px;
  }
}

/* ============================================================
 * STICKY ELEMENTS (Mobile-specific)
 * ============================================================ */

/* Sticky footer for CTAs, cart summary, etc. */
.sticky-footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  padding: clamp(1rem, 3vw, 1.5rem);
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

/* Not sticky on desktop */
@media (min-width: 768px) {
  .sticky-footer-desktop-static {
    position: static;
    border-top: none;
    box-shadow: none;
  }
}

/* Sticky header */
.sticky-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  z-index: 99;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
 * CARDS AND SECTIONS
 * ============================================================ */

/* Card: Mobile padding optimization */
.card-responsive {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: clamp(1rem, 3vw, 1.5rem);
  margin-bottom: clamp(1rem, 3vw, 1.5rem);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Section with fluid spacing */
.section-responsive {
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 5vw, 2rem);
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

/* ============================================================
 * ACCORDION/DISCLOSURE (Mobile-friendly)
 * ============================================================ */

.accordion {
  margin-bottom: clamp(0.5rem, 2vw, 1rem);
}

.accordion > summary {
  cursor: pointer;
  padding: clamp(1rem, 2vw, 1.25rem);
  background: var(--bg-tertiary);
  border-radius: 4px;
  user-select: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  transition: background 200ms ease-out;
}

.accordion > summary:hover {
  background: var(--bg-secondary);
}

.accordion > summary::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  margin-right: clamp(0.5rem, 2vw, 1rem);
  background: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22currentColor%22 stroke-width=%222%22%3e%3cpolyline points=%226 9 12 15 18 9%22%3e%3c/polyline%3e%3c/svg%3e') no-repeat center;
  background-size: contain;
  transition: transform 200ms ease-out;
}

.accordion[open] > summary::before {
  transform: rotate(180deg);
}

.accordion > summary::marker {
  display: none;
}

.accordion > div {
  padding: clamp(1rem, 2vw, 1.25rem);
  border-left: 2px solid var(--accent-pink);
  padding-left: clamp(1rem, 3vw, 1.5rem);
}

/* ============================================================
 * RESPONSIVE IMAGES
 * ============================================================ */

img.responsive {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Aspect ratio helpers */
.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-video {
  aspect-ratio: 16 / 9;
}

.aspect-4-3 {
  aspect-ratio: 4 / 3;
}

.aspect-3-2 {
  aspect-ratio: 3 / 2;
}

/* ============================================================
 * RESPONSIVE FORMS
 * ============================================================ */

.form-group-responsive {
  margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.form-label-responsive {
  display: block;
  margin-bottom: clamp(0.5rem, 1.5vw, 0.75rem);
  font-weight: 500;
}

.form-input-responsive {
  width: 100%;
  padding: clamp(0.75rem, 2vw, 1rem);
  font-size: 16px; /* Prevents zoom on iOS */
  border: 1px solid var(--border);
  border-radius: 4px;
}

.form-input-responsive:focus {
  outline: none;
  border-color: var(--accent-pink);
  box-shadow: 0 0 0 2px rgba(var(--accent-pink), 0.1);
}

/* Checkbox/Radio: Touch-friendly */
.checkbox-responsive,
.radio-responsive {
  margin: clamp(0.5rem, 2vw, 0.75rem);
  cursor: pointer;
}

.checkbox-responsive input[type="checkbox"],
.radio-responsive input[type="radio"] {
  min-width: 24px;
  min-height: 24px;
  cursor: pointer;
  margin-right: clamp(0.5rem, 1.5vw, 0.75rem);
}

/* ============================================================
 * RESPONSIVE TEXT
 * ============================================================ */

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
 * UTILITY CLASSES
 * ============================================================ */

/* Display */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

@media (max-width: 375px) {
  .hidden-mobile {
    display: none !important;
  }

  .visible-mobile {
    display: block !important;
  }
}

@media (min-width: 376px) and (max-width: 767px) {
  .hidden-tablet {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .hidden-desktop {
    display: none !important;
  }

  .visible-desktop {
    display: block !important;
  }
}

/* Margin utilities (fluid) */
.m-1 { margin: clamp(0.5rem, 2vw, 0.75rem); }
.m-2 { margin: clamp(1rem, 3vw, 1.5rem); }
.m-3 { margin: clamp(1.5rem, 4vw, 2rem); }

.mt-1 { margin-top: clamp(0.5rem, 2vw, 0.75rem); }
.mt-2 { margin-top: clamp(1rem, 3vw, 1.5rem); }
.mt-3 { margin-top: clamp(1.5rem, 4vw, 2rem); }

.mb-1 { margin-bottom: clamp(0.5rem, 2vw, 0.75rem); }
.mb-2 { margin-bottom: clamp(1rem, 3vw, 1.5rem); }
.mb-3 { margin-bottom: clamp(1.5rem, 4vw, 2rem); }

/* Padding utilities (fluid) */
.p-1 { padding: clamp(0.5rem, 2vw, 0.75rem); }
.p-2 { padding: clamp(1rem, 3vw, 1.5rem); }
.p-3 { padding: clamp(1.5rem, 4vw, 2rem); }

/* Width utilities */
.w-full {
  width: 100%;
}

.w-half {
  width: 50%;
}

/* ============================================================
 * ACCESSIBILITY
 * ============================================================ */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: more) {
  button,
  a.touch-button,
  input[type="button"],
  input[type="submit"] {
    border: 2px solid currentColor;
  }

  .form-input-responsive {
    border: 2px solid var(--border);
  }

  .accordion > summary {
    border: 2px solid var(--border);
  }
}

/* ============================================================
 * DARK MODE
 * ============================================================ */

/* Already supported via CSS variables in customer.css */
@media (prefers-color-scheme: dark) {
  /* No additional changes needed */
}

/* ============================================================
 * LANDSCAPE ORIENTATION
 * ============================================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .hide-landscape {
    display: none !important;
  }

  .section-responsive {
    padding: clamp(1rem, 2vw, 1.5rem);
    margin-bottom: clamp(1rem, 2vw, 1.5rem);
  }
}
