/* Scripts page: smoother on phones + slightly smaller posts. Loaded last.
   Card design (colours, radius, badges, layout) is unchanged. Only motion, blur and spacing are tuned. */

/* ---------- 1. SMOOTH SCROLLING (phones / touch) ---------- */
@media (max-width: 760px), (hover: none) {
  /* No blur layers over a scrolling list: solid colour instead (same tint) */
  .site-header, .tabbar, #toast { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .site-header { background: #fcfaff !important; }
  .tabbar { background: rgba(251,249,255,.98) !important; }

  /* Tap = no sticky hover jump */
  #view-scripts .ig-post, #view-scripts .sc, #view-scripts .arr-card { transition: none !important; }
  html body #view-scripts #cards > .ig-post:hover, html body #view-scripts #cards > .ig-post:not(.is-anime):not(.is-excl):hover,
  #view-scripts .sc:hover, #view-scripts .arr-card:hover { transform: none !important; }

  /* Scroll behaviour */
  html { -webkit-text-size-adjust: 100%; }
  #view-scripts, #view-scripts button, #view-scripts a, #view-scripts select, #view-scripts [role="button"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  #view-scripts .arr-row, #view-scripts .chips { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
  #view-scripts .arr-row > * { scroll-snap-align: start; }

  /* Cheaper paint: lighter shadow on normal posts (New/Updated glow cards are left exactly as before) and a realistic placeholder height so the page does not jump while scrolling */
  #view-scripts #cards > .ig-post:not(.is-hot) { box-shadow: 0 6px 18px -12px rgba(76,29,149,.35) !important; }
  #view-scripts #cards > .ig-post { contain-intrinsic-size: auto 370px; }
}

/* ---------- 2. SMALLER POSTS (phones) ---------- */
@media (max-width: 760px) {
  #view-scripts #cards  { gap: 10px !important; }
  html:root:root body #view-scripts #cards > .ig-post  { border-radius: 18px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-head  { padding: 10px 12px 2px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-head .avatar  { width: 30px !important; height: 30px !important; font-size: 13px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-who  { font-size: 13.5px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-title  { padding: 4px 12px 8px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-title h3  { font-size: 15px !important; line-height: 1.3 !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-desc  { font-size: 12.5px !important; line-height: 1.45 !important; display: -webkit-box; -webkit-line-clamp: 2 !important; -webkit-box-orient: vertical !important; overflow: hidden !important; margin-top: 3px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-media  { max-height: 88px !important; overflow: hidden !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-media pre  { padding: 9px 12px !important; font-size: 11px !important; line-height: 1.5 !important; max-height: 88px !important; overflow: hidden !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-media.bin  { height: 88px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-dlbtn  { margin-top: 8px !important; padding: 9px 14px !important; font-size: 13px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-acts  { margin-top: 2px !important; padding: 3px 6px 0 !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-acts .pact  { padding: 6px 8px !important; }
  html:root:root body #view-scripts #cards > .ig-post .cstats  { padding: 0 12px 6px !important; font-size: 12px !important; }
  html:root:root body #view-scripts #cards > .ig-post .ig-tags  { padding: 0 12px 10px !important; font-size: 12.5px !important; }
}
/* ---------- 3. CLEANER, EASIER PAGE CHROME (cards untouched) ---------- */
/* Language filter was hidden by an older theme rule: bring it back as one tidy scrolling row */
html:root:root body #view-scripts #chips.chips { display: flex !important; flex-wrap: nowrap !important; gap: 8px !important; overflow-x: auto !important; overflow-y: hidden !important; scrollbar-width: none; margin: 4px 0 12px !important; padding: 2px 0 4px !important; }
html:root:root body #view-scripts #chips.chips::-webkit-scrollbar { display: none; }
html:root:root body #view-scripts #chips .chip { flex: 0 0 auto !important; white-space: nowrap !important; height: 34px; padding: 0 14px; display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; border-radius: 999px; }

