/* ============================================================================
   QA10 — mobile.css
   State-of-the-art mobile enhancement layer.
   Loaded AFTER styles.css so plain-specificity rules win by source order.
   Section order (top → bottom = cascade increasing):
     1. TOKENS
     2. RESET / GLOBAL
     3. TOUCH TARGETS
     4. HERO LOGO (fluid clamp)
     5. SAFE AREA (landscape L/R)
     6. STICKY CTA (keyboard-open + safe-area enhancements)
     7. SKELETON LOADERS
     8. BREAKPOINT BLOCKS (iPhone SE)
     9. USER PREFERENCES (contrast, reduced-data, reduced-motion)
    10. FOLDABLES (horizontal-viewport-segments)
    11. CONTAINER QUERIES
    12. VIEW TRANSITIONS
   ============================================================================ */


/* ============================================================================
   1. TOKENS
   ============================================================================ */
:root {
  --mobile-cta-height: 68px;
  --mobile-tap-min: 44px;
  --mobile-tap-scale-active: 0.97;
}


/* ============================================================================
   2. RESET / GLOBAL
   ============================================================================ */
:root {
  accent-color: var(--teal-light);
}

body {
  overscroll-behavior-y: none;
}


/* ============================================================================
   3. TOUCH TARGETS
   — scoped to NOT collide with html.menu-open { touch-action: none } at styles.css:979
   ============================================================================ */
button,
a,
[role="button"],
input[type="submit"],
input[type="button"] {
  touch-action: manipulation;
}

/* Hamburger 44×44 — matches specificity of styles.css:1365, wins by source order */
.hamburger {
  min-width: var(--mobile-tap-min);
  min-height: var(--mobile-tap-min);
}

/* Active tap states — coarse pointers only to avoid mouse click flashes on desktop */
@media (pointer: coarse) {
  button:active,
  a:active,
  .case-card:active,
  .nav-cta:active,
  .btn:active {
    transform: scale(var(--mobile-tap-scale-active));
    transition: transform 100ms ease-out;
  }

  /* Respect reduced motion — disable the scale feedback entirely */
  @media (prefers-reduced-motion: reduce) {
    button:active,
    a:active,
    .case-card:active,
    .nav-cta:active,
    .btn:active {
      transform: none;
      transition: none;
    }
  }
}


/* ============================================================================
   4. HERO LOGO — fluid clamp replacing 7 fixed-width cascading rules
   Wraps each override in matching @media breakpoints to guarantee
   cascade dominance over styles.css:1571, 3962, 8011, 8719, 8774, 8947.
   ============================================================================ */
.hero-logo-container {
  width: clamp(110px, 40vw, 380px);
  height: clamp(110px, 40vw, 380px);
  aspect-ratio: 1;
}

.hero-logo-container img {
  width: 90%;
  height: auto;
  max-width: 100%;
}

@media (max-width: 1024px) {
  .hero-logo-container {
    width: clamp(110px, 38vw, 280px);
    height: clamp(110px, 38vw, 280px);
  }
  .hero-logo-container img {
    width: 88%;
  }
}

@media (max-width: 768px) {
  .hero-logo-container {
    width: clamp(110px, 36vw, 220px);
    height: clamp(110px, 36vw, 220px);
  }
  .hero-logo-container img {
    width: 86%;
  }
}

@media (max-width: 600px) {
  .hero-logo-container {
    width: clamp(110px, 34vw, 200px);
    height: clamp(110px, 34vw, 200px);
  }
}

@media (max-width: 480px) {
  .hero-logo-container {
    width: clamp(110px, 34vw, 180px);
    height: clamp(110px, 34vw, 180px);
  }
  .hero-logo-container img {
    width: 84%;
  }
}

@media (max-width: 375px) {
  .hero-logo-container {
    width: 110px;
    height: 110px;
  }
  .hero-logo-container img {
    width: 82%;
  }
}


/* ============================================================================
   5. SAFE AREA — landscape L/R insets on inner containers
   Do NOT push padding onto body — .nav-links is fixed/left:0/width:100%
   and body padding would desync from viewport width.
   ============================================================================ */
@media (orientation: landscape) and (max-width: 1024px) {
  .nav-container,
  .navbar > .container,
  .container,
  .footer-content,
  .mobile-sticky-cta {
    padding-left: max(env(safe-area-inset-left, 0px), 16px);
    padding-right: max(env(safe-area-inset-right, 0px), 16px);
  }
}


/* ============================================================================
   6. STICKY CTA — enhancements to existing .mobile-sticky-cta (styles.css:9150)
   Base styles already implemented. We add:
     - keyboard-open hiding (via VisualViewportKeyboardManager in JS)
     - (pointer: coarse) scoping so mouse-only mid-size windows don't show it
     - prefers-contrast outline
   ============================================================================ */
