/**
 * mobile.css
 * Mobile-only visual & layout overrides (max-width: 480px)
 * Loaded ONLY when viewport matches, keeping desktop unchanged.
 * 
 * IMPORTANT: Designed for native-like UX on phones.
 * Desktop CSS is NOT modified - these are additive overrides.
 */

@media screen and (max-width: 480px) {
  /* === ROOT VARIABLES FOR MOBILE === */
  :root {
    --mobile-base-font-size: 15px;
    --mobile-container-max-width: 100%;
    --mobile-touch-target: 56px;
    --mobile-spacing-unit: 12px;
    --mobile-max-hero-height: 46vh;
    --mobile-nav-height: 60px;
  }

  html {
    font-size: var(--mobile-base-font-size);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  body {
    overscroll-behavior-y: contain;
  }

  /* === LAYOUT: Full-width mobile === */
  .container,
  .site-wrapper,
  main,
  section {
    padding-left: var(--mobile-spacing-unit);
    padding-right: var(--mobile-spacing-unit);
    max-width: var(--mobile-container-max-width);
    margin: 0;
  }

  /* === HEADER: Mobile-optimized === */
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--mobile-spacing-unit);
    height: var(--mobile-nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    background: hsl(var(--background) / 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* Hide desktop nav on mobile */
  header nav:not(.mobile-nav),
  header .nav:not(.mobile-nav),
  .desktop-nav,
  .tablet-nav {
    display: none !important;
  }

  /* Show mobile nav toggle */
  .mobile-nav-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
  }

  /* === HERO: Optimized for mobile === */
  .hero,
  [class*="hero"] {
    min-height: var(--mobile-max-hero-height);
    max-height: 56vh;
    background-size: cover;
    background-position: center;
    background-attachment: scroll !important;
  }

  /* === TOUCH TARGETS: iOS/Android guidelines === */
  a,
  button,
  .btn,
  [role="button"],
  input[type="submit"],
  input[type="button"] {
    min-height: var(--mobile-touch-target);
    padding: 14px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* === GRID: Single column on mobile === */
  .grid-2col,
  .grid-3col,
  [class*="grid-cols-2"],
  [class*="grid-cols-3"],
  [class*="md:grid-cols"],
  [class*="lg:grid-cols"] {
    grid-template-columns: 1fr !important;
    gap: var(--mobile-spacing-unit);
  }

  /* === TYPOGRAPHY: Compact mobile sizing === */
  h1, .h1 {
    font-size: 1.5rem;
    line-height: 1.12;
    letter-spacing: -0.02em;
  }

  h2, .h2 {
    font-size: 1.15rem;
    line-height: 1.2;
  }

  h3, .h3 {
    font-size: 1rem;
  }

  p, .text-base {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  /* === CARDS: Flat design for mobile === */
  .card,
  [class*="card"] {
    box-shadow: none;
    border: 1px solid hsl(var(--border) / 0.5);
    border-radius: 12px;
  }

  /* === FORMS: Mobile-optimized inputs === */
  input,
  textarea,
  select {
    width: 100%;
    font-size: 16px; /* Prevents iOS zoom */
    padding: 14px;
    border-radius: 10px;
    min-height: var(--mobile-touch-target);
    -webkit-appearance: none;
    appearance: none;
  }

  input:focus,
  textarea:focus,
  select:focus {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.2);
  }

  /* === IMAGES: LQIP blur-up effect === */
  .lqip,
  img[data-lqip] {
    filter: blur(8px);
    transform: scale(1.02);
    transition: filter 350ms ease-out, transform 350ms ease-out;
  }

  .lqip.loaded,
  img[data-lqip].loaded {
    filter: none;
    transform: none;
  }

  /* === PERFORMANCE: Minimal animations === */
  *,
  *::before,
  *::after {
    animation-duration: 150ms !important;
    transition-duration: 150ms !important;
  }

  /* Respect prefers-reduced-motion */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation: none !important;
      transition: none !important;
    }
  }

  /* === MOBILE NAV DRAWER === */
  .mobile-nav-drawer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: hsl(var(--background) / 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    padding: var(--mobile-spacing-unit);
    padding-top: calc(var(--mobile-nav-height) + var(--mobile-spacing-unit));
  }

  .mobile-nav-drawer.closed {
    display: none;
  }

  .mobile-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-nav a {
    display: block;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 12px;
    background: hsl(var(--muted) / 0.5);
  }

  .mobile-nav a:active {
    background: hsl(var(--muted));
  }

  /* === PORTFOLIO SPECIFIC === */
  .portfolio-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  /* Video controls: larger on mobile */
  .video-controls {
    padding: 12px;
    gap: 16px;
  }

  .video-controls button {
    min-width: 48px;
    min-height: 48px;
    font-size: 1.2rem;
  }

  /* Campaign modal: full screen on mobile */
  .campaign-modal,
  [role="dialog"] {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  /* === ACCESSIBILITY === */
  :focus {
    outline: 3px solid hsl(var(--primary) / 0.7);
    outline-offset: 2px;
  }

  :focus:not(:focus-visible) {
    outline: none;
  }

  /* === SAFE AREAS (notch support) === */
  @supports (padding: env(safe-area-inset-bottom)) {
    .mobile-nav-drawer {
      padding-bottom: calc(var(--mobile-spacing-unit) + env(safe-area-inset-bottom));
    }

    footer,
    .bottom-nav {
      padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }

  /* === REDUCED MOTION CLASS (set by JS) === */
  .reduced-motion-mobile *,
  .reduced-motion-mobile *::before,
  .reduced-motion-mobile *::after {
    animation: none !important;
    transition-duration: 50ms !important;
  }

  /* === DISABLE HEAVY EFFECTS === */
  .reduced-motion-mobile .shader-animation,
  .reduced-motion-mobile .spiral-animation,
  .reduced-motion-mobile .vaporize-image,
  .reduced-motion-mobile canvas {
    display: none !important;
  }

  .reduced-motion-mobile .hero-fallback {
    display: block !important;
  }
}