@media (max-width: 760px) {
  /* one compact toolbar row: count on the left, sort + New on the right */
  html:root:root body #view-scripts .sc-tools { display: flex !important; flex-wrap: nowrap !important; align-items: center; gap: 8px !important; margin: 0 0 6px !important; padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; }
  html:root:root body #view-scripts .sc-tools .sc-count { display: none !important; } /* "All (40)" chip already shows the total */
  html:root:root body #view-scripts .sc-tools { justify-content: space-between; }
  html:root:root body #view-scripts .sc-tools .spacer { flex: 1 1 auto; }
  html:root:root body #view-scripts .sc-tools .sc-sort { display: block !important; flex: 0 0 auto !important; width: auto !important; min-width: 0; margin: 0; }
  html:root:root body #view-scripts .sc-tools select#sort { flex: none !important; display: block !important; width: 150px !important; height: 36px !important; min-height: 0 !important; max-width: 150px; padding: 0 28px 0 12px !important; font-size: 13px !important; border-radius: 10px !important; }
  html:root:root body #view-scripts .sc-tools #newOnly { flex: 0 0 auto !important; width: auto !important; max-width: none !important; height: 36px !important; min-height: 0 !important; padding: 0 12px !important; font-size: 13px !important; white-space: nowrap; }

  /* New arrivals: same cards, much less chrome, so posts start higher on screen */
  html:root:root body #view-scripts .arrivals { padding: 0 !important; margin: 4px 0 12px !important; background: none !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  html:root:root body #view-scripts .arrivals .arr-head { margin: 0 0 8px !important; padding: 0 !important; align-items: center; }
  html:root:root body #view-scripts .arrivals .arr-head h2 { font-size: 15px !important; }
  html:root:root body #view-scripts .arrivals .arr-head > span { display: none !important; }
  html:root:root body #view-scripts .arrivals .arr-row { gap: 10px !important; padding-bottom: 4px; }
  html:root:root body #view-scripts .arrivals .arr-card { flex: 0 0 min(78%, 270px) !important; width: min(78%, 270px) !important; }

  /* breathing room: last post never hides under the tab bar */
  #view-scripts { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- 4. Scripts page search box hidden ---------- */
html:root:root body #view-scripts .sx-search, html:root:root body #view-scripts #scSearch { display: none !important; }

/* ---------- 5. Messages icon back in the phone header (an older "uncluttered header" rule had hidden it, leaving no way to reach Chats on mobile) ---------- */
@media (max-width: 760px) {
  html:root:root body .site-header .bar-actions .msg-top { display: grid !important; place-items: center; order: 1; position: relative; width: 42px !important; height: 42px !important; border: 1px solid #eee4ff !important; border-radius: 50% !important; background: #ffffff !important; color: #52299f !important; box-shadow: none !important; }
  html:root:root body .site-header .bar-actions .msg-top svg { width: 21px !important; height: 21px !important; }
  html:root:root body .site-header .bar-actions .mobile-alerts { order: 2; }
  html:root:root body .site-header .bar-actions .mobile-profile { order: 3; }
}
@media (max-width: 360px) {
  html:root:root body .site-header .bar-actions { gap: 6px !important; }
  html:root:root body .site-header .bar-actions .msg-top, html:root:root body .site-header .bar-actions .mobile-alerts { width: 38px !important; height: 38px !important; }
}
@media (max-width: 360px) {
  html:root:root body #view-scripts .sc-tools select#sort { width: 124px !important; max-width: 124px; padding-right: 22px !important; }
  html:root:root body #view-scripts .sc-tools #newOnly { padding: 0 10px !important; font-size: 12.5px !important; }
}

/* ---------- 6. Glow lives on the POST cards only; New arrivals shelf cards are calm ---------- */
html:root:root body #view-scripts .arr-card:not(.is-anime):not(.is-excl),
html:root:root body #view-scripts .arr-card.is-upd:not(.is-anime):not(.is-excl) { animation: none !important; box-shadow: none !important; border-color: var(--line2, #e6dff5) !important; }
html:root:root body #view-scripts .arr-card:not(.is-anime):not(.is-excl)::after,
html:root:root body #view-scripts .arr-card:not(.is-anime):not(.is-excl)::before { display: none !important; animation: none !important; }

/* ---------- 7. Phone header can never overflow, whatever the screen width or avatar ---------- */
@media (max-width: 760px) {
  html:root:root body .site-header .wrap { display: flex !important; flex-wrap: nowrap !important; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; overflow: hidden; }
  html:root:root body .site-header .brand { flex: 0 1 auto !important; min-width: 0 !important; overflow: hidden; }
  html:root:root body .site-header .bar-actions { flex: 0 0 auto !important; margin-left: auto; gap: 6px !important; min-width: 0; }
  html:root:root body .site-header .bar-actions > * { flex: 0 0 auto; }
  html:root:root body .site-header .bar-actions .msg-top,
  html:root:root body .site-header .bar-actions .mobile-alerts { width: 38px !important; height: 38px !important; min-width: 0 !important; min-height: 0 !important; }
  html:root:root body .site-header .bar-actions .mobile-profile { width: 40px !important; height: 40px !important; min-width: 0 !important; min-height: 0 !important; padding: 2px !important; }
  html:root:root body .site-header .mobile-profile .avatar,
  html:root:root body .site-header .mobile-profile img { width: 32px !important; height: 32px !important; max-width: 100%; border-radius: 50%; }
}
@media (max-width: 360px) {
  html:root:root body .site-header .brand .aevy-word { font-size: 20px !important; }
  html:root:root body .site-header .brand { padding: 4px 8px !important; }
}