body.keyboard-open .mobile-sticky-cta {
  transform: translateY(150%);
  transition: transform 200ms ease-out;
}

/* Note: we intentionally do NOT gate the sticky CTA on (pointer: coarse) —
   Chrome DevTools mobile emulation keeps pointer: fine from the host device,
   which would suppress the CTA during testing. Relying on the 768px width
   gate from styles.css:9188 is sufficient for real devices. */


/* ============================================================================
   7. SKELETON LOADERS
   ============================================================================ */
.skeleton,
.skeleton-active .skeleton-target {
  position: relative;
  overflow: hidden;
  background: var(--teal-a8);
  border-radius: var(--radius-sm);
}

.skeleton::after,
.skeleton-active .skeleton-target::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--teal-a15) 50%,
    transparent 100%
  );
  animation: qa10-skeleton-shimmer 1400ms ease-in-out infinite;
}

@keyframes qa10-skeleton-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Form submitting state — dim + disable, shimmer the submit button */
form.skeleton-active {
  pointer-events: none;
}

form.skeleton-active button[type="submit"] {
  position: relative;
  overflow: hidden;
  opacity: 0.85;
}

form.skeleton-active button[type="submit"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 100%
  );
  animation: qa10-skeleton-shimmer 1200ms ease-in-out infinite;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after,
  .skeleton-active .skeleton-target::after,
  form.skeleton-active button[type="submit"]::after {
    animation: none;
    background: var(--teal-a15);
  }
}


/* ============================================================================
   8. BREAKPOINT BLOCKS — iPhone SE (375 px) compact tuning
   ============================================================================ */
@media (max-width: 375px) {
  :root {
    --text-hero: clamp(1.8rem, 7.5vw, 2.2rem);
  }

  .container {
    padding: 0 var(--space-3);
  }

  h1 {
    font-size: clamp(1.65rem, 7.5vw, 2rem);
  }

  .nav-logo-img {
    height: 24px;
  }

  .hero {
    padding: 120px 0 60px;
  }

  .hero-buttons .btn {
    padding: 12px 20px;
    font-size: var(--text-sm);
  }
}


/* ============================================================================
   9. USER PREFERENCES
   ============================================================================ */

/* High-contrast mode — stronger accent + outlined interactives */
@media (prefers-contrast: more) {
  :root {
    --teal-light: #5EEAD4;
    --text-secondary: #E4E4E7;
  }

  button,
  a.btn,
  .nav-cta,
  .mobile-sticky-cta .btn {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }

  .case-card,
  .section-badge {
    border: 1px solid var(--white-a40);
  }
}

/* Save-Data / reduced-data — drop decorative canvases, simplify backgrounds */
@media (prefers-reduced-data: reduce) {
  .hero-particle-canvas,
  .intro-canvas,
  #processMiningCanvas,
  canvas[aria-hidden="true"] {
    display: none !important;
  }

  .hero::before,
  .hero::after,
  body::before {
    display: none;
  }

  .grain-overlay {
    display: none;
  }
}


/* ============================================================================
   10. FOLDABLES — Surface Duo + dual-screen postures
   ============================================================================ */
@media (horizontal-viewport-segments: 2) {
  .navbar > .container,
  .hero .container,
  .container {
    max-width: env(viewport-segment-width 0 0);
    margin-left: 0;
  }

  .nav-links {
    width: env(viewport-segment-width 0 0);
    max-width: env(viewport-segment-width 0 0);
  }

  .hero .container {
    grid-template-columns: 1fr;
  }
}

@media (vertical-viewport-segments: 2) {
  .hero {
    min-height: env(viewport-segment-height 0 0);
  }
}


/* ============================================================================
   11. CONTAINER QUERIES — modern component-aware responsiveness
   ============================================================================ */
@supports (container-type: inline-size) {
  .cases-section,
  .case-studies {
    container-type: inline-size;
    container-name: cases;
  }

  @container cases (max-width: 600px) {
    .case-card {
      padding: var(--space-4);
    }
    .case-card h3 {
      font-size: clamp(1rem, 4vw, 1.2rem);
    }
  }

  .team-section,
  .zespol-section {
    container-type: inline-size;
    container-name: team;
  }

  @container team (max-width: 500px) {
    .team-card {
      flex-direction: column;
      text-align: center;
    }
  }
}


/* ============================================================================
   12. VIEW TRANSITIONS — feature-detected, progressively enhanced
   ============================================================================ */
@supports (view-transition-name: root) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 280ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }

  @media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation: none;
    }
  }
}


/* ============================================================================
   NAV FOCUS-WITHIN — keyboard reveal
   ============================================================================ */
.nav-links:focus-within {
  outline: none;
}

.nav-links a:focus-visible,
.nav-links button:focus-visible {
  outline: 2px solid var(--teal-light);
  outline-offset: 4px;
  border-radius: var(--radius-xs);
}
