/* ============================================================================
 * layout.css — Structural styles and ALL responsive behaviour.
 *
 * Every media query on the site lives in this file. That is deliberate: the
 * previous version scattered breakpoints across four separate <style> blocks
 * (two of which both targeted 880px with conflicting rules), which is why the
 * layout behaved differently depending on which component happened to render.
 *
 * Breakpoint ladder — one ladder, applied consistently to every grid:
 *
 *   > 1024px   desktop      3-column grids, horizontal nav
 *   <= 1024px  large tablet 2-column grids, horizontal nav
 *   <=  860px  tablet/phone 1-column, hamburger nav, stacked hero
 *   <=  600px  small phone  tighter type and spacing
 *
 * The 860px cut is where the hamburger appears. It is set well above phone
 * width on purpose so portrait tablets (768px) get the same tested mobile
 * layout rather than a cramped desktop nav.
 * ==========================================================================*/

/* ─── Navigation ─────────────────────────────────────────────────────────── */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0 calc(var(--gutter) + var(--safe-r)) 0 calc(var(--gutter) + var(--safe-l));
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background 0.4s ease, border-color 0.4s ease, backdrop-filter 0.4s ease;
}

/* Applied by JS once the page is scrolled past the nav height. The class
   toggles only on threshold crossings, not on every scroll event. */
.site-nav.is-scrolled {
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--nav-border);
}

.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
}

.nav-brand {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.nav-brand-main {
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink-light);
}

.nav-brand-subtitle {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 2px;
  font-size: 0.65rem;
  white-space: nowrap;
}

.nav-desktop {
  display: flex;
  gap: clamp(1.25rem, 2.6vw, 2.5rem);
  align-items: center;
}

.nav-desktop a {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-light);
  white-space: nowrap;
  transition: color 0.2s;
}

.nav-desktop a:hover {
  color: var(--ink);
}

.nav-cta {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg) !important;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.nav-cta:hover {
  opacity: 0.85;
}

/* Hamburger — hidden on desktop, revealed at <=860px. */
.nav-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  border: 1px solid var(--nav-border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--ink);
  cursor: pointer;
}

.nav-menu-toggle span {
  display: block;
  width: 18px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Hamburger morphs into an X when the menu is open. */
.nav-menu-toggle.is-open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-menu-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-menu-toggle.is-open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.nav-mobile-menu {
  display: none;
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */

.hero-section {
  /* svh = "small viewport height": the height with mobile browser chrome
     visible. Using it instead of vh stops the hero from being taller than
     the screen on iOS/Android, which used to push the CTA below the fold. */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(6rem, 11vw, 8rem) calc(var(--gutter) + var(--safe-r)) 4rem
    calc(var(--gutter) + var(--safe-l));
  position: relative;
  overflow: hidden;
}

.hero-grid {
  position: relative;
  z-index: 1;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero-copy {
  text-align: left;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5.5vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.hero-lede {
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
  color: var(--ink-light);
  line-height: 1.55;
  max-width: 520px;
  margin-bottom: 2.25rem;
}

.hero-actions {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.hero-stats {
  display: flex;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  margin-top: 2.25rem;
  flex-wrap: wrap;
}

.hero-graphic-wrap {
  position: relative;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  /* min-height keeps every tappable control at or above the 44px target
     size recommended for touch. */
  min-height: 44px;
  padding: 0.95rem 2rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 6px 24px oklch(18% 0.02 260 / 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px oklch(18% 0.02 260 / 0.3);
}

.btn-ghost {
  border: 1.5px solid var(--card-border);
  color: var(--ink);
  background: var(--card-bg);
}

.btn-ghost:hover {
  border-color: var(--ink);
  background: var(--bg-alt);
}

/* ─── Grids ──────────────────────────────────────────────────────────────── */

.service-grid,
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.product-grid {
  gap: 1.5rem;
}

.process-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: stretch;
}

.contact-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--ink-light);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1.5px solid var(--card-border);
  /* Must be >=16px. Anything smaller makes iOS Safari zoom the page in when
     the field receives focus, which visibly breaks the mobile layout. */
  font-size: 16px;
  background: var(--card-bg);
  color: var(--ink);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.field-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px oklch(50% 0.22 188 / 0.12);
}

.field-input::placeholder {
  color: var(--ink-faint);
}

textarea.field-input {
  resize: vertical;
  line-height: 1.6;
  min-height: 120px;
}

select.field-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  padding: 2.5rem calc(var(--gutter) + var(--safe-r))
    calc(2.5rem + var(--safe-b)) calc(var(--gutter) + var(--safe-l));
  border-top: 1px solid var(--card-border);
  background: var(--bg);
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--ink-faint);
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--ink);
}

