/* ============================================================================
   responsive.css - device-adaptive layout layer for luxechain.si

   Loaded LAST (after luxechain.css and marketing.css) so it can correct rules
   without editing them, and so a future edit to the older files cannot silently
   undo a fix here.

   WHY THIS FILE EXISTS
   An audit of 150 real page loads across 10 device widths (320 → 1440) found
   three classes of real breakage, all of them invisible because
   `html, body { overflow-x: hidden }` CLIPS the overflow instead of showing it.
   Content was being cut off with no scroll affordance at all.

     1. GRID CHILDREN COULD NOT SHRINK. A grid/flex child defaults to
        `min-width: auto`, i.e. "never narrower than my widest content". The
        hero code card is 430px wide, so on a 390px phone the hero column was
        forced to 601px and every child overflowed by 301px. marketing.css had
        ZERO `min-width: 0` declarations. This is the root cause of most of the
        breakage, including the pricing and status tables.

     2. TABLES KEPT THEIR DESKTOP MIN-WIDTH inside a card whose inline
        `overflow:hidden` clipped them, so columns were unreachable.

     3. iOS ZOOMED THE PAGE ON EVERY FORM FOCUS. Fields were 15px; Safari zooms
        any input below 16px, so the visitor got a zoomed, mis-aligned page the
        moment they tapped "Your name".

   Breakpoints follow real devices, not arbitrary numbers:
       320  iPhone SE (1st gen) / smallest Android
       360  the most common Android CSS width
       390  iPhone 12–15
       430  iPhone Pro Max
       600  large phone landscape / small tablet portrait
       768  iPad Mini portrait
       834  iPad Air portrait
       1024 iPad Pro portrait / small laptop
   ========================================================================== */

/* ---------------------------------------------------------------- 1. shrink */
/* The single highest-value rule in this file. Without it, one wide child (a
   <pre>, a table, a long token, a fixed-width card) drags its whole grid column
   past the viewport. Applying it broadly is safe: min-width:0 only removes the
   automatic "never smaller than content" floor, it does not force anything to
   be narrow. */
.hero-grid > *,
.m-hero-grid > *,
.m-split > *,
.m-code-split > *,
.m-grid > *,
.m-plan-grid > *,
.plans > *,
.tgrid > *,
.g2 > *,
.g3 > *,
.g4 > *,
.g5 > *,
.stats > *,
.foot-grid > *,
.m-foot-grid > *,
.logostrip > *,
.fgrid > *,
.row,
.m-row {
  min-width: 0;
}

/* The code shells wrap a <pre> that is intrinsically as wide as its longest
   line. Inside a grid column that cannot shrink, one long line stretched the
   whole page. `overflow-x: auto` on the <pre> already provides the scroll, so
   the shell itself must be allowed to be narrow. */
.m-code-shell,
.m-codecard,
.m-code-shell pre,
.m-codecard pre {
  min-width: 0;
  max-width: 100%;
}

/* Long unbroken strings (API keys, base URLs, model ids) must wrap rather than
   push a column wide. `anywhere` is used only where a break is genuinely
   allowed mid-token. */
.m-hero-title,
.m-hero-sub,
.m-card,
.tcard,
.pill,
.mtag {
  overflow-wrap: break-word;
}
.m-hero-title { hyphens: none; }

/* ------------------------------------------------------------- 2. containers */
/* Padding that scales with the viewport instead of a fixed 28px that eats 18%
   of a 320px screen. */
