/* Responsive refinements for phones, foldables and compact tablets. */
:root {
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  min-width: 0;
  overflow-wrap: break-word;
}

@media (max-width: 64rem) {
  :root {
    --shell: min(calc(100% - 2.5rem - var(--safe-left) - var(--safe-right)), 92rem);
  }

  html { scroll-padding-top: 5.25rem; }

  .header-inner {
    min-height: 4.75rem;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.65rem;
  }

  .brand,
  .language-switcher,
  .nav-toggle { grid-column: auto; }

  .brand { min-width: 0; }

  .brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .language-switcher { justify-self: end; }

  .nav-toggle {
    justify-self: end;
    display: grid;
    gap: 0.35rem;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.8rem 0.55rem;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .nav-toggle span:not(.sr-only) {
    display: block;
    width: 100%;
    height: 1px;
    background: var(--ink);
    transition: transform 180ms ease;
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(2) {
    transform: translateY(0.2rem) rotate(45deg);
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-0.2rem) rotate(-45deg);
  }

  .primary-nav {
    position: fixed;
    inset: 4.75rem 0 auto;
    display: none;
    max-height: calc(100dvh - 4.75rem);
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1.25rem max(1.25rem, var(--safe-right)) calc(1.75rem + var(--safe-bottom)) max(1.25rem, var(--safe-left));
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
    box-shadow: 0 1rem 2rem rgb(20 19 16 / 0.08);
  }

  .primary-nav.is-open { display: flex; }

  .primary-nav a {
    display: flex;
    align-items: center;
    min-height: 3.25rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 1rem;
    background-image: none;
  }

  .primary-nav .nav-contact {
    justify-content: center;
    margin: 1rem 0 0;
    padding: 0.85rem 1rem;
  }

  .hero {
    min-height: auto;
    grid-template-rows: auto auto auto auto;
    padding-top: clamp(2rem, 5vw, 3.5rem);
  }

  .hero-title {
    padding-block: clamp(3rem, 9vw, 6rem);
    font-size: clamp(4.25rem, 12vw, 7.7rem);
  }

  .hero-lower { padding-bottom: 3rem; }
}

@media (max-width: 56rem) {
  .section-grid,
  .categories,
  .about-grid,
  .contact-grid {
    row-gap: clamp(3.5rem, 8vw, 5rem);
  }

  .section-heading,
  .service-list,
  .categories-intro,
  .category-list,
  .about-copy,
  .contact-prompt,
  .contact-grid > div {
    grid-column: 1 / -1;
  }

  .section-heading h2,
  .categories-intro h2,
  .about-copy h2,
  .contact h2 { max-width: 12ch; }

  .hero-intro { grid-column: 1 / 7; }
  .hero-action { grid-column: 8 / -1; }

  .process-heading { display: block; }
  .process-heading h2 { max-width: 13ch; }

  .process-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: clamp(4rem, 9vw, 6rem);
  }

  .process-list li,
  .process-list li:not(:first-child) {
    min-height: 16rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--line);
  }

  .process-list li:nth-child(odd) { padding-left: 0; }
  .process-list li:nth-child(even) { border-right: 0; }
  .process-number { margin-bottom: 3.5rem; }

  .why {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .why-image-wrap { min-height: clamp(30rem, 62svh, 42rem); }
  .why-image { object-position: center 42%; }

  .why-content {
    padding: clamp(4.5rem, 9vw, 7rem) max(1.25rem, calc((100vw - min(calc(100vw - 2.5rem), 92rem)) / 2));
  }

  .principle-list li {
    grid-template-columns: minmax(10rem, 0.8fr) 1.4fr;
  }

  .about-monogram {
    grid-column: 1 / 5;
    font-size: clamp(10rem, 26vw, 15rem);
  }

  .about-copy { grid-row: 2; }
}

