/* Only Telegram's injected iPhone bridge enables these overrides. */
html.is-telegram-ios :is(.hero, .about-section, .about-grid, .work-section, .work-stage, .services-section, .services-stage, .reviews-section, .contact-section, .contact-grid) {
  min-height: var(--telegram-screen-height);
}

html.is-telegram-ios .hero { height: var(--telegram-screen-height); }
html.is-telegram-ios .case-lightbox { max-height: calc(var(--telegram-screen-height) - 48px); }
html.is-telegram-ios .case-lightbox-image { max-height: calc(var(--telegram-screen-height) - 136px); }

html.is-telegram-ios .all-work-section.is-project-scene,
html.is-telegram-ios .all-work-section.is-project-scene .work-stage { height: var(--telegram-screen-height); }

html.is-telegram-ios .all-work-section.is-project-scene .work-stage {
  --project-width: min(64vw, calc((var(--telegram-screen-height) - 200px) * 1.45), 860px);
  padding-block: 24px;
}

html.is-telegram-ios .all-work-section.is-project-scene .project-caption { margin-top: 22px; }
html.is-telegram-ios .all-work-section.is-project-scene .project-title strong { font-size: clamp(22px, 2.1vw, 30px); }
html.is-telegram-ios .gallery-back { margin-top: 12px; }

@media (max-width: 767px) {
  html.is-telegram-ios .hero { min-height: min(560px, var(--telegram-screen-height)); }
  html.is-telegram-ios .case-review { height: var(--telegram-screen-height); }
  html.is-telegram-ios .case-lightbox { max-height: calc(var(--telegram-screen-height) - 20px); }
  html.is-telegram-ios .case-lightbox-image { max-height: calc(var(--telegram-screen-height) - 108px); }
  html.is-telegram-ios .service-art { max-width: min(100%, calc(var(--telegram-screen-height) * .14), 145px); }

  /* Keep the form's height breakpoint tied to the captured screen as well. */
  html.is-telegram-ios .contact-copy h2 { font-size: 30px; line-height: 36px; }
  html.is-telegram-ios .contact-heading > p { margin-top: 12px; line-height: 22px; }
  html.is-telegram-ios .contact-details { margin-top: 20px; }
  html.is-telegram-ios .brief-form { gap: 12px; }
  html.is-telegram-ios .form-intro { font-size: 20px; line-height: 28px; }
  html.is-telegram-ios .brief-form label { gap: 6px; line-height: 18px; }
  html.is-telegram-ios .brief-form :is(input:not([type="checkbox"]), select) { min-height: 44px; padding: 10px 12px; line-height: 22px; }
  html.is-telegram-ios .brief-form textarea { min-height: 88px; padding: 10px 12px; line-height: 22px; }
  html.is-telegram-ios .brief-form .button { min-height: 48px; padding-block: 12px; }

  html.is-telegram-ios.telegram-compact-contact .contact-copy h2 { font-size: 27px; line-height: 32px; }
  html.is-telegram-ios.telegram-compact-contact .contact-heading > p { margin-top: 8px; line-height: 20px; }
  html.is-telegram-ios.telegram-compact-contact .contact-details { margin-top: 16px; }
  html.is-telegram-ios.telegram-compact-contact .brief-form { gap: 10px; }
  html.is-telegram-ios.telegram-compact-contact .form-intro { font-size: 18px; line-height: 24px; }
  html.is-telegram-ios.telegram-compact-contact .brief-form label { gap: 4px; line-height: 16px; }
  html.is-telegram-ios.telegram-compact-contact .brief-form :is(input:not([type="checkbox"]), select) { min-height: 40px; padding: 8px 12px; line-height: 20px; }
  html.is-telegram-ios.telegram-compact-contact .brief-form textarea { min-height: 72px; padding: 8px 12px; line-height: 18px; }
  html.is-telegram-ios.telegram-compact-contact .brief-form .button { min-height: 44px; padding-block: 10px; }

  html.is-telegram-ios #work.is-project-scene .work-stage {
    --project-width: min(86vw, max(280px, calc((var(--telegram-screen-height) - 400px) * 1.45)), calc((var(--telegram-screen-height) - 336px) * 1.5), 560px);
    height: var(--telegram-screen-height);
    justify-content: center;
    padding-block: 0;
  }
  html.is-telegram-ios #work.is-project-scene .section-heading {
    margin-bottom: clamp(56px, calc(var(--telegram-screen-height) * .12), 112px);
  }
  html.is-telegram-ios #work.is-project-scene .project-caption { margin-top: 28px; }
  html.is-telegram-ios #work.is-project-scene .project-title strong { font-size: 24px; }
  html.is-telegram-ios #work.is-project-scene .project-meta { font-size: 11px; }
  html.is-telegram-ios #work.is-project-scene .browser-toolbar { grid-template-columns: 44px 1fr 44px; }

  html.is-telegram-ios.telegram-short-screen #work.is-project-scene .work-stage {
    justify-content: flex-start;
    padding-top: calc(var(--anchor-offset) + 8px);
  }
  html.is-telegram-ios.telegram-short-screen #work.is-project-scene .section-heading { margin-bottom: 32px; }
  html.is-telegram-ios.telegram-short-screen #work.is-project-scene .project-caption { margin-top: 20px; }
  html.is-telegram-ios.telegram-short-screen #work.is-project-scene .project-title strong { font-size: 18px; }
  html.is-telegram-ios.telegram-short-screen #work.is-project-scene .project-meta { font-size: 10px; }
  html.is-telegram-ios.telegram-short-screen #work.is-project-scene .browser-toolbar { grid-template-columns: 44px minmax(0, 1fr) 12px; }

  html.is-telegram-ios .all-work-section.is-project-scene .work-stage {
    --project-width: min(86vw, calc((var(--telegram-screen-height) - 280px) * 1.45), 560px);
  }
  html.is-telegram-ios .all-work-section.is-project-scene .project-card {
    top: calc(50% + clamp(20px, calc(var(--telegram-screen-height) * .05), 44px));
  }
}

html.is-telegram-ios.telegram-short-screen .all-work-section.is-project-scene .work-stage {
  --project-width: min(56vw, calc((var(--telegram-screen-height) - 180px) * 1.45));
  padding-block: 12px;
}
html.is-telegram-ios.telegram-short-screen .all-work-section.is-project-scene .project-caption { margin-top: 12px; }
html.is-telegram-ios.telegram-short-screen .all-work-section.is-project-scene .project-title strong { font-size: 20px; }
html.is-telegram-ios.telegram-short-screen .gallery-back { margin-top: 0; }

/* Telegram observes transform/top/left under the finger and cancels its panel
   gesture when they change. Individual transforms preserve the same visuals. */
html.has-telegram-safe-motion :is(.hero-content, .hero-art) {
  --telegram-hero-y: 0px;
  --telegram-hero-scale: 1;
  transform: none !important;
  translate: 0 var(--telegram-hero-y, 0px);
  scale: var(--telegram-hero-scale, 1);
}
html.has-telegram-safe-motion .is-project-scene .project-card { will-change: translate, scale; }

@media (max-width: 767px) {
  html.has-telegram-safe-motion .is-review-carousel .review-card {
    transform: none;
    translate: 0 0;
    scale: .92;
    transition: translate .3s ease, scale .3s ease, opacity .3s ease;
  }
  html.has-telegram-safe-motion .is-review-carousel .review-card.is-current { translate: 0 -8px; scale: 1; }
}