@media (max-width: 620px) {
  .wrap,
  .wrap-narrow { padding-left: 18px; padding-right: 18px; }
  body.public .wrap { padding-left: 18px; padding-right: 18px; }
  .m-wrap { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 380px) {
  .wrap,
  .wrap-narrow { padding-left: 14px; padding-right: 14px; }
  body.public .wrap { padding-left: 14px; padding-right: 14px; }
  .m-wrap { padding-left: 14px; padding-right: 14px; }
}

/* ---------------------------------------------------------------- 3. hero */
/* The headline was clamp(38px, 11vw, 52px). At 320px that is 35px across two
   long lines, which no longer fits once the copy column is correctly shrunk.
   Two extra steps keep it readable without overflowing. */
@media (max-width: 430px) {
  .m-hero-title { font-size: clamp(30px, 8.6vw, 40px); letter-spacing: -0.035em; }
  .m-hero-sub { font-size: 15px; line-height: 1.65; }
  .hero h1 { font-size: clamp(1.7rem, 7.4vw, 2.1rem); }
}

@media (max-width: 360px) {
  .m-hero-title { font-size: clamp(27px, 8.4vw, 33px); }
  .hero h1 { font-size: clamp(1.55rem, 7.2vw, 1.9rem); }
  .m-hero { padding: 38px 0 34px; }
}

/* Stat strip: 4 columns never fit under 430px. Two columns with the dividers
   removed on the right edge reads cleanly. */
@media (max-width: 430px) {
  .m-stats { grid-template-columns: 1fr 1fr; row-gap: 16px; }
  .m-stat:nth-child(2n) { border-right: 0; padding-right: 0; }
  .m-stat:nth-child(n+3) { border-top: 1px solid var(--border); padding-top: 14px; }
}

/* CTA buttons go full width on a phone: a 50/50 split leaves two cramped
   targets, and the primary action should be unmissable. */
@media (max-width: 520px) {
  .m-actions { flex-direction: column; align-items: stretch; }
  .m-actions .btn { width: 100%; }
}

/* -------------------------------------------------------------- 4. marquee */
/* The track is `width: max-content` (correct for the animation) but nothing
   contained it, so it measured 4321px and was the single largest "overflow" in
   the audit. `overflow:hidden` + `max-width:100%` keeps the animation and stops
   the geometry leaking into the page. `contain: paint` also stops it forcing
   layout work on the whole document. */
.m-marquee {
  max-width: 100%;
  overflow: hidden;
  contain: paint;
}
.m-marquee-track { max-width: none; }

/* --------------------------------------------------------------- 5. tables */
/* A table must never be clipped without a way to reach the hidden columns.
   The wrapper scrolls; the card must NOT also clip it. */
.tbl-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Inline `overflow:hidden` on a card that hosts a table defeats the wrapper. */
.m-card:has(.tbl-wrap),
.card:has(.tbl-wrap) { overflow: visible; }

@media (max-width: 820px) {
  /* Keep a readable minimum but let the wrapper scroll to it. 520px fits the
     Model + 2 plan columns; 600px clipped the third on a 320px screen. */
  .tbl-wrap .tbl { min-width: 480px; }
  .tbl-wrap .tbl th,
  .tbl-wrap .tbl td { white-space: nowrap; }
  /* The empty-state row must wrap: nowrap clipped sentences mid-word. */
  .tbl-wrap .tbl td[colspan] { white-space: normal; }
}

@media (max-width: 430px) {
  .tbl-wrap .tbl { min-width: 440px; font-size: 13px; }
  .tbl-wrap .tbl th,
  .tbl-wrap .tbl td { padding-left: 10px; padding-right: 10px; }
}

/* A visible affordance that the table scrolls sideways. Without it the user
   sees a table that appears to end at the screen edge. */
@media (max-width: 820px) {
  .tbl-wrap::after {
    content: "";
    position: sticky;
    right: 0;
    top: 0;
    float: right;
    width: 26px;
    height: 100%;
    margin-left: -26px;
    background: linear-gradient(to right, transparent, var(--card, #fff));
    pointer-events: none;
  }
}

/* --------------------------------------------------- 6. touch ergonomics */
/* 44px is the Apple HIG minimum and Google's recommended minimum. Applies to
   coarse pointers (fingers) so a desktop mouse layout is untouched. */
@media (pointer: coarse) {
  .btn,
  .btn-sm,
  button,
  [role="button"],
  input[type="submit"],
  input[type="button"],
  .cart-btn,
  .nav-burger,
  .ccy-btn,
  .tab,
  .luxechain-bot-launch {
    min-height: 44px;
  }

  /* Small icon-only buttons need a real hit area even if the glyph is small. */
  .cart-btn,
  .nav-burger {
    min-width: 44px;
    justify-content: center;
  }

  /* The wordmark is a link home; give it a comfortable tap height without
     changing its visual size. */
  .lx-logo { min-height: 44px; align-items: center; }

  /* Comfortable row height on tappable list rows and FAQ summaries. */
  .faq summary,
  .m-acc summary,
  .mobile-menu a { min-height: 44px; }

  /* ---------- 7. stop iOS Safari zooming on focus ----------
     Safari zooms the page whenever a focused field is under 16px, and it does
     NOT zoom back out on blur. Every field on the site was 15px, so tapping the
     first input on the contact form left the visitor on a zoomed, sideways page.
     16px is the documented threshold; 16.5px gives a little headroom against
     sub-pixel rounding. */
  input[type="text"],
  input:not([type]),
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="url"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea {
    font-size: 16.5px;
  }
}

/* Range sliders and checkboxes are not text fields - iOS does not zoom on them,
   but they still need a finger-sized control. */
@media (pointer: coarse) {
  input[type="range"] { min-height: 44px; }
  input[type="checkbox"],
  input[type="radio"] { width: 22px; height: 22px; }
}

/* textarea has its OWN `font-size: 13.5px` in luxechain.css (it is monospace by
   design). That rule is later in the cascade than the generic field rule above,
   so the zoom fix missed every message box - including the contact form, which
   is the one field a customer is most likely to tap first. 16.5px with the mono
   stack keeps the "code-ish" feel while staying above Safari's zoom threshold. */
@media (pointer: coarse) {
  textarea {
    font-size: 16.5px;
    line-height: 1.55;
  }
}

/* ------------------------------------------------------------ 8. tool cards */
/* A tool card is icon + name + tag pills. The pill row could not wrap, so on a
   320px screen the card's min-content was 69px wider than the screen. */
@media (max-width: 430px) {
  .tgrid { grid-template-columns: 1fr; }
  .tcard { padding: 18px 16px; }
  .mtag { white-space: normal; }
  .tcard .pills,
  .tcard .tags { flex-wrap: wrap; }
}

/* ------------------------------------------------------------- 9. footer */
/* Four link columns become two below 768, and one below 400 - at 320px the
   address `hello@luxechain.si` needs a full column or it wraps mid-address. */
@media (max-width: 768px) {
  .foot-grid { grid-template-columns: 1fr 1fr; gap: 26px; }
  .foot-brand { grid-column: 1 / -1; }
}

@media (max-width: 400px) {
  .foot-grid { grid-template-columns: 1fr; gap: 22px; }
  .foot-brand { grid-column: auto; }
  .foot-legal { gap: 10px 14px; }
  .foot-mail,
  .contact-mail { overflow-wrap: anywhere; }
}

/* ------------------------------------------------------- 10. status pills */
/* Pills are nowrap by design (a label should not break) but the status table's
   pill column was pushing the row wide. The table now scrolls, so this only
   needs to cap the padding on small screens. */
@media (max-width: 430px) {
  .pill { padding-left: 8px; padding-right: 8px; font-size: 11.5px; }
}

/* --------------------------------------------- 11. tablet-specific tuning */
/* Portrait tablets (768–834) have plenty of width but short height and coarse
   pointers. Two-column grids read better than three, and the hero should stack
   rather than squeeze two 380px columns into 768. */
@media (min-width: 700px) and (max-width: 1024px) {
  .m-grid.models { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* NOT .m-plan-grid: it holds exactly 3 cards, and a 2-column track leaves the
     third alone beside a dead column. It keeps 3 across this whole range
     (measured 232px at 768px - enough for price + feature list). */
  .tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------- 11b. plan + trust card stacks */
/* THE WORST BREAKAGE FOUND. At 320px the three pricing cards were still three
   columns - roughly 80px each - so the price, the feature list and the button
   were compressed into an unreadable sliver. `.m-plan-grid` had NO phone rule:
   the only collapse in the file was `.m-plan-grid.m-trust` at 900px, which does
   not match a plain `.m-plan-grid`. The trust cards (`.m-trust`, 3 columns) had
   no rule at all below desktop. Both now stack. */
@media (max-width: 900px) {
  .m-plan-grid { grid-template-columns: 1fr; }
  .m-trust { grid-template-columns: 1fr; }
}

/* Two-up is better than one-up on a wide-ish phone / small tablet - BUT a
   3-card grid in 2 columns leaves the third card alone on its own row with a
   dead column beside it, which reads as broken rather than deliberate. So the
   tablet range uses THREE columns (measured: 232px per card at 768px, which
   fits a plan card's price + feature list) and everything narrower stacks. */
@media (min-width: 701px) and (max-width: 900px) {
  .m-plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .m-trust { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .m-plan-grid { grid-template-columns: 1fr; }
  .m-trust { grid-template-columns: 1fr; }
}

/* A featured plan is reordered to the top when stacked, so the paid option is
   not buried under two others on a phone. */
@media (max-width: 900px) {
  .m-plan.featured { order: -1; }
}

/* The dashboard mock's 3 KPI columns and the payment comparison are the same
   problem: fixed column counts that never collapse. */
@media (max-width: 560px) {
  .m-dash-kpis { grid-template-columns: 1fr; }
  .m-dash-kpis div { border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 14px; }
  .m-dash-kpis div:last-child { border-bottom: 0; }
}

/* Footer: four link columns plus the brand column cannot survive a phone. */
@media (max-width: 620px) {
  .m-foot-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .m-foot-brand { grid-column: 1 / -1; }
}

@media (max-width: 400px) {
  .m-foot-grid { grid-template-columns: 1fr; gap: 20px; }
  .m-foot-brand { grid-column: auto; }
}

/* A short landscape phone (e.g. 844x390 rotated) has very little height; the
   full-height chat panel and tall hero padding waste it. */
@media (max-height: 480px) and (orientation: landscape) {
  .m-hero { padding: 30px 0 28px; }
  .hero { padding: 30px 0 24px; }
  .luxechain-bot-panel { height: 100dvh; }
}

/* ------------------------------------------- 13. forms vs. the chat widget */
/* The chat launcher is a fixed 52px circle pinned bottom-right (z-index 90), so
   it floats over whatever happens to be there. On a phone it landed on the
   message textarea on /contact - the one field a customer types the most into,
   with the send button right underneath it. Reserve foot room on any page that
   ends in a form so the last field and its button can always scroll clear. */
@media (max-width: 860px) {
  form.stack,
  form.form,
  .card form,
  main form {
    scroll-margin-bottom: 84px;
  }
  /* Give the form card itself breathing room under its submit button. */
  form.stack { padding-bottom: 8px; }
  .contact-page-foot-pad { padding-bottom: 84px; }
}

/* ------------------------------------------------- 12. safety net, last */
/* Anything still wider than the screen gets a horizontal scroll on its own
   container instead of being silently clipped by body overflow-x:hidden. This
   is a backstop, not a fix - the rules above are the fixes. */
@media (max-width: 1024px) {
  .m-hero,
  .hero,
  .m-section,
  section { max-width: 100%; }
}
