/* =====================================================================
   ui-final-fix.css  —  LOADED LAST (see shell.php)
   Fixes:
   1. Text visibility: tables (API docs "Limits & errors"), inline <code>
      chips, notes, help text – theme-aware (uses --rx-* variables)
   2. Mobile: APK / "Install app" card image no longer overlaps heading
   3. Responsive: split layouts, code blocks and tables auto-adjust and
      scroll INSIDE their card instead of being clipped / overflowing
   ===================================================================== */

/* ---------- 0. Safety: nothing may push the page sideways ------------- */
html body #app :is(.split, .split > *, .panel, .content, .workspace, section, article) {
  min-width: 0;
  max-width: 100%;
}
html, body { overflow-x: clip; }

/* ---------- 1. TABLES: always readable, never clipped ------------------ */
html body #app .table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--rx-line, #e7e2d5) !important;
  border-radius: 18px !important;
  background: var(--rx-card, #fff) !important;
}
html body #app .table-wrap table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: auto;
}
html body #app .table-wrap :is(th, td) {
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  vertical-align: top;
  padding: 12px 14px !important;
  line-height: 1.55;
  opacity: 1 !important;
  -webkit-text-fill-color: currentColor !important;
}
html body #app .table-wrap thead th {
  color: var(--rx-accent, #0e7c5a) !important;
  background: var(--rx-soft, #edf7f1) !important;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 11px !important;
}
html body #app .table-wrap tbody td {
  color: var(--rx-ink, #15211b) !important;
  font-size: 14px !important;
}
/* API docs: first column = status codes, keep them bold + visible */
html body[data-page="docs"] #app .table-wrap tbody td:first-child {
  color: var(--rx-accent, #0e7c5a) !important;
  font-weight: 800;
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums;
}
html body #app .table-wrap tbody td small,
html body #app .table-wrap tbody td span:not(.status):not(.badge) {
  color: var(--rx-ink-2, #4d5b53) !important;
}

/* ---------- 2. INLINE <code> chips: visible text, any theme ------------ */
html body #app :not(pre) > code {
  display: inline;
  padding: 2px 8px !important;
  border-radius: 8px !important;
  background: var(--rx-soft, #edf7f1) !important;
  color: var(--rx-ink, #15211b) !important;
  -webkit-text-fill-color: currentColor !important;
  border: 1px solid var(--rx-line, #e7e2d5) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: .9em !important;
  font-weight: 650;
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 1 !important;
  text-shadow: none !important;
}

/* paragraphs/notes inside panels: guarantee readable body text */
html body #app .panel :is(p, li, label) {
  color: var(--rx-ink-2, #4d5b53);
  opacity: 1;
}
html body #app .panel :is(p, li) :is(strong, b) { color: var(--rx-ink, #15211b); }

/* ---------- 3. CODE BLOCKS: scroll inside, never overflow -------------- */
html body #app .code-block {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
html body #app .code-block pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}
html body #app .code-block-head { flex-wrap: wrap; gap: 8px; }

/* ---------- 4. Developer docs layout (two columns -> one on tablet) ---- */
@media (max-width: 1100px) {
  html body #app .split { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------- 5. APK / Install-app banner: photo auto-fits, no overlap --- */
html body #app .app-install-banner {
  overflow: hidden;
}
html body #app .app-install-banner .install-app-art {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  z-index: 0;
}
html body #app .app-install-banner .install-generated-art {
  position: static !important;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}
html body #app .app-install-banner .install-banner-copy,
html body #app .app-install-banner .install-banner-action {
  position: relative;
  z-index: 1;
  min-width: 0;
}
html body #app .app-install-banner .install-banner-copy h2 {
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  html body #app .app-install-banner.app-install-banner {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 16px !important;
    padding: 18px !important;
    border-radius: 26px !important;
  }
  /* the photo keeps its real 3:2 ratio and takes its OWN space in the flow,
     so the title and text always start BELOW it – no overlap */
  html body #app .app-install-banner .install-app-art {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    aspect-ratio: 3 / 2;
    margin: 0 !important;
  }
  html body #app .app-install-banner .install-generated-art {
    object-fit: cover !important;
    background: transparent !important;
  }
  html body #app .app-install-banner .install-banner-copy {
    width: 100%;
    padding: 0 !important;
    margin: 0 !important;
  }
  html body #app .app-install-banner .install-banner-copy h2 {
    font-size: clamp(22px, 6.2vw, 28px) !important;
    line-height: 1.2 !important;
    margin: 6px 0 8px !important;
    color: var(--rx-ink, #15211b) !important;
  }
  html body #app .app-install-banner .install-banner-copy p {
    font-size: 14px !important;
    line-height: 1.7 !important;
    color: var(--rx-ink-2, #4d5b53) !important;
  }
  html body #app .app-install-banner .install-benefits {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px !important;
    font-size: 12.5px !important;
    color: var(--rx-ink-2, #4d5b53) !important;
  }
  html body #app .app-install-banner .install-banner-action {
    width: 100% !important;
    align-items: stretch !important;
  }
  html body #app .app-install-banner .install-banner-action .btn {
    width: 100% !important;
    min-height: 50px;
    justify-content: center;
  }
  html body #app .app-install-banner .install-banner-action small {
    text-align: center;
    display: block;
    margin-top: 8px;
  }

  /* docs/tables on phones */
  html body #app .table-wrap :is(th, td) { padding: 10px 12px !important; }
  html body #app .table-wrap tbody td { font-size: 13px !important; }
}

