/* LoomCode mobile baseline (phones and tablets, max-width 1023.98px).
 * Mobile-first reset: one stylesheet for everything below 1024px. Desktop rules above 1024px are not touched.
 * Loaded last on every page so it wins over the desktop rules where a phone rule is needed.
 */
/* iOS Safari scales text up in landscape unless this is set. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (max-width: 1023.98px) {
  html, body {
    width: 100%;
    max-width: 100%;
    /* Anything wider than the screen (glow blobs, the review marquee) is cut off at the edge, so
     * Safari never zooms the page out to fit it. clip (not hidden) keeps the sticky header working. */
    overflow-x: clip;
    min-height: 100svh;
    font-size: 16px;
    line-height: 1.5;
  }

  /* Sections: full width, 16px side padding (safe-area aware), 48px between sections. */
  #main [data-framer-name] {
    box-sizing: border-box;
    max-width: 100%;
  }
  /* Framer nests padded boxes; each level adds its own side inset. Remove the nested insets
   * so the text column is the section width minus 16px on each side. Cards keep their padding. */
  #main [data-framer-name] [data-framer-name] {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  #main [data-framer-name] [data-framer-name].ui-card,
  #main [data-framer-name] [data-framer-name].lc-m-card {
    padding: 20px !important;
  }
  /* The Framer card with a separate border layer: its text box needs the card padding. */
  #main [data-framer-name] [data-framer-name="Project starting points"] {
    padding: 20px !important;
  }
  #main [data-framer-name] [data-framer-name]:is(a, button) {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  /* Underlined text links have no box, so they line up with the text column. */
  #main [data-framer-name] a[data-framer-name="Text link"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  /* Work page filter chips: the nested-inset reset above removed their side padding. */
  #main [data-framer-name="Category filter"] > [data-framer-name] {
    padding: 12px 16px !important;
  }
  /* Work page stats line: Framer keeps the runs of spaces around the slashes, which wrap badly. */
  #main [data-framer-name^="BUILDING SINCE"],
  #main [data-framer-name^="BUILDING SINCE"] * {
    white-space: normal !important;
  }
  #main [data-framer-name$=" content"] {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
    gap: 24px;
  }
  #main [data-framer-name$=" content"] > [data-framer-name] {
    max-width: 100%;
  }

  /* Section spacing: 48px between sections. */
  #main .framer-1a7eeg4, #main .framer-evghxu, #main .framer-1sbjqs4, #main .framer-1gecc79,
  #main .framer-jaf476, #main .framer-s6d7vw, #main .framer-exukx3, #main .framer-1k3qkv3, #main .framer-aivkr {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
  }

  /* Images and canvases: fluid width, natural height. */
  #main img, #main canvas, #main video {
    max-width: 100%;
    height: auto;
  }
  /* Project gallery images fill their 16:10 frame (the scroll parallax scales them with transform). */
  #main .pg-frame img { height: 100%; }

  /* Headings: fluid sizes. */
  #main h1 { font-size: clamp(32px, 9vw, 44px); line-height: 1.1; }
  #main h2 { font-size: clamp(24px, 7vw, 32px); line-height: 1.15; }
  #main h3 { font-size: 20px; line-height: 1.3; }

  /* Buttons: at least 44px high. Cards: full width, solid, 20px padding. */
  .ui-btn { min-height: 44px; }
  .ui-card { max-width: 100%; padding: 20px; }

  /* Ambient background: one still frame on phones, no mouse trail. */
  .lc-weave { animation: none !important; }
  .lc-trail { display: none !important; }
}

