/* ============================================================
   05 · TOUCH & SMALL SCREENS
   Loads LAST so it can correct earlier rules without raising
   specificity anywhere else.

   ---- THE RULE THIS FILE FOLLOWS ----
   The phone must show the SAME site as the desktop: same sections,
   same copy, same 3D, same order. Nothing here hides a section or
   swaps in a "mobile version". Every block is gated behind one of

     (pointer:coarse)      finger, not mouse
     (hover:none)          no hover state exists
     (max-height:...)      landscape phones / short windows

   so a desktop browser never matches any of it, and its rendering
   is exactly what it was before this file existed.

   The layout itself was already fluid — measured at 375px there
   was zero horizontal overflow on every page type. What was
   missing was touch ergonomics, iOS safe areas, and landscape
   headroom.
   ============================================================ */


/* ------------------------------------------------------------
   1 · SAFE AREAS  (iPhone notch / home indicator)

   Every page ships viewport-fit=cover, which lets the background
   paint into the notch and home-indicator strips. That is what we
   want for the dark 3D backdrop, but text and tap targets have to
   stay out of them — held sideways, the notch covers ~44px of one
   edge. max() keeps the existing padding wherever it is already
   the larger of the two, so nothing shrinks.
   ------------------------------------------------------------ */
@supports (padding:max(0px)){
  .wrap{
    padding-left:max(clamp(24px,6vw,72px), env(safe-area-inset-left));
    padding-right:max(clamp(24px,6vw,72px), env(safe-area-inset-right));
  }
  #nav .in{
    padding-left:max(clamp(20px,9vw,144px), env(safe-area-inset-left));
    padding-right:max(clamp(20px,9vw,144px), env(safe-area-inset-right));
  }
  .scene{
    padding-left:max(clamp(24px,9vw,144px), env(safe-area-inset-left));
    padding-right:max(clamp(24px,9vw,144px), env(safe-area-inset-right));
  }
  #mobmenu{
    padding-left:max(clamp(24px,8vw,60px), env(safe-area-inset-left));
    padding-right:max(clamp(24px,8vw,60px), env(safe-area-inset-right));
    padding-bottom:env(safe-area-inset-bottom);
  }
  .foot{padding-bottom:max(40px, env(safe-area-inset-bottom))}
}


/* ------------------------------------------------------------
   2 · VIEWPORT-UNIT FALLBACK

   100svh — the viewport measured with the browser chrome showing
   — is the right unit for the sticky stages: it can never be
   taller than what the visitor can actually see, so a scene never
   hides its own bottom edge behind the URL bar. It needs iOS 15.4
   / Chrome 108 though, and a browser that does not know `svh`
   drops the whole declaration and falls back to height:auto,
   which collapses the sticky stack into a normal scroll. The vh
   lines below are only ever read by those older browsers.
   ------------------------------------------------------------ */
.scene{height:100vh;height:100svh}
.sp-hero{min-height:100vh;min-height:100svh}


/* ------------------------------------------------------------
   3 · TAP TARGETS  (pointer:coarse only)

   Measured on a 375px viewport: footer column links were 21px
   tall, the legal bar 16px, breadcrumbs 14px, the "remember me"
   checkbox 13px. WCAG 2.2 asks for 24px minimum; 44px is the size
   a thumb actually hits first time.

   These are fixed with an invisible ::after overlay rather than
   with padding, so NOTHING MOVES. The text keeps its exact
   position and the footer keeps its exact height — only the
   region that responds to a finger grows.

   The overlays of two stacked links do overlap: the footer list
   has a 33px pitch and each overlay is 43px tall. That is fine
   and in fact wanted — the later sibling paints on top, so the
   shared strip belongs to the lower link and the column is
   partitioned with no dead gaps between rows. Measured result:
   every footer link answers to a band ~54px tall (was 21px), and
   the legal bar ~67px (was 16px).
   ------------------------------------------------------------ */
