/*
 * Phone-first hardening layer.
 *
 * The original visual system is retained, but this final layer makes the
 * small-screen contract explicit: one readable column, touch-sized controls,
 * no viewport overflow, and compact media before wider layouts enhance it.
 */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

img,
video,
svg,
canvas {
  max-width: 100%;
}

img,
video {
  height: auto;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

input,
select,
textarea {
  max-width: 100%;
  font-size: 1rem; /* prevents iOS focus zoom */
}

@media (max-width: 47.999rem) {
  :root {
    --phone-gutter: clamp(1rem, 4.6vw, 1.35rem);
    --phone-section: clamp(4rem, 16vw, 5.75rem);
  }

  .site-shell,
  main,
  section,
  header,
  footer,
  .section,
  .about-inner,
  .bl-wrap {
    min-width: 0;
    max-width: 100%;
  }

  .site-header {
    height: calc(4.5rem + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--phone-gutter) 0;
  }

  .brand-logo img {
    width: auto;
    max-width: 8.75rem;
    height: 2.15rem;
  }

  .header-actions {
    gap: .5rem;
  }

  .urgent-pill {
    display: none;
  }

  .menu-button {
    width: 2.85rem;
    height: 2.85rem;
    flex: none;
  }

  .nav-links {
    inset: calc(4.5rem + env(safe-area-inset-top)) 0 0;
    height: calc(100dvh - 4.5rem - env(safe-area-inset-top));
    padding: 1.25rem var(--phone-gutter) calc(1.5rem + env(safe-area-inset-bottom));
    gap: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: color-mix(in srgb, var(--paper) 97%, transparent);
  }

  .nav-links a {
    min-height: 3.65rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
    font-size: clamp(1.35rem, 7vw, 1.75rem);
  }

  .nav-links .nav-urgent {
    margin-top: 1rem;
    padding-inline: 1rem;
    border: 1.5px solid var(--ink);
    border-radius: 999px;
    background: var(--coral);
    font-size: .85rem;
  }

  .hero,
  .about-hero,
  .sd-hero,
  .pd-hero,
  .pp-hero,
  .urgent-hero {
    min-height: auto;
    padding-left: var(--phone-gutter);
    padding-right: var(--phone-gutter);
  }

  .hero {
    min-height: 100svh;
    padding-top: calc(6.75rem + env(safe-area-inset-top));
    padding-bottom: 4.5rem;
  }

  .about-hero,
  .sd-hero,
  .pd-hero,
  .pp-hero,
  .urgent-hero {
    padding-top: calc(6.5rem + env(safe-area-inset-top));
  }

  .hero h1,
  .about-hero h1,
  .sd-hero h1,
  .pd-hero h1,
  .pp-hero h1,
  .urgent-hero h1 {
    font-size: clamp(2.85rem, 14.5vw, 4.5rem);
    line-height: .9;
    letter-spacing: -.065em;
  }

  .section-heading :is(:is(h2,[data-heading-style="h2"]),[data-heading-style=":is(h2,[data-heading-style="h2"])"]),
  .feature-copy :is(:is(h2,[data-heading-style="h2"]),[data-heading-style=":is(h2,[data-heading-style="h2"])"]),
  .showcase-intro :is(:is(h2,[data-heading-style="h2"]),[data-heading-style=":is(h2,[data-heading-style="h2"])"]),
  .cta-section :is(:is(h2,[data-heading-style="h2"]),[data-heading-style=":is(h2,[data-heading-style="h2"])"]),
  .about-promises :is(:is(h2,[data-heading-style="h2"]),[data-heading-style=":is(h2,[data-heading-style="h2"])"]),
  .about-why :is(:is(h2,[data-heading-style="h2"]),[data-heading-style=":is(h2,[data-heading-style="h2"])"]) {
    font-size: clamp(2.55rem, 12.5vw, 3.65rem);
    line-height: .92;
  }

  .hero-copy,
  .about-lede,
  .section-heading > p {
    font-size: 1rem;
    line-height: 1.55;
  }

  .section,
  .feature,
  .proposal,
  .about-promises,
  .about-why,
  .showcase,
  .projects,
  .testimonials,
  .presence,
  .cta-section {
    padding: var(--phone-section) var(--phone-gutter);
  }

  .section-heading {
    margin-bottom: 2.25rem;
  }

  .idea-form {
    margin-top: 2rem;
  }

  .idea-field {
    min-height: 3.65rem;
  }

  input,
  select,
  textarea,
  .idea-field input {
    font-size: 1rem !important;
  }

  .button-3d,
  .work-tab,
  .product-tab,
  .bl-filters button,
  .ck-link {
    min-height: 2.75rem;
  }

  .button-3d {
    white-space: normal;
    text-align: center;
  }

  .service-grid,
  .service-grid--bento,
  .about-offices,
  .about-work-grid,
  .ap-grid,
  .bl-grid,
  .work-grid,
  .prob-grid,
  .testimonial-grid,
  .process-steps,
  .offices,
  .footer-groups,
  .pp-card,
  .pp-card.is-flip,
  .sd-split,
  .pd-split,
  .request-card,
  .urgent-hero-inner,
  .bp-grid,
  .lg-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .service-card {
    min-height: 20rem;
    padding: 1.25rem;
  }

  .service-card :is(:is(h3,[data-heading-style="h3"]),[data-heading-style=":is(h3,[data-heading-style="h3"])"]) {
    max-width: calc(100% - 3.5rem);
    font-size: clamp(1.8rem, 9vw, 2.45rem);
  }

  .service-card p {
    max-width: calc(100% - 2.8rem);
    padding-right: 0;
  }

  .real-photo,
  .real-photo img {
    width: 100%;
  }

  .feature-collage {
    min-height: 26rem;
  }

  .product-stage,
  .product-mock,
  .project-visual,
  .browser-content {
    min-height: 0;
  }

  .browser-card,
  .service-card,
  .project-card,
  .pp-card,
  .request-card,
  .about-photo,
  .bl-feature {
    border-radius: 1rem;
    box-shadow: .28rem .35rem 0 var(--ink);
  }

  .browser-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: .5rem;
  }

  .browser-bar > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .product-stage {
    margin: .55rem;
    padding: 1rem;
  }

  .product-actions,
  .cta-actions,
  .ap-actions,
  .nf-actions,
  .bp-cta-actions {
    width: 100%;
  }

  .product-actions .button-3d,
  .cta-actions .button-3d,
  .nf-actions .button-3d {
    width: 100%;
  }

  .product-tabs,
  .work-tabs,
  .pp-cats,
  .steps {
    margin-inline: calc(var(--phone-gutter) * -1);
    padding-inline: var(--phone-gutter);
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .product-tabs::-webkit-scrollbar,
  .work-tabs::-webkit-scrollbar,
  .pp-cats::-webkit-scrollbar,
  .steps::-webkit-scrollbar {
    display: none;
  }

  .product-tab,
  .work-tab,
  .pp-cats a,
  .steps > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .project-card-copy,
  .project-visual,
  .testimonial-grid figure {
    min-height: 0;
  }

  .project-card-copy :is(:is(h3,[data-heading-style="h3"]),[data-heading-style=":is(h3,[data-heading-style="h3"])"]),
  .browser-hero :is(:is(h3,[data-heading-style="h3"]),[data-heading-style=":is(h3,[data-heading-style="h3"])"]) {
    font-size: clamp(2.6rem, 13vw, 3.75rem);
  }

  .metrics,
  .about-stats,
  .work-stats {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .metrics > div,
  .about-stats > div {
    min-width: 0;
    padding: 1.35rem .75rem;
  }

  .metrics strong,
  .about-stats strong {
    font-size: clamp(2.25rem, 11vw, 3.4rem);
  }

  .about-photo {
    aspect-ratio: 4 / 3;
  }

  .about-photo-sticker,
  .team-photo-note {
    max-width: calc(100% - 1rem);
  }

  .about-chapters {
    padding-left: 1.75rem;
  }

  .chapter::before {
    left: -1.75rem;
  }

  .about-promise,
  .role,
  .stack-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .role > .button-3d,
  .role > a {
    justify-self: start;
  }

  .bp-toc,
  .lg-side {
    position: static;
  }

  .bp-toc {
    display: none;
  }

  .bp-cover,
  .bl-wrap {
    padding-inline: var(--phone-gutter);
  }

  .bp-cover .bl-cover,
  .bl-cover,
  .about-photo {
    aspect-ratio: 4 / 3;
  }

  .bl-feature {
    padding: .85rem;
  }

  .fields,
  .opts,
  .opts--2,
  .direct,
  .request-form .fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .phone {
    flex-wrap: wrap;
  }

  .phone select,
  .phone input {
    min-height: 3rem;
  }

  .ck-banner {
    bottom: calc(.75rem + env(safe-area-inset-bottom));
    width: calc(100% - 1.5rem);
    padding: .9rem;
  }

  .ck-banner p {
    min-width: 0;
  }

  .ck-banner > div,
  .ck-actions {
    width: 100%;
    justify-content: stretch;
  }

  .ck-banner button,
  .ck-actions button {
    flex: 1;
  }

  .chat-launcher {
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .chat-panel {
    right: .75rem;
    bottom: calc(4.75rem + env(safe-area-inset-bottom));
    width: calc(100vw - 1.5rem);
    max-height: min(76dvh, 40rem);
  }

  footer {
    padding: 3.25rem var(--phone-gutter) calc(1.5rem + env(safe-area-inset-bottom));
  }

  .footer-groups,
  footer,
  .footer-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-meta {
    align-items: flex-start;
  }
}

@media (max-width: 23.5rem) {
  .hero h1,
  .about-hero h1,
  .sd-hero h1,
  .pd-hero h1,
  .pp-hero h1,
  .urgent-hero h1 {
    font-size: 2.7rem;
  }

  .metrics,
  .about-stats,
  .work-stats,
  .logos {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (hover: none) and (pointer: coarse) {
  .button-3d:hover,
  .service-card:hover,
  .bl-card:hover,
  .work-card:hover,
  .pp-card:hover {
    transform: none;
  }

  .button-3d:active {
    transform: translateY(.18rem);
  }
}
