/* ═══════════════════════════════════════════════════════════════
   MAX DIMENSIONES TEXAS — mobile.css  v3.0
   Fullscreen-safe · Edge/notch-aware · Retina-ready · Touch-optimized
   Breakpoints: 1100 / 768 / 480 / 360
═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────
   SAFE AREA / NOTCH / DYNAMIC ISLAND
   env() with fallback for all browsers
───────────────────────────────────────── */
:root {
  --sat: env(safe-area-inset-top,    0px);
  --sar: env(safe-area-inset-right,  0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left,   0px);
}

/* Fullscreen HTML — critical for iPhone notch */
html {
  -webkit-text-size-adjust: 100%;   /* prevent iOS font bump on rotate */
  text-size-adjust: 100%;
}

/* Floating buttons — always above home bar */
.whatsapp-float,
#backToTop {
  bottom: calc(1.75rem + var(--sab));
  right:  calc(1.75rem + var(--sar));
}
.whatsapp-float {
  bottom: calc(5.5rem + var(--sab));
}

/* Nav — keep below status bar */
#navbar {
  padding-top: calc(1.4rem + var(--sat));
}
#navbar.scrolled {
  padding-top: calc(0.7rem + var(--sat));
}

/* Mobile nav slide-out — full safe area */
.mobile-nav {
  padding-top:    calc(5.5rem + var(--sat));
  padding-bottom: calc(2rem  + var(--sab));
}

/* ─────────────────────────────────────────
   RETINA — crisp images & borders
───────────────────────────────────────── */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* 0.5px borders render as 1 physical pixel on Retina */
  .service-card    { border-bottom-width: 0.5px; }
  .portfolio-item  { outline: 0.5px solid transparent; } /* subpixel gap fix */
  .hero-thumb      { border-width: 1px; }                /* stays crisp at 2x */
  .map-wrap iframe { filter: grayscale(1) brightness(0.78) contrast(1.12); }

  /* Prevent blurry SVG icons — force GPU layer */
  .service-icon svg,
  .hiw-icon svg,
  .social-btn svg,
  .whatsapp-float svg { will-change: transform; }
}

/* ─────────────────────────────────────────
   TABLET — ≤ 1100px
───────────────────────────────────────── */
@media (max-width: 1100px) {

  /* Nav */
  .nav-links  { gap: 1.4rem; }
  .btn-quote  { padding: .5rem 1.1rem; font-size: .78rem; }

  /* Hero thumb strip */
  .hero-thumb-strip { right: 1.25rem; bottom: 130px; }
  .hero-thumb       { width: 58px; height: 44px; }

  /* Stats */
  .stats-grid   { gap: .6rem; justify-content: center; }
  .stat-divider { display: none; }

  /* Services */
  .services-grid          { grid-template-columns: repeat(2, 1fr); }
  .service-card[style*="grid-column"] { grid-column: span 1 !important; }

  /* Portfolio */
  .portfolio-grid                        { grid-template-columns: repeat(2, 1fr); }
  .portfolio-item.featured               { grid-column: span 2; aspect-ratio: 16/9; }

  /* About — stack + center */
  .about-grid         { grid-template-columns: 1fr; gap: 3rem; }
  .about-img-wrap     { max-width: 560px; width: 100%; margin: 0 auto; }
  .about-img-main     { width: 100%; }
  .about-img-accent   { display: none; }
  .about-content      { text-align: center; }
  .about-list         { align-items: center; }
  .about-list li      { justify-content: center; }
  .about-flags        { justify-content: center; }
  .about-content .section-sub { margin-left: auto; margin-right: auto; }

  /* How It Works */
  .hiw-steps   { flex-wrap: wrap; }
  .hiw-step    { flex: 1 1 calc(50% - 1.5rem); min-width: 200px; }
  .hiw-connector { display: none; }

  /* Contact */
  .contact-grid { grid-template-columns: 1fr; gap: 3rem; }
  .contact-detail { justify-content: flex-start; }
  .map-wrap   { max-width: 560px; margin: 2rem auto 0; }
}

