/* ==========================================================================
   RESPONSIVE OPTIMIZATION — Mobile (320px+) & Tablet (768px+)
   ========================================================================== */

/* ===== MOBILE SMALL (320px - 479px) ===== */
@media (max-width: 479px) {
  :root {
    --radius: 12px;
  }

  /* Prevent overflow */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
  }

  /* Film grain — disable on mobile for performance */
  .film-grain {
    display: none !important;
  }

  /* Custom cursor — disable on mobile */
  #pm-cursor, #pm-cursor-aura {
    display: none !important;
  }

  /* Nav */
  .nav-inner {
    height: 56px !important;
    padding: 0 12px !important;
  }
  .nav .brand span:last-child {
    font-size: 13px !important;
  }
  .nav .mark {
    width: 32px !important;
    height: 32px !important;
    font-size: 11px !important;
  }
  .nav-actions .btn-primary {
    display: none !important;
  }
  .nav-actions .soundwave-toggle {
    display: none !important;
  }
  .nav-actions .cc-trigger-btn {
    display: none !important;
  }
  .nav-actions .nav-toggle {
    display: flex !important;
  }
  .nav .links {
    display: none !important;
  }
  .lang-switcher {
    transform: scale(0.85);
    transform-origin: right center;
  }

  /* Mobile menu */
  .mobile-menu {
    top: 56px !important;
    padding: 12px !important;
  }
  .mobile-menu a {
    padding: 12px 14px !important;
    font-size: 15px !important;
  }
  .mobile-menu-divider {
    height: 1px;
    background: var(--line);
    margin: 8px 0;
  }
  .mobile-cmd-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    margin-top: 4px;
    background: rgba(255, 106, 26, 0.08);
    border: 1px solid rgba(255, 106, 26, 0.2);
    border-radius: 12px;
    color: var(--purple);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .mobile-cmd-btn:active {
    background: rgba(255, 106, 26, 0.15);
    transform: scale(0.98);
  }
  .mobile-cmd-btn .cmd-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 106, 26, 0.15);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
  }
  .mobile-cmd-btn .cmd-label {
    flex: 1;
    text-align: left;
  }
  .mobile-cmd-btn .cmd-hint {
    font-size: 10px;
    color: var(--muted);
    font-weight: 400;
  }

  /* Hero */
  .hero-fullscreen {
    min-height: 100svh !important;
    padding: 80px 0 40px !important;
  }
  .hero-fullscreen-wrap {
    padding: 0 16px !important;
  }
  .hero-fullscreen-content h1 {
    font-size: clamp(28px, 8vw, 42px) !important;
    line-height: 1.1 !important;
  }
  .hero-hologram-centerpiece {
    position: relative !important;
    width: 100% !important;
    height: 280px !important;
    margin-bottom: 20px;
  }
  .hero-3d-container {
    height: 280px !important;
  }

  /* Marquee */
  .marquee-section {
    padding: 8px 0 !important;
  }
  .marquee-item {
    font-size: 14px !important;
  }

  /* Stats ribbon */
  .stats-ribbon-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 16px !important;
    padding: 16px 0 !important;
  }
  .stats-ribbon-item strong {
    font-size: 20px !important;
  }
  .stats-ribbon-item small {
    font-size: 10px !important;
  }
  .stats-ribbon-divider {
    display: none !important;
  }

  /* Founder section */
  .founder-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    padding: 0 16px !important;
  }
  .founder-visual {
    text-align: center !important;
  }
  .founder-img {
    max-width: 200px !important;
    margin: 0 auto !important;
  }
  .founder-placeholder-avatar {
    width: 120px !important;
    height: 120px !important;
    font-size: 48px !important;
    margin: 0 auto !important;
  }

  /* Services snap carousel */
  .snap-carousel-container {
    padding: 40px 0 !important;
  }
  .snap-slide {
    min-width: 85vw !important;
    padding: 20px !important;
  }
  .slide-giant-num {
    font-size: 48px !important;
  }
  .slide-title-glitch {
    font-size: 18px !important;
  }
  .slide-desc {
    font-size: 13px !important;
  }
  .carousel-control-dock {
    margin-top: 16px !important;
  }

  /* Bento grid */
  .bento-grid-custom {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .bento-card-custom {
    min-height: 200px !important;
  }
  .bento-card-media {
    min-height: 180px !important;
  }
  .bento-card-title {
    font-size: 16px !important;
  }
  .bento-card-desc {
    font-size: 13px !important;
  }
  .bento-filter-pill-track {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding-bottom: 8px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .bento-filter-pill {
    flex-shrink: 0 !important;
    font-size: 12px !important;
    padding: 8px 14px !important;
  }

  /* Skill constellation */
  .constellation-wrapper {
    max-width: 100% !important;
    padding: 0 8px !important;
  }
  #skill-canvas {
    height: 350px !important;
    width: 100% !important;
  }

  /* Timeline */
  .timeline-step-row {
    padding: 16px 0 !important;
  }
  .timeline-step-col h3 {
    font-size: 16px !important;
  }
  .timeline-accordion-desc {
    font-size: 13px !important;
  }

  /* Testimonials */
  .testimonials-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .testimonial {
    padding: 20px !important;
  }
  .testimonial .quote {
    font-size: 15px !important;
  }

  /* FAQ */
  .faq-item {
    padding: 14px !important;
  }
  .faq-item summary {
    font-size: 14px !important;
  }
  .faq-item p {
    font-size: 13px !important;
  }

  /* Contact */
  .contact-box {
    padding: 20px !important;
    grid-template-columns: 1fr !important;
  }
  .contact-copy h2 {
    font-size: 24px !important;
  }
  .contact-copy p {
    font-size: 14px !important;
  }
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  .contact-form input,
  .contact-form textarea,
  .contact-form select {
    font-size: 14px !important;
    padding: 10px 14px !important;
  }
  .newsletter-bar {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 16px !important;
  }
  .newsletter-bar form {
    flex-direction: column !important;
    width: 100% !important;
  }
  .newsletter-bar input {
    width: 100% !important;
  }

  /* Footer */
  .footer-inner {
    flex-direction: column !important;
    gap: 12px !important;
    text-align: center !important;
  }
  .foot-links {
    flex-wrap: wrap !important;
    justify-content: center !important;
  }

  /* Command Center Modal */
  .cc-modal {
    width: 95% !important;
    max-width: 95% !important;
    padding: 20px !important;
    border-radius: 16px !important;
    max-height: 85vh !important;
  }
  .cc-header {
    margin-bottom: 16px !important;
  }
  .cc-badge {
    font-size: 9px !important;
  }
  .cc-input-wrapper {
    padding: 10px 14px !important;
  }
  #ccInput {
    font-size: 14px !important;
  }
  .cc-commands-list {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    max-height: 200px !important;
  }
  .cc-cmd-item {
    padding: 10px 12px !important;
  }
  .cc-cmd-name {
    font-size: 12px !important;
  }
  .cc-cmd-desc {
    font-size: 10px !important;
  }
  .cc-close {
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
    top: 8px !important;
    right: 8px !important;
  }

  /* Page transition */
  .page-transition-overlay {
    /* Faster transition on mobile */
    transition-duration: 0.3s !important;
  }

  /* Intro overlay */
  .intro-line {
    font-size: 24px !important;
  }
  .intro-name {
    font-size: 32px !important;
  }
}