/* very small phones (<=360px) */
@media (max-width: 360px) {
  html body #app .app-install-banner.app-install-banner { padding: 14px !important; }
  html body #app .app-install-banner .install-app-art { aspect-ratio: 4 / 3; }
}

/* the hero APK page image (full /app page) – same safe behaviour */
html body #app .hxh-app-hero img { max-width: 100%; height: auto; }

/* generic safety: images never overflow their card on any page */
html body #app :is(.panel, .hero, .card, .help-card) img { max-width: 100%; height: auto; }

/* =====================================================================
   PRODUCT CARDS (mobile + desktop) – clipped titles, faded bullets,
   floating button covering "Buy", off-theme purple chip
   ===================================================================== */

/* 6. Title: first letter was cut (C / G / 1) and tops of letters clipped
      because the 2-line clamp had 0 padding + tight line-height. */
html body #app .product .product-title-trigger {
  padding: .14em .18em .14em .16em !important;
  margin: -.14em -.18em -.14em -.16em !important;
  width: calc(100% + .34em) !important;
  line-height: 1.38 !important;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-rendering: optimizeLegibility;
  color: var(--rx-ink, #15211b) !important;
  -webkit-text-fill-color: currentColor !important;
}
html body #app .product .product-title { overflow: visible !important; line-height: 1.38 !important; }