/* ─────────────────────────────────────────
   MOBILE — ≤ 768px
───────────────────────────────────────── */
@media (max-width: 768px) {

  /* ── Global ── */
  .container { padding: 0 1.25rem; }

  /* ── Nav ── */
  .nav-links    { display: none; }
  .nav-hamburger { display: flex; }
  .btn-quote    { display: none; }
  .nav-logo img { height: 36px; }

  /* Hamburger — bigger tap target */
  .nav-hamburger { padding: 10px; margin: -10px; }

  /* ── Hero — 100svh with safe-area ── */
  #hero {
    /* svh = small viewport height: excludes browser chrome on scroll */
    min-height: 100svh;
    /* fallback for browsers without svh */
    min-height: -webkit-fill-available;
    padding: calc(90px + var(--sat)) 0 calc(60px + var(--sab));
    text-align: center;
  }
  .hero-bg::after {
    background: linear-gradient(
      to bottom,
      rgba(8,8,8,0.93) 0%,
      rgba(8,8,8,0.80) 50%,
      rgba(8,8,8,0.88) 100%
    );
  }
  .hero-content   { max-width: 100%; }
  .hero-eyebrow   { justify-content: center; }
  .hero-title     { font-size: clamp(3rem, 12vw, 6rem); }
  .hero-desc      { font-size: .95rem; margin-left: auto; margin-right: auto; }
  .hero-actions   { flex-direction: column; align-items: center; gap: .85rem; }
  .btn-primary,
  .btn-outline    { width: 100%; max-width: 320px; justify-content: center; }
  .hero-thumb-strip { display: none; }
  .hero-scroll-hint { display: none; }
  .hero-diagonal  { height: 70px; }

  /* ── Stats ── */
  #stats { padding: 1rem 0; }
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    text-align: center;
  }
  .stat-item    { padding: .75rem .5rem; }
  .stat-num     { font-size: 2rem; }
  .stat-divider { display: none; }

  /* ── Services ── */
  #services { padding: 5rem 0; }
  .services-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .services-header .section-sub { margin-left: auto; margin-right: auto; }
  .services-grid  { grid-template-columns: 1fr; gap: 2px; }
  .service-card[style*="grid-column"] { grid-column: span 1 !important; }
  .service-card   { padding: 1.75rem; }

  /* ── How It Works ── */
  .hiw-section { padding: 4.5rem 0; }
  .hiw-header  { text-align: center; }
  .hiw-steps   { flex-direction: column; gap: 1rem; align-items: center; }
  .hiw-step    { width: 100%; max-width: 420px; text-align: center; }
  .hiw-connector { display: none; }

  /* ── Portfolio ── */
  #portfolio { padding: 5rem 0; }
  .portfolio-header { text-align: center; }
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .portfolio-item.featured {
    grid-column: span 1;
    aspect-ratio: 4/3;
  }
  .portfolio-item { aspect-ratio: 4/3; }
  /* Touch: always show overlay (no hover state on mobile) */
  .portfolio-overlay {
    opacity: 1;
    background: linear-gradient(
      to top,
      rgba(8,8,8,0.92) 0%,
      rgba(8,8,8,0.12) 60%,
      transparent 100%
    );
  }
  .portfolio-item img { filter: saturate(.85) brightness(.9); }

  /* ── Filter buttons — bigger tap targets ── */
  .filter-btn { padding: .65rem 1.3rem; min-height: 44px; }
  .portfolio-filter { gap: .5rem; }

  /* ── Testimonials ── */
  #testimonials { padding: 5rem 0; }
  .testimonials-header { text-align: center; }
  .testi-card    { padding: 0 .75rem; }
  .testi-text    { font-size: clamp(1.2rem, 5vw, 1.75rem); }
  .testi-controls {
    padding-left: 0;
    justify-content: center;
  }
  /* Bigger swipe / tap targets on slider buttons */
  .testi-btn { width: 52px; height: 52px; min-height: 44px; }

  /* ── About ── */
  #about { padding: 5rem 0; }
  .about-grid       { grid-template-columns: 1fr; gap: 2.5rem; }
  .about-img-wrap   { width: 100%; max-width: 480px; margin: 0 auto; display: block; }
  .about-img-main   { width: 100%; display: block; margin: 0 auto; }
  .about-badge {
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
  }
  .about-content    { text-align: center; }
  .about-list       { align-items: center; }
  .about-list li    { justify-content: center; }
  .about-flags      { justify-content: center; }

  /* ── CTA ── */
  #cta       { padding: 4.5rem 0; }
  .cta-title { font-size: clamp(2rem, 9vw, 3.5rem); }

  /* ── Contact ── */
  #contact { padding: 5rem 0; }
  .contact-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .contact-detail { flex-direction: row; align-items: flex-start; }
  .map-wrap { margin: 1.5rem auto 0; max-width: 100%; }
  .map-wrap iframe { height: 200px; }
  .form-row    { grid-template-columns: 1fr; }
  .form-title  { text-align: center; }

  /* ── Footer ── */
  #footer { padding: 2.5rem 0 calc(1.5rem + var(--sab)); }
  .footer-top {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }
  .footer-logo      { margin: 0 auto; }
  .footer-logo img  { height: 34px; }
  .footer-links,
  .footer-nav       { justify-content: center; flex-wrap: wrap; gap: 1rem; }
  .footer-social    { justify-content: center; }
  .footer-bottom {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .5rem;
  }

  /* ── Floating buttons — safe-area-aware ── */
  .whatsapp-float {
    bottom: calc(4.5rem + var(--sab));
    right:  calc(1.1rem + var(--sar));
    width: 50px; height: 50px;
  }
  .wa-tooltip { display: none; }   /* no hover on touch */

  #backToTop {
    bottom: calc(1.1rem + var(--sab));
    right:  calc(1.1rem + var(--sar));
    width: 42px; height: 42px;
    min-width: 44px; min-height: 44px; /* WCAG tap target */
  }
}