@media (pointer:coarse){

  /* footer link columns — 21px tall, 12px apart */
  .foot-cols a{position:relative}
  .foot-cols a::after{content:'';position:absolute;inset:-11px -10px}

  /* footer legal bar — 16px tall */
  .foot-legal a{position:relative;display:inline-block}
  .foot-legal a::after{content:'';position:absolute;inset:-14px -10px}

  /* breadcrumbs, on every sub-page — 14px tall */
  .crumb a{position:relative;display:inline-block}
  .crumb a::after{content:'';position:absolute;inset:-15px -8px}

  /* social + contact links (footer and contact page) */
  .sociallink{position:relative}
  .sociallink::after{content:'';position:absolute;inset:-12px -8px}

  /* "Forgot password?" / "Sign up" / "Sign in" inline links */

  /* the legal line under the sign-up form — "Terms", "Privacy" at 15px */

  /* Contact details written as inline links inside a paragraph — the phone,
     e-mail and WhatsApp rows on the contact page, ~19px tall. Matched by
     protocol rather than by class because they are plain <a> tags with an
     inline colour and nothing else. Anything already wearing .btn is 43px
     and is left alone. */
  a[href^="mailto:"]:not(.btn):not(.sociallink),
  a[href^="tel:"]:not(.btn):not(.sociallink),
  a[href^="https://wa.me"]:not(.btn):not(.sociallink),
  a[href*="instagram.com"]:not(.btn):not(.sociallink){
    position:relative;display:inline-block;
  }
  a[href^="mailto:"]:not(.btn):not(.sociallink)::after,
  a[href^="tel:"]:not(.btn):not(.sociallink)::after,
  a[href^="https://wa.me"]:not(.btn):not(.sociallink)::after,
  a[href*="instagram.com"]:not(.btn):not(.sociallink)::after{
    content:'';position:absolute;inset:-13px -8px;
  }

  /* the header wordmark, which is also the link home — 29px tall */
  #nav .brand{position:relative}
  #nav .brand::after{content:'';position:absolute;inset:-9px -8px}

  /* the checkbox itself, which an overlay cannot fix. The <label> wrapping
     it is the real target and is forced to 44px above; this just stops the
     box being a 13px speck next to 16px text. */
  .checkbox{min-height:44px}
  .checkbox input[type="checkbox"]{width:20px;height:20px;flex:0 0 auto}

  /* header account button — 38px, just under the threshold */

  /* kill the 300ms double-tap-to-zoom wait on everything clickable */
  a,button,input,select,textarea,label,[role="button"]{touch-action:manipulation}

  /* the grey box iOS flashes over a tapped link — every component
     below has its own :active state, which reads better than it */
  a,button,[role="button"]{-webkit-tap-highlight-color:transparent}

  /* form fields at 16px or larger, or iOS zooms the page in when
     one is focused and leaves it zoomed */
  .field input,input,select,textarea{font-size:16px}
}


/* ------------------------------------------------------------
   4 · NO HOVER

   On iOS a :hover state latches after a tap and stays until the
   visitor taps somewhere else — so a link that slides sideways on
   hover stays slid, and a button that lifts stays lifted. The
   reveal-on-hover cases (.srow .desc, .case .view, .tile .arw)
   are already handled in their own stylesheets; these are the
   movement-only ones left over, swapped for :active so a tap
   still gives feedback.
   ------------------------------------------------------------ */
