/**
 * Homepage CTA / callback / quote modals — performance + full viewport scale
 * (phones through 4K TV). Load on index.html only.
 */

/* Callback / quote: compact footer — centered horizontally and vertically */
body.pcs-home .pc-modal-formfooter {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
  padding: 16px 12px;
  text-align: center;
  border-top: 1px solid rgba(18, 34, 65, 0.1);
}

body.pcs-home .pc-modal-back-link {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pc-navy, #122241);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.pcs-home .pc-modal-back-link:hover,
body.pcs-home .pc-modal-back-link:focus-visible {
  color: var(--pc-accent, #6b6ce0);
}

body.pcs-home .pc-modal-formfooter-note {
  margin: 0;
  width: 100%;
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
  color: rgba(18, 34, 65, 0.72);
}

body.pcs-home .pc-modal-formfooter-note a {
  font-weight: 700;
  color: var(--pc-navy, #122241);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Form modals: one primary action (Submit) in the card */
body.pcs-home #callbackModal .pc-modal-formfooter,
body.pcs-home #quoteModal .pc-modal-formfooter {
  flex-shrink: 0;
}

body.pcs-home #callbackModal .pcs-native-callback-form__title,
body.pcs-home #callbackModal .pcs-native-callback-form__intro,
body.pcs-home #quoteModal .pcs-native-quote-form__title,
body.pcs-home #quoteModal .pcs-native-quote-form__intro {
  display: none;
}

button.pc-modal-btn {
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

/* GPU-friendly open state; no perpetual will-change */
body.pcs-home .pc-modal.is-open .pc-modal-card {
  contain: layout style paint;
}

/* Cheaper overlay on touch / narrow viewports (backdrop-filter is costly) */
@media (max-width: 991px), (hover: none) {
  body.pcs-home .pc-modal-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(18, 34, 65, 0.82);
  }
}

/* Icon glyphs: stable box so missing-font flash is minimal */
body.pcs-home .pc-modal-icon i,
body.pcs-home .pc-modal-close i {
  display: inline-block;
  min-width: 1.15em;
  text-align: center;
  line-height: 1;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
}

body.pcs-home .pc-modal-icon .fa-solid,
body.pcs-home .pc-modal-close .fa-solid {
  font-weight: 900;
}

/* Safe areas (notched phones, home indicator) */
body.pcs-home .pc-modal {
  padding: max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
}

/* Quote / callback sheets: scroll inside card on all viewports */
body.pcs-home #callbackModal .pc-modal-card,
body.pcs-home #quoteModal .pc-modal-card {
  width: min(960px, calc(100vw - 24px));
  max-height: min(94dvh, 94vh, 980px);
  display: flex;
  flex-direction: column;
}

body.pcs-home #callbackModal .pc-modal-body,
body.pcs-home #quoteModal .pc-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: clip;
  -webkit-overflow-scrolling: touch;
}

body.pcs-home #ctaModal .pc-modal-card {
  width: min(560px, 100%);
  max-height: min(92dvh, 92vh, 860px);
}

/* iPhone SE / narrow (≤390) */
@media (max-width: 390px) {
  body.pcs-home .pc-modal-header h3 {
    font-size: clamp(1.15rem, 5.2vw, 1.35rem);
  }

  body.pcs-home .pc-modal-titlewrap {
    gap: 10px;
  }

  body.pcs-home .pc-tube-canvas {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  body.pcs-home .pc-modal .pc-modal-btn {
    min-height: 76px;
    padding: 12px 14px;
    gap: 12px;
  }

  body.pcs-home .pc-modal-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    font-size: 17px;
  }

  body.pcs-home .pc-modal-text strong {
    font-size: 1rem;
  }

  body.pcs-home .pc-modal-text small {
    font-size: 0.8125rem;
    line-height: 1.35;
  }
}

/* Large phones (391–480) */
@media (min-width: 391px) and (max-width: 480px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: 100%;
  }
}

/* Tablets: iPad Mini / Air / Pro */
@media (min-width: 481px) and (max-width: 767px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: min(520px, calc(100vw - 32px));
  }
}

@media (min-width: 768px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: min(580px, calc(100vw - 48px));
  }

  body.pcs-home #callbackModal .pc-modal-card,
  body.pcs-home #quoteModal .pc-modal-card {
    width: min(960px, calc(100vw - 48px));
  }

  body.pcs-home #callbackModal .pcs-native-callback-form__field--date,
  body.pcs-home #callbackModal .pcs-native-callback-form__field--time {
    gap: 8px;
  }

  body.pcs-home #callbackModal .pcs-native-callback-form__grid {
    gap: 20px 26px;
  }
}

/* Laptops */
@media (min-width: 1200px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: min(600px, 42vw);
  }
}

/* 27″ (~1920px) */
@media (min-width: 1920px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: min(640px, 34vw);
  }

  body.pcs-home .pc-modal-header h3 {
    font-size: clamp(1.75rem, 1.1vw + 1rem, 2rem);
  }
}

/* 32″ / QHD (~2560px) */
@media (min-width: 2560px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: min(680px, 28vw);
  }

  body.pcs-home .pc-modal-body {
    gap: 16px;
  }
}

/* 4K TV (~3840px) — readable, not oversized */
@media (min-width: 3840px) {
  body.pcs-home #ctaModal .pc-modal-card {
    width: min(720px, 22vw);
    max-height: min(80vh, 900px);
  }

  body.pcs-home .pc-modal .pc-modal-btn {
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Foldables / Nest Hub / short landscape */
@media (max-height: 500px) and (min-width: 600px) {
  body.pcs-home .pc-modal {
    align-items: flex-start;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }

  body.pcs-home .pc-modal-card {
    max-height: min(94dvh, 94vh);
    margin-top: 4px;
  }

  body.pcs-home .pc-modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.pcs-home .pc-modal .pc-modal-btn {
    min-height: 68px;
    padding: 10px 14px;
  }
}

/* Performance: skip decorative motion when user prefers less */
@media (prefers-reduced-motion: reduce) {
  body.pcs-home .pc-modal.is-open .pc-tube-canvas,
  body.pcs-home .pc-modal-btn-primary::after,
  body.pcs-home .pcs-offer-pulse {
    animation: none !important;
  }

  body.pcs-home .pc-modal-overlay,
  body.pcs-home .pc-modal,
  body.pcs-home .pc-modal-card {
    transition-duration: 0.01ms !important;
  }
}

/* Coarse pointer: no shimmer / glow loops */
@media (hover: none) and (pointer: coarse) {
  body.pcs-home .pc-modal-btn-primary::after,
  body.pcs-home .pc-modal.is-open .pc-tube-canvas {
    animation: none;
  }
}