/* ─────────────────────────────────────────
   SMALL MOBILE — ≤ 480px
───────────────────────────────────────── */
@media (max-width: 480px) {

  .container { padding: 0 1rem; }

  /* Typography */
  .section-title { font-size: clamp(2rem, 8vw, 3rem); }
  .hero-title    { font-size: clamp(2.6rem, 11vw, 4.5rem); }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-num   { font-size: 1.85rem; }

  /* Services */
  .services-grid { grid-template-columns: 1fr; }

  /* Portfolio */
  .portfolio-item { aspect-ratio: 3/2; }

  /* Testimonials */
  .testi-text   { font-size: 1.15rem; }
  .testi-author { flex-direction: column; align-items: flex-start; gap: .5rem; }

  /* CTA */
  .btn-dark { width: 100%; justify-content: center; }

  /* !! CRITICAL — prevent iOS auto-zoom on focus !! */
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    border-radius: 0;           /* iOS adds unwanted rounding */
  }
  /* Fix select arrow on iOS */
  .form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
  }

  /* Footer */
  .footer-copy   { font-size: .72rem; }
  .footer-credit { font-size: .72rem; }
}

/* ─────────────────────────────────────────
   EXTRA SMALL — ≤ 360px
───────────────────────────────────────── */
@media (max-width: 360px) {
  .container  { padding: 0 .875rem; }
  .hero-title { font-size: 2.4rem; }
  .btn-primary,
  .btn-outline { font-size: .82rem; padding: .75rem 1.1rem; }
  .stat-num   { font-size: 1.65rem; }
  .nav-logo img { height: 30px; }
  .whatsapp-float { width: 46px; height: 46px; }
  #backToTop      { width: 40px; height: 40px; }
}