/* 7. Short description bullets: readable colour, 2 clean lines, no half-cut row */
html body #app .product .product-desc {
  max-height: none !important;
  overflow: visible !important;
  color: var(--rx-ink-2, #4d5b53) !important;
}
html body #app .product .product-desc :is(.desc-item, .desc-text) {
  color: var(--rx-ink-2, #4d5b53) !important;
  opacity: 1 !important;
  font-size: 11.5px !important;
  line-height: 1.6 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html body #app .product .product-desc .desc-item:nth-child(n+3) { display: none !important; }
html body #app .product .product-desc .desc-heading { display: none; }

/* 8. Category / filter chips follow the ACTIVE theme (were hard-coded purple) */
html body #app .catalog-toolbar .tabs .tab {
  color: var(--rx-ink, #15211b) !important;
  background: var(--rx-soft, #edf7f1) !important;
  border: 1px solid var(--rx-line, #e7e2d5) !important;
  box-shadow: none !important;
}
html body #app .catalog-toolbar .tabs .tab.active {
  background: linear-gradient(135deg, var(--rx-accent-2, #17a67a), var(--rx-accent, #0e7c5a)) !important;
  border-color: var(--rx-accent, #0e7c5a) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  box-shadow: 0 8px 18px -10px var(--rx-accent, #0e7c5a) !important;
}

/* 9. Back-to-top button: smaller, tucked at the edge, never hides Add/Buy */
@media (max-width: 860px) {
  html body .scroll-to-top-btn {
    width: 40px !important;
    height: 40px !important;
    right: 6px !important;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    opacity: .88;
    z-index: 60 !important;
  }
  html body .scroll-to-top-btn .rocket-icon { width: 18px; height: 18px; }
  html body .scroll-to-top-btn:active { opacity: 1; }
  /* keep Add / Buy buttons inside the card and never overlapping */
  html body #app .product .product-bottom { gap: 8px; flex-wrap: wrap; }
  html body #app .product .product-actions-wrap { display: flex; gap: 8px; width: 100%; }
  html body #app .product .product-actions-wrap .btn {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 10px !important;
    white-space: nowrap;
  }
}


/* =====================================================================
   HxH · Floating pill top bar + sidebar-aware layout  (desktop only)
   1. #app no longer sits in a centred 1240px column while the sidebar is
      fixed at the viewport edge. That column added ~87px of dead space on
      each side and squeezed the page (and cut "Contact") whenever the side
      menu was open. The workspace now uses all the room next to the sidebar.
   2. The top bar is a rounded "cylinder" (pill) behind menu + search + cart.
   3. Menu / search shrink by the width the bar really has, so they stay tidy
      with the side menu open OR collapsed.
   ===================================================================== */
@media (min-width:1001px){
  :root{--hx-gut:clamp(16px,2.2vw,32px);--hx-cmax:1360px}

  html body #app{max-width:none !important;margin:0 !important;padding-left:0 !important;padding-right:0 !important}
  html body #app .workspace{min-width:0}
  html body #app .content{margin-left:auto !important;margin-right:auto !important;max-width:var(--hx-cmax) !important;padding-left:var(--hx-gut) !important;padding-right:var(--hx-gut) !important}

  html body #app .topbar.topbar{
    container-type:inline-size;container-name:hxtop;
    position:sticky !important;top:10px !important;
    width:calc(100% - 2 * var(--hx-gut)) !important;
    max-width:calc(var(--hx-cmax) - 2 * var(--hx-gut)) !important;
    margin:10px auto 0 !important;
    min-height:60px !important;height:auto !important;
    padding:7px 8px 7px 12px !important;
    gap:10px !important;
    border:1px solid var(--rx-line) !important;
    border-radius:999px !important;
    background:var(--rx-card) !important;
    box-shadow:0 18px 40px -28px rgba(15,33,27,.55),0 2px 6px rgba(15,33,27,.05) !important;
  }
  html body #app .topbar .top-nav{align-self:center}
  html body #app .topbar .top-nav a{border-radius:999px !important;padding-left:12px !important;padding-right:12px !important}
  html body #app .topbar .top-nav a::after{display:none !important}
  html body #app .topbar .header-search{flex:0 1 240px !important;min-width:170px}
  html body #app .topbar .top-actions{gap:8px}

  /* Older responsive layers hid the whole menu (<=1100px) or its last links (<=1280px) even though the
     side menu is on screen from 1001px up. Show them again; the container queries below do the trimming. */
  html body #app .topbar .top-nav{display:flex !important}
  html body #app .topbar .top-nav a{display:inline-flex !important}

  /* About / Contact stay visible whenever they fit (old rule hid them under 1240px viewport) */
  html body #app .topbar .top-nav a[href="/about"],
  html body #app .topbar .top-nav a[href="/contact"]{display:inline-flex !important}
  html body #app .topbar .header-search kbd{display:inline-flex !important}

  /* Container queries: react to the bar's own width (sidebar open or collapsed) */
  @container hxtop (max-width:1080px){
    html body #app .topbar .top-nav a{padding-left:9px !important;padding-right:9px !important}
    html body #app .topbar .header-search{flex-basis:190px !important;min-width:150px}
    html body #app .topbar .header-search kbd{display:none !important}
  }
  @container hxtop (max-width:900px){
    html body #app .topbar .top-nav a[href="/about"],
    html body #app .topbar .top-nav a[href="/contact"]{display:none !important}
    html body #app .topbar .header-search{flex-basis:150px !important;min-width:130px}
  }

  /* The side menu is always on screen from 1001px up, so the hamburger is useless here
     (it stole ~50px and left the menu empty on 1001-1100px screens). */
  html body #app .topbar .mobile-toggle{display:none !important}
}
