/* ============================================================================
   AAC Pro Estimator V104.1 — iOS Touch Parity Layer
   ============================================================================
   ADDITIVE only. Loaded AFTER aac-mobile.css. Targets:
     1. Capacitor-detected native iOS shell  (html.is-native-ios)
     2. Generic touch-only / coarse-pointer devices  (no hover hardware)

   Reason: V104.1 desktop relies on :hover for visual feedback (Create-New
   tile lifts, right-rail tab tint, lead-row tint). On iOS the first tap
   triggers :hover with no animation, then the click runs — feedback feels
   broken. This layer adds :active scale-and-tint feedback so taps feel
   crisp, AND scopes existing :hover rules to non-touch devices so they
   don't fire on the wrong gesture.

   Brand Identity Lock enforced: light surfaces, navy accent (#19195F),
   gold highlights (#C9A84C). NO heavy navy washes.
   ============================================================================ */

/* --- 1. Disable iOS WebKit blue tap-highlight on every interactive surface
       (we render our own :active feedback) ---------------------------------- */
html.is-native-ios button,
html.is-native-ios a,
html.is-native-ios .aac-cn-tile,
html.is-native-ios .aac-onboard-step,
html.is-native-ios .aac-rail-tab,
html.is-native-ios .pipeline-card,
html.is-native-ios .aac-job-picker-confirm,
html.is-native-ios .aac-job-picker-cancel,
html.is-native-ios [role="button"] {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* --- 2. Create-New tile: gold border + tint on tap (parity with desktop hover)
       Active feedback fires on touch devices and on iOS Capacitor shell. */
@media (hover: none), (pointer: coarse) {
  .aac-cn-tile:active {
    background: #fff8e1;
    border-color: #C9A84C;
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(201, 168, 76, 0.18);
    transition: all 100ms cubic-bezier(0.32, 1, 0.55, 1);
  }
  .aac-cn-tile:active .aac-cn-icon {
    background: #fff8e1;
    border-color: #C9A84C;
  }
  /* Keyboard / focus parity (Apple HIG focus ring, not the desktop hover lift). */
  .aac-cn-tile:focus-visible {
    outline: 2px solid #C9A84C;
    outline-offset: 2px;
    border-color: #C9A84C;
  }
}

/* --- 3. Onboarding scorecard rows ---------------------------------------- */
@media (hover: none), (pointer: coarse) {
  .aac-onboard-step:active {
    border-color: #C9A84C;
    background: #fff8e1;
  }
  .aac-onboard-toggle:active {
    border-color: #C9A84C;
    background: #fff8e1;
    transform: scale(0.96);
  }
  .aac-onboard-action:active {
    background: #19195F;
    color: #fff;
  }
  .aac-onboard-step:focus-visible,
  .aac-onboard-action:focus-visible {
    outline: 2px solid #C9A84C;
    outline-offset: 2px;
  }
}

/* --- 4. Right-rail tabs (tablet+ icon strip, FAB on phone) --------------- */
@media (hover: none), (pointer: coarse) {
  .aac-rail-tab:active {
    background: #fff8e1;
    color: #19195F;
    transform: scale(0.95);
  }
  .aac-rail-tab:focus-visible {
    outline: 2px solid #C9A84C;
    outline-offset: -2px;
  }
}

/* --- 5. Lead drawer + pipeline rows --------------------------------------- */
@media (hover: none), (pointer: coarse) {
  .pipeline-card:active,
  tr.aac-lead-row:active,
  .lead-row:active {
    background: #fff8e1;
    transform: scale(0.99);
  }
}

/* --- 6. All primary buttons share the same Apple-feel scale-down ---------- */
@media (hover: none), (pointer: coarse) {
  .aac-btn:active,
  .aac-btn-primary:active,
  .aac-btn-secondary:active,
  button.primary:active,
  .aac-job-picker-confirm:active,
  .aac-job-picker-cancel:active {
    transform: scale(0.97);
    transition: transform 80ms cubic-bezier(0.32, 1, 0.55, 1);
  }
}

/* --- 7. Status bar offset for native shell -------------------------------- */
/* When Capacitor is running with overlaysWebView=false the StatusBar plugin
   already pushes content down, but for safety we add a top safe-area
   reservation on the top bar so notch areas never overlap content. */
html.is-native-ios .header-content,
html.is-native-ios .aac-app-header,
html.is-native-ios .nav-bar {
  padding-top: max(env(safe-area-inset-top, 0px), 8px);
}

/* --- 8. Modal scrolling on iOS keyboard open ------------------------------
   When the iOS keyboard appears, viewport height shrinks. Modals built with
   AACModal (.aac-job-picker-modal) need to remain scrollable so the focused
   input stays visible. */
html.is-native-ios .aac-job-picker-overlay,
@media (hover: none) and (pointer: coarse) {
  .aac-job-picker-overlay {
    align-items: flex-start;
    padding-top: max(env(safe-area-inset-top, 0px), 12px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .aac-job-picker-modal {
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- 9. Pull-to-refresh visual indicator ---------------------------------- */
.aac-ptr-indicator {
  position: absolute;
  top: -56px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(25, 25, 95, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms cubic-bezier(0.32, 1, 0.55, 1);
}
.aac-ptr-host.is-ptr-pulling .aac-ptr-indicator {
  opacity: 1;
}
.aac-ptr-host.is-ptr-refreshing .aac-ptr-indicator {
  opacity: 1;
}
.aac-ptr-indicator::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid #C9A84C;
  border-top-color: transparent;
  border-radius: 50%;
  display: block;
}
.aac-ptr-host.is-ptr-refreshing .aac-ptr-indicator::after {
  animation: aac-ptr-spin 700ms linear infinite;
}
@keyframes aac-ptr-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* --- 10. FAB safe-area redundancy ----------------------------------------
   aac-mobile.css already does this; reinforced for native shell. */
html.is-native-ios .aac-right-rail-fab {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
}