/* ─── Decorative background orbs ─────────────────────────────────────────── */

/* A large blurred circle. Kept as a class rather than an inline style so the
   mobile performance guard further down can switch off its animation.

   Deliberately no will-change: the blur filter already promotes these to
   their own compositor layer, and hinting five 400px layers up front costs
   memory for no gain. */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

/* ============================================================================
 * RESPONSIVE
 * ==========================================================================*/

/* ─── <= 1024px — large tablet: drop 3-column grids to 2 ─────────────────── */

@media (max-width: 1024px) {
  .service-grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .hero-graphic-wrap {
    width: min(62vw, 380px);
    margin-inline: auto;
  }
}

/* ─── <= 860px — tablet & phone: single column, hamburger nav ────────────── */

@media (max-width: 860px) {
  /* Nav: swap the horizontal links for the hamburger. The nav bar is given
     a solid background at all scroll positions here, because the stacked
     hero sits directly beneath it with no clearance. */
  .site-nav {
    padding: 0 calc(1rem + var(--safe-r)) 0 calc(1rem + var(--safe-l));
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: var(--nav-border);
  }

  .nav-brand-main {
    font-size: 1.12rem;
  }

  .nav-brand-subtitle {
    font-size: 0.56rem;
    letter-spacing: 0.14em;
  }

  .nav-desktop {
    display: none;
  }

  .nav-menu-toggle {
    display: inline-flex;
  }

  .nav-mobile-menu {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    /* dvh tracks the live viewport as mobile browser chrome collapses, so a
       long menu stays scrollable rather than being clipped. */
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    padding: 0.7rem 1rem calc(1rem + var(--safe-b));
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: 0 18px 40px oklch(0% 0 0 / 0.12);
  }

  .nav-mobile-menu a {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.85rem 0.9rem;
    border-radius: 8px;
    color: var(--ink-light);
    font-size: 0.95rem;
    font-weight: 500;
  }

  .nav-mobile-menu a:last-child {
    margin-top: 0.35rem;
    background: var(--ink);
    color: var(--bg);
    justify-content: center;
  }

  /* Hero: stack, graphic first, everything centred. */
  .hero-section {
    min-height: auto;
    justify-content: flex-start;
    padding-top: 6rem;
    padding-bottom: 5rem;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    text-align: center;
  }

  .hero-copy {
    text-align: center;
  }

  .hero-title {
    font-size: clamp(2.3rem, 9vw, 3.2rem);
  }

  .hero-lede {
    margin-inline: auto;
  }

  .hero-actions,
  .hero-stats {
    justify-content: center;
  }

  .hero-graphic-wrap {
    order: -1;
    width: min(76vw, 320px);
    margin: 0 auto 0.75rem;
  }

  /* All multi-column grids collapse to one column together. */
  .service-grid,
  .product-grid,
  .process-grid,
  .people-grid,
  .contact-grid,
  .contact-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }

  .footer-links {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
  }

  /* Performance guard: a blurred 400px circle that also animates its
     transform forces the compositor to re-rasterise a large layer every
     frame. On phones that is the single most expensive thing on the page,
     so the colour wash stays and the motion stops. */
  .orb {
    animation: none !important;
    filter: blur(60px);
    will-change: auto;
  }
}

/* ─── <= 600px — small phone: tighten type and spacing ───────────────────── */

@media (max-width: 600px) {
  :root {
    --section-y: clamp(3.5rem, 12vw, 5rem);
  }

  .hero-title {
    font-size: clamp(2.1rem, 10vw, 2.8rem);
  }

  .hero-lede {
    font-size: 1rem;
  }

  .hero-actions .btn {
    /* Full-width stacked CTAs are easier to hit one-handed. */
    flex: 1 1 100%;
  }

  .hero-graphic-wrap {
    width: min(84vw, 290px);
  }

  .footer-links {
    gap: 0.75rem 1.25rem;
  }
}

/* ─── Coarse pointers — disable hover-only affordances ───────────────────── */

/* Touch devices fire :hover on tap and then leave it stuck until the next
   tap elsewhere. Suppressing the transforms avoids cards that stay lifted. */
@media (hover: none) {
  .btn-primary:hover,
  .btn-ghost:hover {
    transform: none;
  }
}