@media (max-width: 48rem) {
  :root {
    --shell: min(calc(100% - 2rem - var(--safe-left) - var(--safe-right)), 92rem);
    --section-space: clamp(4.75rem, 18vw, 6rem);
  }

  .hero {
    min-height: calc(100vh - 4.75rem);
    min-height: calc(100svh - 4.75rem);
    grid-template-rows: auto 1fr auto auto;
    padding-top: 1.25rem;
  }

  .hero-index {
    grid-column: 7 / -1;
    text-align: right;
  }

  .hero-title {
    padding-block: clamp(2.5rem, 9vh, 5rem);
    font-size: clamp(3.35rem, 17.5vw, 6.6rem);
    line-height: 0.9;
  }

  .hero-title > span:last-child {
    width: auto;
    margin-left: 8%;
  }

  .hero-lower {
    row-gap: 2rem;
    padding-bottom: 2rem;
  }

  .hero-intro,
  .hero-action { grid-column: 1 / -1; }

  .hero-intro {
    max-width: 23rem;
    font-size: clamp(1.3rem, 6vw, 1.75rem);
  }

  .text-link,
  .primary-nav a,
  .language-switcher button,
  .nav-toggle { touch-action: manipulation; }

  .section-heading h2,
  .categories-intro h2,
  .about-copy h2,
  .contact h2 {
    max-width: none;
    font-size: clamp(2.55rem, 12.5vw, 4.5rem);
    line-height: 1;
  }

  .section-kicker { margin-bottom: 1.5rem; }

  .service-item {
    grid-template-columns: 2rem minmax(0, 1fr);
    gap: 0.75rem;
    padding-block: 1.4rem;
  }

  .service-item p,
  .process-list p,
  .principle-list p,
  .about-copy p:not(.section-kicker) { font-size: 1rem; }

  .process-list { grid-template-columns: 1fr; }

  .process-list li,
  .process-list li:not(:first-child) {
    min-height: auto;
    padding: 1.6rem 0 1.9rem;
    border-right: 0;
  }

  .process-number { margin-bottom: 1.75rem; }
  .why-image-wrap { min-height: clamp(27rem, 68svh, 36rem); }

  .image-caption {
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    width: fit-content;
    max-width: calc(100% - 2rem);
    line-height: 1.4;
  }

  .why-content {
    padding: var(--section-space) max(1rem, var(--safe-right)) var(--section-space) max(1rem, var(--safe-left));
  }

  .why-content h2 { font-size: clamp(2.9rem, 14vw, 4.7rem); }

  .why-lede {
    margin: 2.25rem 0 2.5rem;
    font-size: clamp(1.25rem, 5.7vw, 1.65rem);
  }

  .principle-list li {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .categories-intro > p:last-child { font-size: 1.1rem; }

  .category-list li {
    min-height: 4.2rem;
    padding-inline: 0;
    font-size: clamp(1.1rem, 5vw, 1.35rem);
  }

  .about-grid { row-gap: 2.5rem; }

  .about-monogram {
    grid-column: 1 / -1;
    font-size: clamp(9rem, 43vw, 13rem);
  }

  .about-copy { grid-row: auto; }

  .about-copy .about-lede {
    margin-top: 2.25rem;
    font-size: clamp(1.3rem, 5.8vw, 1.75rem);
  }

  .contact-grid { row-gap: 3rem; }

  .inquiry-form-heading,
  .inquiry-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 1rem;
  }

  .inquiry-form-heading p,
  .inquiry-status {
    max-width: none;
    text-align: left;
  }

  .inquiry-fields {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .inquiry-field-wide {
    grid-column: auto;
  }

  .inquiry-actions button {
    width: 100%;
  }

  .contact-addresses {
    grid-template-columns: 1fr;
    margin-top: 2.5rem;
  }

  .contact-address {
    padding-right: 0;
  }

  .contact-address + .contact-address {
    margin-top: 1.5rem;
    padding: 1.5rem 0 0;
    border-top: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
    border-left: 0;
  }

  .footer-inner { padding-bottom: calc(2rem + var(--safe-bottom)); }
}

@media (max-width: 22.5rem) {
  :root {
    --shell: min(calc(100% - 1.5rem - var(--safe-left) - var(--safe-right)), 92rem);
  }

  .brand-name { display: none; }

  .language-switcher button {
    min-width: 2.1rem;
    padding-inline: 0.35rem;
  }

  .hero-title { font-size: clamp(3.05rem, 17vw, 4.2rem); }
}

/* Foldable-open portrait: use the extra width without desktop density. */
@media (min-width: 40rem) and (max-width: 56rem) and (min-height: 40rem) {
  .hero-intro { grid-column: 1 / 7; }
  .hero-action { grid-column: 8 / -1; }

  .process-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .process-list li,
  .process-list li:not(:first-child) {
    min-height: 15rem;
    padding: 1.5rem;
    border-right: 1px solid var(--line);
  }

  .process-list li:nth-child(odd) { padding-left: 0; }
  .process-list li:nth-child(even) { border-right: 0; }
  .process-number { margin-bottom: 3rem; }
}

@media (max-width: 64rem) and (max-height: 36rem) and (orientation: landscape) {
  .primary-nav { max-height: calc(100dvh - 4.75rem); }
  .hero { min-height: auto; }

  .hero-title {
    padding-block: 2rem;
    font-size: clamp(3.6rem, 10vw, 6.5rem);
  }

  .hero-lower { padding-bottom: 2rem; }
  .why-image-wrap { min-height: 26rem; }
}

@media (hover: none) and (pointer: coarse) {
  .primary-nav a,
  .text-link,
  .language-switcher button,
  .nav-toggle { min-height: 2.75rem; }
}
