/* ============================================================
   Ryllo — responsive layer
   ------------------------------------------------------------
   ADDITIVE ONLY. Every rule below lives inside a `max-width`
   media query, so nothing here applies at 1024px and above:
   the desktop layout, spacing, type scale, colours and content
   render exactly as they did before this file existed.

   It works by overriding the inline `style` attributes the page
   already ships with. Because those attributes are re-serialised
   by the runtime (`padding:88px 40px 72px 0` becomes
   `padding: 88px 40px 72px 0px`), each selector is written in
   both spellings.

   Breakpoints and the devices they cover:
     <=1023  iPad Pro 13 portrait edge, Surface Pro 10/7 (912)
     <=900   Asus Zenbook Fold (853), Fold inner screens
     <=820   iPad Mini (768), Z Fold 5/6 inner (748), Galaxy Tab S4 (712)
     <=640   Surface Duo (540), phones in landscape
     <=600   header gap only
     <=520   iPhone 16 Pro Max (440), Pixel 8/9 Pro (448)
     <=445   iPhone 16 (393), Pixel 7-10 (412), iPhone XR (414),
             iPhone Plus / Pro Max (430), Galaxy A55 / S8+ (360)
     <=380   iPhone SE (375), Moto G4 (360), Fold covers (344)
     <=330   JioPhone 2 (240), narrow split-screen panes

   Breakpoints deliberately sit a few px CLEAR of real device widths:
   sub-pixel viewport rounding makes `max-width: 430px` fail on a
   430px iPhone, and `max-width: 768px` fail on a 768px iPad Mini.
   ============================================================ */


/* ============================================================
   1. Safety net + collapse the two-up hero splits
   ============================================================ */
@media (max-width: 1023px) {

  /* `clip` (not `hidden`) so the sticky header keeps working */
  body { overflow-x: clip; }

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

  /* Splits built as repeat(auto-fit, minmax(480px,1fr)) cannot fit
     two tracks here, and the 480px floor overflows below 528px. */
  [style*="minmax(480px"] { grid-template-columns: 1fr !important; }

  /* The copy column carried a right-hand gutter for the split. */
  [style*="padding:88px 40px 72px"],
  [style*="padding: 88px 40px 72px"] { padding: 72px 0 48px !important; }

  [style*="padding:64px 48px 64px"],
  [style*="padding: 64px 48px 64px"] { padding: 56px 0 40px !important; }

  [style*="padding:18px 20px 18px 0"],
  [style*="padding: 18px 20px 18px 0px"] { padding: 18px 20px !important; }

  [style*="padding:16px 20px 16px 0"],
  [style*="padding: 16px 20px 16px 0px"] { padding: 16px 20px !important; }

  /* The image panel that sat beside the copy. */
  [style*="margin:32px 0 32px 24px"],
  [style*="margin: 32px 0px 32px 24px"],
  [style*="margin:32px 24px 32px 0"],
  [style*="margin: 32px 24px 32px 0px"] { margin: 0 0 32px !important; }

  /* Decorative panels: keep the proportion, lose the dead height. */
  [style*="min-height:560px"], [style*="min-height: 560px"] { min-height: 420px !important; }
  [style*="min-height:520px"], [style*="min-height: 520px"] { min-height: 400px !important; }
  [style*="min-height:480px"], [style*="min-height: 480px"] { min-height: 380px !important; }
  [style*="min-height:460px"], [style*="min-height: 460px"] { min-height: 360px !important; }

  /* Sticky article sidebars are unhelpful once the column stacks. */
  .doc-aside { position: static !important; }

  /* The mobile nav panel is positioned at a hard `top: 82px`, which
     assumed an 80px header. Anchor it to the header instead so it
     stays flush at every header height below. */
  header nav[aria-label="Main"] { top: 100% !important; }
}

/* The header collapses to its menu button at 1300px (the full nav no longer
   fits on one line below that), so the dropped-down panel has to be anchored
   to the header all the way up to that width, not just to 1023px. */