/* ---------- Header and menu on phones and tablets (step 4) ---------- */
@media (max-width: 1023.98px) {
  /* 64px solid black header. Nav links and the header button move into the menu. */
  #main .framer-1878n9t,
  html.lc-scrolled #main .framer-1878n9t {
    height: 64px !important;
    min-height: 64px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
    background: #000 !important;
    border-bottom: 1px solid #1F1F1F;
  }
  #main .framer-1fwjgun {
    height: 64px !important;
    grid-template-columns: 1fr 44px !important;
    grid-template-rows: 64px !important; /* Framer sets a 44px row, which sat the logo at the top */
    align-items: center !important;
    padding: 0 16px !important;
    max-width: 100% !important;
  }
  #main .framer-1fwjgun > .framer-aq0awj,
  #main .framer-1fwjgun .framer-1vsmq3i-container { display: none !important; }
  #main .framer-1fwjgun > .framer-9gk531 { grid-column: 1; }
  #main .framer-9gk531 * { font-size: 20px !important; }

  /* The menu button: 44px, right side. */
  .lc-menu-btn {
    grid-column: 2;
    justify-self: end;
    position: relative;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #2E2E2E;
    border-radius: 8px;
    background: #0D0D0E;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
  }
  /* Framer pages: the button lives outside Framer's markup, pinned over the 64px header. */
  .lc-menu-btn--float {
    position: fixed;
    top: 10px;
    right: 16px;
    z-index: 101;
  }
  .lc-menu-btn span { display: block; width: 18px; height: 2px; background: #F2F2F2; transition: transform 200ms ease, opacity 200ms ease; }
  .lc-menu-btn.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .lc-menu-btn.is-open span:nth-child(2) { opacity: 0; }
  .lc-menu-btn.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .lc-menu-btn:focus-visible { outline: 2px solid #EC5F22; outline-offset: 2px; }

  /* Full-screen solid black panel under the 64px header. */
  .lc-menu {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 16px max(24px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lc-menu[hidden] { display: none; }
  .lc-menu-links a {
    display: flex;
    align-items: center;
    min-height: 56px;
    font: 500 18px/1.2 "JetBrains Mono", ui-monospace, monospace;
    color: #F2F2F2;
    text-decoration: none;
    border-bottom: 1px solid #1F1F1F;
  }
  .lc-menu-foot .ui-btn { width: 100%; }
  html.lc-menu-open { overflow: hidden; }
}

/* Case-study and privacy headers: 64px, nav replaced by the menu button. */
@media (max-width: 1023.98px) {
  header.cs-top .cs-top-inner, header.top .wrap {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  header.cs-top nav, header.top nav { display: none; }
  header.cs-top, header.top { background: #000; }
}

/* Tap targets (set by mobile-fix.js): at least 44px tall, centred content. */
@media (max-width: 1023.98px) {
  .lc-m-target {
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center;
    box-sizing: border-box;
  }
}

/* Plain text link row under the keyboard (keyboard-scene.js). */
@media (max-width: 1023.98px) {
  .kb-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
}

/* Contact form fields: 44px tall on phones and tablets. */
@media (max-width: 1023.98px) {
  #main input.framer-form-input:not([aria-hidden="true"]):not([tabindex="-1"]),
  #main textarea.framer-form-input {
    min-height: 44px !important;
    height: auto !important;
    box-sizing: border-box;
  }
  #main textarea.framer-form-input { min-height: 120px !important; }
}

/* ---------- Layout-shift reservations (phones and tablets) ---------- */
@media (max-width: 1023.98px) {
  /* Project rows: the image box is fixed at 16:10 before the image loads. */
  #main [data-framer-name="Project row and mobile image"] picture,
  #main [data-framer-name="Project row and mobile image"] img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    height: auto;
    object-fit: cover;
    object-position: center;
  }
  #main [data-framer-name="Project row and mobile image"] {
    min-height: 0;
  }
  /* Small Framer text is set to 14px in CSS, so no script resizes it after first paint. */
  #main [style*="font-size: 10px"], #main [style*="font-size:10px"],
  #main [style*="font-size: 11px"], #main [style*="font-size:11px"],
  #main [style*="font-size: 12px"], #main [style*="font-size:12px"],
  #main [style*="font-size: 13px"], #main [style*="font-size:13px"] {
    font-size: 14px !important;
  }
}

/* Home counters (Building since / Disciplines / Team): three boxes across are too narrow for the
 * labels on phones, so each counter becomes a full-width row: label left, number right.
 * The count-up animation is unchanged. */
@media (max-width: 479.98px) {
  #main [data-framer-name="Company counters"] > div {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  #main [data-framer-name="Company counters"] > div > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
  #main [data-framer-name="Company counters"] > div > div > div {
    min-height: 0 !important;
    margin-top: 0 !important;
  }
}

/* Landscape phones (short screens): the keyboard box fits the screen height, centred. */
@media (max-width: 1023.98px) and (orientation: landscape) and (max-height: 600px) {
  #main .kb-root .kb-3d { aspect-ratio: 16 / 7; max-width: 720px; margin: 0 auto; }
  .kb-3d canvas { width: 100% !important; height: 100% !important; }
}