/* ─────────────────────────────────────────
   TOUCH DEVICES (hover: none)
   Better tap targets, remove hover artefacts
───────────────────────────────────────── */
@media (hover: none) {
  /* Portfolio overlay always visible on touch */
  .portfolio-overlay { opacity: 1; }
  .portfolio-item img { filter: saturate(.82) brightness(.88); }

  /* Minimum 44×44 tap targets (Apple HIG / WCAG 2.5.5) */
  .filter-btn     { padding: .65rem 1.4rem; min-height: 44px; }
  .testi-btn      { width: 52px; height: 52px; }
  .nav-hamburger  { padding: 10px; }
  .lang-toggle span { padding: .4rem .5rem; }
  .social-btn,
  .social-icon    { width: 44px; height: 44px; }
  .mobile-nav a   { padding: 1rem 0; }
  .btn-submit     { min-height: 52px; }

  /* Remove hover-only transforms that misfire on tap */
  .service-card:hover  { transform: none; }
  .hiw-step:hover      { transform: none; }
  .btn-primary:hover,
  .btn-outline:hover,
  .btn-dark:hover      { transform: none; box-shadow: none; }
  .portfolio-item:hover img { transform: none; filter: saturate(.82) brightness(.88); }
  .footer-nav a:hover  { padding-left: 0; }
}

/* ─────────────────────────────────────────
   LANDSCAPE PHONE — short + wide
───────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  #hero {
    min-height: auto;
    padding: calc(70px + var(--sat)) 0 2rem;
  }
  .hero-title { font-size: clamp(2rem, 7vw, 3.5rem); }
  .hero-desc  { display: none; }        /* too cramped in landscape */
  #loader .loader-bg-lines { display: none; }
  .loader-status { display: none; }
}

/* ─────────────────────────────────────────
   REDUCED MOTION — respect OS setting
───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .hero-bg-slide { transition: none; }
  #loader .loader-fill { transition: none; }
}

/* ─────────────────────────────────────────
   HIGH CONTRAST MODE (Windows)
───────────────────────────────────────── */
@media (forced-colors: active) {
  .btn-primary,
  .btn-quote,
  .btn-submit  { forced-color-adjust: none; }
  .service-card { border: 1px solid ButtonText; }
}

/* ─────────────────────────────────────────
   SERVICE PHOTO-CARDS
   Works on both desktop and mobile.
   CSS variable --svc-bg set inline on each card.
───────────────────────────────────────── */
.service-card.service-photo {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  background-image: var(--svc-bg);
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 0 1.25rem 0;
  border: none;
}

/* Dark gradient overlay so text is always legible */
.service-card.service-photo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.08) 0%,
    rgba(0,0,0,0.55) 55%,
    rgba(0,0,0,0.82) 100%
  );
  z-index: 1;
}

.service-card.service-photo .service-num,
.service-card.service-photo .service-name,
.service-card.service-photo .service-desc {
  position: relative;
  z-index: 2;
  color: #fff;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.service-card.service-photo .service-num {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--accent, #f60);
  margin-bottom: 0.35rem;
  padding-top: 0;
}

.service-card.service-photo .service-name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.4rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.service-card.service-photo .service-desc {
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.88);
  margin: 0;
}

/* Mobile: 2-column grid, taller cards */
@media (max-width: 768px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .service-card.service-photo {
    min-height: 190px;
    border-radius: 10px;
  }
  .service-card.service-photo .service-name {
    font-size: 0.9rem;
  }
  .service-card.service-photo .service-desc {
    font-size: 0.76rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Extra-small phones: single column, bigger height */
@media (max-width: 390px) {
  .services-grid {
    grid-template-columns: 1fr !important;
  }
  .service-card.service-photo {
    min-height: 200px;
  }
  .service-card.service-photo .service-desc {
    -webkit-line-clamp: 3;
  }
}

/* Portfolio grid: keep 2 columns on mobile */
@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .portfolio-item {
    aspect-ratio: 4/3 !important;
    border-radius: 8px;
    overflow: hidden;
  }
  .portfolio-item.featured {
    grid-column: span 2 !important;
    aspect-ratio: 16/9 !important;
  }
  .portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .portfolio-overlay {
    opacity: 1 !important;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 60%) !important;
  }
  .portfolio-info {
    padding: 0.5rem 0.6rem;
  }
  .portfolio-cat {
    font-size: 0.65rem;
  }
  .portfolio-title {
    font-size: 0.82rem;
    font-weight: 700;
  }
  .portfolio-desc {
    display: none;
  }
}