@media (max-width: 1300px) {
  header nav[aria-label="Main"] { top: 100% !important; }
}


/* ============================================================
   2. Uneven fr grids go single-column
   ============================================================ */
@media (max-width: 900px) {

  [style*="2.1fr)"],
  [style*="2.2fr)"],
  [style*="1.9fr)"],
  [style*="1.7fr)"],
  [style*="1.4fr)"] { grid-template-columns: 1fr !important; }

  /* Side-by-side panes that assumed a wide viewport. */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* Headings were set `nowrap` because they always fitted on one
     desktop line. Below 900px they have to be allowed to wrap.
     Buttons, pills and nav links keep their nowrap. */
  h1, h2, h3, h4, h5, h6 { white-space: normal !important; }
}


/* ============================================================
   3. iPad Mini portrait / foldable inner screens
   ============================================================ */
@media (max-width: 820px) {

  /* Four across is unreadable at this width; two is not. */
  [style*="repeat(4,"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* Section rhythm, scaled down proportionally. */
  [style*="padding:88px 0"], [style*="padding: 88px 0"] { padding-top: 64px !important; padding-bottom: 64px !important; }
  [style*="padding:80px 0"], [style*="padding: 80px 0"] { padding-top: 60px !important; padding-bottom: 60px !important; }
  [style*="padding:72px 0"], [style*="padding: 72px 0"] { padding-top: 56px !important; padding-bottom: 56px !important; }
  [style*="padding:64px 0"], [style*="padding: 64px 0"] { padding-top: 48px !important; padding-bottom: 48px !important; }
  [style*="padding:72px 24px"], [style*="padding: 72px 24px"] { padding-top: 56px !important; padding-bottom: 56px !important; }
  [style*="padding:56px 0 80px"], [style*="padding: 56px 0px 80px"] { padding: 48px 0 56px !important; }

  /* Generous desktop gaps. */
  [style*="gap:40px"], [style*="gap: 40px"] { gap: 28px !important; }
  [style*="gap:32px"], [style*="gap: 32px"] { gap: 24px !important; }
}


/* ============================================================
   4. Phones in landscape / small tablets
   ============================================================ */
@media (max-width: 640px) {

  /* Three across becomes a stack rather than three slivers. */
  [style*="repeat(3,"] { grid-template-columns: 1fr !important; }

  /* Those trios use vertical rules as dividers — rotate them. */
  [style*="repeat(3,"] > [style*="border-left"] {
    border-left: 0 !important;
    border-top: 1px solid #E4E7EC !important;
    padding: 16px 0 0 !important;
    margin-top: 16px !important;
  }
  [style*="repeat(3,"] > [style*="padding:0 24px"],
  [style*="repeat(3,"] > [style*="padding: 0px 24px"] { padding-left: 0 !important; padding-right: 0 !important; }

  /* Icon + label + body rows: let the body text take a full line. */
  [style*="minmax(120px"] { grid-template-columns: 44px 1fr !important; }
  [style*="minmax(120px"] > :nth-child(3) { grid-column: 1 / -1 !important; }

  /* One button row is pinned `flex-wrap: nowrap`, so its second CTA
     is pushed straight off the page instead of dropping to a new
     line. (Pricing page, "Start free trial / Schedule a demo".) */
  [style*="flex-wrap:nowrap"],
  [style*="flex-wrap: nowrap"] { flex-wrap: wrap !important; }

  /* Card padding. */
  [style*="padding:36px"], [style*="padding: 36px"] { padding: 24px !important; }
  [style*="padding:40px"], [style*="padding: 40px"] { padding: 24px !important; }
  [style*="padding:32px"], [style*="padding: 32px"] { padding: 22px !important; }
  [style*="padding:28px"], [style*="padding: 28px"] { padding: 20px !important; }
}


/* ============================================================
   5. Large phones
   ============================================================ */
@media (max-width: 600px) {

  /* The header row needs logo (239px with the tagline) + 32px gap +
     actions (201px) + 48px gutter = 520px. Reclaiming the gap keeps
     everything, including the "by AccSource" tagline, down to ~520px. */
  header [style*="height:80px"],
  header [style*="height: 80px"] { gap: 12px !important; }
}


@media (max-width: 520px) {

  [style*="repeat(4,"] { grid-template-columns: 1fr !important; }

  /* Below this the tagline has to go, or the CTA is pushed off-screen.
     Note this tier — not a phone-width one — is where the header
     slims down: an iPhone 16 Pro Max (440) and a Pixel 9 Pro (448)
     both need it. */
  header [style*="height:80px"],
  header [style*="height: 80px"] { gap: 10px !important; }

  header a[aria-label="Ryllo home"] img { height: 38px !important; }
  header a[aria-label="Ryllo home"] span { display: none !important; }

  header a[href*="demo"] {
    padding: 10px 12px !important;
    font-size: 13.5px !important;
  }

  /* 340px floor overflows once the gutters are counted. */
  [style*="minmax(340px"] { grid-template-columns: 1fr !important; }

  /* Priced rows: label / value / value. */
  [style*="1fr 84px 70px"] { grid-template-columns: 1fr auto !important; }
  [style*="1fr 84px 70px"] > :nth-child(3) { text-align: right !important; }

  /* The 3D buddy is 132x168 — a third of a phone screen. It keeps
     its behaviour, just at a size that leaves the page readable.
     To switch it off on phones entirely, replace this block with:
       #ryllo-buddy { display: none !important; }                  */
  #ryllo-buddy { width: 96px !important; height: 122px !important; }
  #ryllo-buddy div { max-width: 150px !important; }

  /* Justified text opens rivers at this measure. The
     `:not([style*="text-align"])` guard keeps any paragraph that was
     deliberately centred or right-aligned exactly as it is. */
  article p:not([style*="text-align"]),
  p[style*="ch"]:not([style*="text-align"]),
  [style*="text-align:justify"],
  [style*="text-align: justify"] {
    text-align: left !important;
    text-justify: auto !important;
  }

  [style*="padding:88px 0"], [style*="padding: 88px 0"],
  [style*="padding:80px 0"], [style*="padding: 80px 0"],
  [style*="padding:72px 0"], [style*="padding: 72px 0"] { padding-top: 48px !important; padding-bottom: 48px !important; }
  [style*="padding:64px 0"], [style*="padding: 64px 0"] { padding-top: 40px !important; padding-bottom: 40px !important; }

  [style*="min-height:560px"], [style*="min-height: 560px"],
  [style*="min-height:520px"], [style*="min-height: 520px"],
  [style*="min-height:480px"], [style*="min-height: 480px"],
  [style*="min-height:460px"], [style*="min-height: 460px"],
  [style*="min-height:420px"], [style*="min-height: 420px"],
  [style*="min-height:380px"], [style*="min-height: 380px"],
  [style*="min-height:340px"], [style*="min-height: 340px"] { min-height: 260px !important; }
}


/* ============================================================
   6. Standard phones — iPhone 16, Pixel 9/10, Galaxy A55
   ============================================================ */
@media (max-width: 445px) {

  /* Page gutter. */
  [style*="max-width:1240px"],
  [style*="max-width: 1240px"] { padding-left: 18px !important; padding-right: 18px !important; }

  /* Display type: the clamp floors were tuned for >=768px. */
  [style*="clamp(38px,4.4vw"], [style*="clamp(38px, 4.4vw"] { font-size: clamp(30px, 8.2vw, 38px) !important; }
  [style*="clamp(36px,4.2vw"], [style*="clamp(36px, 4.2vw"] { font-size: clamp(28px, 7.8vw, 36px) !important; }
  [style*="clamp(34px,4vw"],   [style*="clamp(34px, 4vw"]   { font-size: clamp(27px, 7.4vw, 34px) !important; }
  [style*="clamp(32px,3.6vw"], [style*="clamp(32px, 3.6vw"] { font-size: clamp(25px, 7vw, 32px) !important; }
  [style*="clamp(30px,3.4vw"], [style*="clamp(30px, 3.4vw"] { font-size: clamp(24px, 6.6vw, 30px) !important; }
  [style*="clamp(26px,3vw"],   [style*="clamp(26px, 3vw"]   { font-size: clamp(22px, 5.8vw, 26px) !important; }

  /* Pill rows and button rows wrap instead of pushing the page wide. */
  [style*="display:inline-flex"], [style*="display: inline-flex"] { max-width: 100% !important; }
}


/* ============================================================
   7. Smallest supported — iPhone SE (375), foldable covers (344)
   ============================================================ */
@media (max-width: 380px) {

  [style*="max-width:1240px"],
  [style*="max-width: 1240px"] { padding-left: 14px !important; padding-right: 14px !important; }

  header [style*="height:80px"],
  header [style*="height: 80px"] { height: 68px !important; gap: 8px !important; }

  header a[aria-label="Ryllo home"] img { height: 32px !important; }

  header a[href*="demo"] {
    padding: 9px 10px !important;
    font-size: 12.5px !important;
    white-space: nowrap !important;
  }

  header a[href*="signin"] { display: none !important; }

  /* Long single-word CTAs must be allowed to break rather than overflow. */
  h1, h2, h3 { overflow-wrap: break-word !important; }

  [style*="padding:26px"], [style*="padding: 26px"] { padding: 18px !important; }
  [style*="padding:24px"], [style*="padding: 24px"] { padding: 18px !important; }
  [style*="padding:24px 28px"], [style*="padding: 24px 28px"] { padding: 18px 16px !important; }

  [style*="gap:24px"], [style*="gap: 24px"] { gap: 16px !important; }
}


/* ============================================================
   8. Feature phones and split-screen — JioPhone 2 (240x320),
      narrow multi-window panes. Below this width the header
      stops trying to hold everything on one line.
   ============================================================ */
@media (max-width: 330px) {

  [style*="max-width:1240px"],
  [style*="max-width: 1240px"] { padding-left: 10px !important; padding-right: 10px !important; }

  /* Logo on the first line, actions on the second. */
  header [style*="height:80px"],
  header [style*="height: 80px"] {
    height: auto !important;
    flex-wrap: wrap !important;
    row-gap: 8px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  header a[aria-label="Ryllo home"] img { height: 28px !important; }
  header a[href*="demo"] { padding: 8px 10px !important; font-size: 12px !important; }

  /* 96px of mascot on a 240px screen is not a trade worth making. */
  #ryllo-buddy { display: none !important; }

  [style*="clamp(38px,4.4vw"], [style*="clamp(38px, 4.4vw"] { font-size: clamp(23px, 9vw, 30px) !important; }
  [style*="clamp(36px,4.2vw"], [style*="clamp(36px, 4.2vw"] { font-size: clamp(22px, 8.6vw, 28px) !important; }
  [style*="clamp(34px,4vw"],   [style*="clamp(34px, 4vw"]   { font-size: clamp(22px, 8.4vw, 27px) !important; }
  [style*="clamp(32px,3.6vw"], [style*="clamp(32px, 3.6vw"] { font-size: clamp(21px, 8vw, 25px) !important; }
  [style*="clamp(30px,3.4vw"], [style*="clamp(30px, 3.4vw"] { font-size: clamp(20px, 7.6vw, 24px) !important; }
  [style*="clamp(26px,3vw"],   [style*="clamp(26px, 3vw"]   { font-size: clamp(19px, 7vw, 22px) !important; }

  /* Long unbroken words (URLs, product names) must break, not overflow. */
  body { overflow-wrap: break-word !important; }

  /* Icon + text rows lose the icon column. */
  [style*="minmax(120px"] { grid-template-columns: 1fr !important; }
  [style*="minmax(120px"] > :nth-child(3) { grid-column: auto !important; }

  [style*="padding:18px 20px"], [style*="padding: 18px 20px"] { padding: 14px 12px !important; }
  [style*="padding:20px 24px"], [style*="padding: 20px 24px"] { padding: 14px 12px !important; }
  [style*="padding:24px"], [style*="padding: 24px"] { padding: 14px !important; }

  /* Buttons and pills are `inline-flex` + `nowrap`; at 240px a label
     like "Read more about security" cannot fit on one line, so let it
     wrap and trim the horizontal padding that was sized for a phone. */
  [style*="display:inline-flex"],
  [style*="display: inline-flex"] {
    white-space: normal !important;
    max-width: 100% !important;
  }
  a[style*="inline-flex"],
  button[style*="inline-flex"],
  span[style*="inline-flex"] { font-size: 12.5px !important; }

  /* Labels pinned to a fixed pixel box so a set of them lines up —
     the four "Your AI … Specialist" badges are all width:232px, the
     product headings width:246px. Wider than the card at 240px, so
     the pinned sizing is released. Needs BOTH an inline width and
     height, which leaves ordinary buttons and icons alone. */
  [style*="width:"][style*="height:"][style*="text-align:center"],
  [style*="width:"][style*="height:"][style*="text-align: center"],
  [style*="white-space:nowrap"][style*="width:"],
  [style*="white-space: nowrap"][style*="width:"] {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    white-space: normal !important;
  }

  /* Nothing fits on one line here, so every flex row may wrap, and
     flex/grid children may shrink below their content width. */
  /* Row containers only. Wrapping a COLUMN flex container makes its
     items spill into extra columns, which is wider, not narrower. */
  [style*="display:flex"]:not([style*="flex-direction:column"]):not([style*="flex-direction: column"]),
  [style*="display: flex"]:not([style*="flex-direction:column"]):not([style*="flex-direction: column"]) {
    flex-wrap: wrap !important;
  }
  [style*="display:flex"] > *, [style*="display: flex"] > *,
  [style*="display:grid"] > *, [style*="display: grid"] > * { min-width: 0 !important; }

  /* At 240px nothing should be held on one line — including text
     inside a nowrap element, which inherits it. */
  [style*="nowrap"], [style*="nowrap"] * { white-space: normal !important; }

  input, select, textarea { max-width: 100% !important; }
  input[style*="width:70px"], input[style*="width: 70px"] { width: 56px !important; }

  /* Decorative flow connectors drawn outside their column. */
  [style*="right:-13px"], [style*="right: -13px"],
  [style*="position: absolute"][style*="left: calc("],
  [style*="position:absolute"][style*="left:calc("] { display: none !important; }

  [style*="padding:16px 26px"], [style*="padding: 16px 26px"],
  [style*="padding:14px 24px"], [style*="padding: 14px 24px"],
  [style*="padding:14px 22px"], [style*="padding: 14px 22px"],
  [style*="padding:15px 20px"], [style*="padding: 15px 20px"],
  [style*="padding:12px 20px"], [style*="padding: 12px 20px"],
  [style*="padding:12px 16px"], [style*="padding: 12px 16px"],
  [style*="padding:9px 14px"],  [style*="padding: 9px 14px"] {
    padding-left: 11px !important;
    padding-right: 11px !important;
  }
}


/* ============================================================
   9. Short landscape viewports — phones held sideways,
      Nest Hub Max (1280x800). Only trims dead vertical space.
   ============================================================ */
@media (max-height: 560px) and (orientation: landscape) {
  [style*="min-height:560px"], [style*="min-height: 560px"],
  [style*="min-height:520px"], [style*="min-height: 520px"],
  [style*="min-height:480px"], [style*="min-height: 480px"],
  [style*="min-height:460px"], [style*="min-height: 460px"] { min-height: 300px !important; }
}


/* ============================================================
   9. Input and accessibility defaults for touch devices
   ============================================================ */
@media (max-width: 1023px) {
  input, select, textarea { font-size: 16px !important; } /* stops iOS zoom-on-focus */
  a, button { -webkit-tap-highlight-color: rgba(7, 85, 134, .15); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [style*="ryllo-marquee"] { animation: none !important; }
}

/* ============================================================
   10. Team grid (About)
   4 across on desktop, 3 on small laptops, 2 on tablets,
   1 on phones. The avatar shrinks with the card so a face is
   never clipped by a circle that is wider than its column.
   ============================================================ */
@media (max-width: 1120px) {
  #team [data-team-grid] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (max-width: 860px) {
  #team [data-team-grid] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 460px) {
  #team [data-team-grid] { grid-template-columns: 1fr !important; }
}

/* Keep the circle inside its card at every width. */
@media (max-width: 1240px) {
  #team [data-team-avatar] { width: clamp(104px, 20vw, 150px) !important; height: auto !important; }
}


/* ============================================================
   11. "Every job, in order" flow (How it works)
   The connector rule only makes sense while the six steps sit
   three-across. Once the grid wraps, it is dropped.
   ============================================================ */
@media (max-width: 640px) {
  [data-flow-line] { display: none !important; }
}


/* ============================================================
   12. Hero media panel (Index, How it works, Pricing)
   ------------------------------------------------------------
   On desktop the panel stretches to the full height of the copy
   column so there is no dead white space beside the headline.
   Once the hero stacks, a stretched panel has nothing to match,
   so the panel falls back to the picture's own proportions:
     - "contain" heroes (Index) take the image's exact ratio, so
       the whole picture — robot included — is shown with no
       letterboxing at all;
     - "cover" heroes keep a comfortable landscape band.
   ============================================================ */
@media (max-width: 1180px) {

  /* Stack the hero a little earlier than the rest of the page: below this
     width the two columns are too narrow for the picture to stretch to the
     copy height without a deep letterbox. */
  section[data-screen-label="Hero"] > div:first-child { grid-template-columns: 1fr !important; }

  section[data-screen-label="Hero"] > div:first-child > div:first-child {
    padding: 56px 0 40px !important;
  }

  [data-hero-media] {
    align-self: auto !important;
    margin: 0 0 32px !important;
    width: 100%;
  }

  [data-hero-media="cover"] {
    min-height: 0 !important;
    aspect-ratio: 1860 / 845;
  }

  [data-hero-right] { margin: 0 0 32px !important; gap: 20px; }
}

/* The three hero stat boxes stretch to share the column height on desktop.
   Once the hero stacks there is no height to share, so they shrink to their
   own content and tighten up on phones. */
@media (max-width: 1180px) {
  [data-hero-stats] > div { flex: 0 0 auto !important; }
}

@media (max-width: 445px) {
  [data-hero-stats] > div { padding: 14px 16px !important; }
}


/* ============================================================
   13. "Every job, in order" flow (How it works)
   The six steps run three-across on desktop with the connectors
   drawn between them. Below 860px they stack, the right-hand
   gutter that carried the wrap-around is no longer needed, and
   the connector overlay hides itself.
   ============================================================ */
@media (max-width: 860px) {
  [data-flow] { padding-right: 0 !important; }
  [data-flow-row] { grid-template-columns: 1fr !important; }
  [data-flow-svg] { display: none !important; }
}

/* RY-011: the 3D buddy is desktop-only (ryllo-buddy.js also skips loading three.js below 1024px). */
@media (max-width: 1023.98px) {
  #ryllo-buddy { display: none !important; }
}

/* RY-019: on phones the bottom-right corner belongs to the live-chat bubble.
   "Back to top" moves to the bottom-left so the two never stack over content. */
@media (max-width: 767.98px) {
  button[aria-label="Back to top"] { right: auto !important; left: 16px !important; bottom: 16px !important; padding: 10px 14px !important; }
}