/* ===== MOBILE MEDIUM (480px - 767px) ===== */
@media (min-width: 480px) and (max-width: 767px) {
  .film-grain {
    opacity: 0.3 !important;
  }

  .nav-inner {
    padding: 0 20px !important;
  }
  .nav-actions .btn-primary {
    display: none !important;
  }
  .nav .links {
    display: none !important;
  }

  .mobile-menu {
    padding: 16px !important;
  }

  .hero-fullscreen {
    min-height: 100svh !important;
    padding: 100px 0 60px !important;
  }
  .hero-fullscreen-content h1 {
    font-size: clamp(32px, 7vw, 52px) !important;
  }
  .hero-hologram-centerpiece {
    height: 350px !important;
  }
  .hero-3d-container {
    height: 350px !important;
  }

  .bento-grid-custom {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  .bento-box-hero {
    grid-column: span 2 !important;
  }

  .snap-slide {
    min-width: 70vw !important;
  }

  .contact-box {
    padding: 24px !important;
  }

  .cc-modal {
    width: 90% !important;
    max-width: 500px !important;
    padding: 24px !important;
  }
  .cc-commands-list {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ===== TABLET (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  .nav .links {
    gap: 12px !important;
  }
  .nav .links a {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }
  .nav-actions .btn-primary {
    padding: 8px 14px !important;
    font-size: 12px !important;
  }
  .nav-actions .cc-trigger-btn {
    display: none !important;
  }

  .hero-fullscreen-content h1 {
    font-size: clamp(36px, 6vw, 56px) !important;
  }
  .hero-hologram-centerpiece {
    height: 400px !important;
  }
  .hero-3d-container {
    height: 400px !important;
  }

  .bento-grid-custom {
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }
  .bento-box-hero {
    grid-column: span 2 !important;
  }

  .founder-grid {
    gap: 32px !important;
  }

  .snap-slide {
    min-width: 45vw !important;
  }

  .cc-modal {
    width: 85% !important;
    max-width: 600px !important;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Hardware acceleration for animated elements */
.film-grain,
#pm-cursor,
#pm-cursor-aura,
.page-transition-overlay,
#intro-overlay,
.cc-modal,
.bento-card-custom,
.magnetic-card,
.snap-slide,
.hero-hologram-centerpiece {
  will-change: transform, opacity;
}



/* Lazy loading image placeholder */
img[loading="lazy"] {
  background: linear-gradient(135deg, #111 25%, #1a1a1a 50%, #111 75%);
  background-size: 200% 200%;
  animation: img-shimmer 1.5s ease-in-out infinite;
}
@keyframes img-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
img[loading="lazy"].loaded {
  animation: none;
  background: none;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Disable hover effects on touch devices */
  .bento-card-custom:hover,
  .magnetic-card:hover,
  .card:hover {
    transform: none !important;
  }
  /* Make tap targets bigger */
  .cc-cmd-item,
  .dock-arrow-btn,
  .carousel-dot-indicator {
    min-height: 44px;
    min-width: 44px;
  }
  /* Disable custom cursor on touch */
  #pm-cursor,
  #pm-cursor-aura {
    display: none !important;
  }
  /* Disable film grain on low-end devices */
  .film-grain {
    display: none !important;
  }
}

/* Fix for iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
  .hero-fullscreen {
    min-height: -webkit-fill-available !important;
  }
  #intro-overlay {
    height: -webkit-fill-available !important;
  }
}

/* Container width fixes for small screens */
@media (max-width: 479px) {
  .wrap {
    width: calc(100% - 24px) !important;
    padding: 0 12px !important;
  }
  .section {
    padding: 40px 0 !important;
  }
  .section-head {
    margin-bottom: 24px !important;
  }
  .section-head h2 {
    font-size: 24px !important;
  }
  .section-head p {
    font-size: 13px !important;
  }
  .eyebrow {
    font-size: 10px !important;
  }
  h1 {
    font-size: 28px !important;
  }
  h2 {
    font-size: 22px !important;
  }
  h3 {
    font-size: 18px !important;
  }
  p, li {
    font-size: 14px !important;
  }
}

/* Ensure text doesn't overflow on small screens */
@media (max-width: 479px) {
  h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  .bento-card-title,
  .slide-title-glitch,
  .testimonial .quote {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}