@media (hover:none){
  .foot-cols a:hover{transform:none;color:var(--dim)}
  .foot-cols a:active{color:#fff}
  .btn.solid:hover,.btn.ghost:hover,.btn.line:hover,.btn.wa:hover{transform:none;gap:12px}
  .btn.solid:active{background:var(--b100)}
  .btn.ghost:active{border-color:var(--b300)}
  .btn.line:active{background:var(--b50);border-color:var(--navy)}
  #nav .cta:hover{transform:none}
  .srow:hover .arw{transform:none}
  .case:hover .res em{transform:none}
  .rel-card:hover{transform:none}
}


/* ------------------------------------------------------------
   5 · VERY NARROW SCREENS  (iPhone SE and similar, 320px)

   At 375px every page measured zero horizontal overflow. At 320px
   the footer pushed 22px past the edge, and the cause was a single
   element: the address nexoraittech@gmail.com is 164px of
   unbreakable text sitting in a footer column that is only 126px
   wide once the grid halves. body{overflow-x:hidden} was hiding
   the symptom — the viewport clipped it, so there was no scrollbar
   — but the text itself was cut off mid-address.

   Below 360px the footer therefore drops to a single column, which
   gives the address the full content width and leaves it readable.
   overflow-wrap is a standing guard so that no future long token
   (a URL, a long service name in Malay) can do this again.
   ------------------------------------------------------------ */
@media (max-width:360px){
  .foot-cols{grid-template-columns:1fr;gap:28px}
}
.foot-cols a,.foot-legal a,.crumb a{overflow-wrap:anywhere}


/* ------------------------------------------------------------
   6 · MOBILE MENU IN LANDSCAPE

   The panel centres its links inside a fixed full-height box. On
   a phone held sideways (~360px tall) the five links, the CTA and
   the language row measure 456px, so the bottom two rows were
   unreachable — overflow was visible, so there was nothing to
   scroll. overscroll-behavior:contain stops the scroll chaining
   through to the page underneath once the panel hits its end.
   ------------------------------------------------------------ */
@media (max-height:620px){
  #mobmenu{
    justify-content:flex-start;overflow-y:auto;-webkit-overflow-scrolling:touch;
    padding-top:calc(clamp(66px,8vw,86px) + 16px);padding-bottom:32px;
    overscroll-behavior:contain;
  }
  #mobmenu a{font-size:clamp(21px,5.4vh,30px);padding:9px 0}
  #mobmenu .mcta{margin-top:18px;padding:14px}
  #mobmenu .mlang{margin-top:18px}
}


/* ------------------------------------------------------------
   7 · HERO IN LANDSCAPE

   hero/scenes.css already tightens the rhythm below 820px tall.
   Below ~560px — a phone on its side — even that is not enough:
   scene 1 measured 300px of copy into 192px of room, which pushed
   "Start a project" off the bottom of the screen.

   The stat row is what gets dropped, because it is the only block
   in the hero whose information appears again further down the
   page: the capability count, the industry count and the language
   count each have their own section. The headline, the lead and
   both buttons stay.
   ------------------------------------------------------------ */
@media (max-height:560px){
  .scene{padding-top:calc(clamp(56px,12vh,72px) + 8px);padding-bottom:28px}
  .scene h1{margin:8px 0 10px}
  #stage3d h2{margin:6px 0 8px}
  .scene .lead{font-size:14px;line-height:1.5}
  .scene .btns{margin-top:16px;gap:10px}
  .scene .stats{display:none}
  .cue{display:none}
}

/* Shorter still: the lead paragraph is the next thing to give. The threshold
   is 340px rather than the 440px I first set — measured at 740x360 the copy
   came to 219px inside 268px of room, so a normal landscape phone keeps its
   lead. This only fires on the genuinely tiny (a split-screen pane, or a
   phone in landscape with the keyboard up). */
@media (max-height:340px){
  .scene .lead{display:none}
}


/* ------------------------------------------------------------
   8 · SERVICE / INDUSTRY 3D HERO IN LANDSCAPE
   The display headline is sized off vw (up to 10.5vw), which on
   an 844px-wide landscape phone is 89px — three lines inside a
   360px box. The vh ceilings below bound it the same way
   hero/scenes.css bounds the homepage h1.
   ------------------------------------------------------------ */
@media (max-height:560px){
  .sp-hero{padding-top:calc(clamp(56px,12vh,72px) + 20px);padding-bottom:40px}
  .sp-hero h1{font-size:min(clamp(42px,10.5vw,164px),19vh);margin-top:14px}
  .sp-rotator{font-size:min(clamp(30px,6.4vw,96px),12vh)}
  .sp-hero .lead{margin-top:16px;font-size:14.5px;line-height:1.5}
  .sp-hero .btns{margin-top:18px}
  .sp-cue{display:none}
}
