/* Zoojoy responsive baseline
   ─────────────────────────────────────────────────────────────────────────
   Small, opt-in helpers that layer on top of the Tailwind utility classes
   already used across the templates. Goals:
     - fluid container + breakpoint helpers for legacy pages that use raw px
     - clamp() typography classes (.h1-fluid / .h2-fluid / .h3-fluid)
     - CSS-only page fade-in on body load (no JS, no flash)
     - reusable .skeleton with shimmer for slow-loading grids
   Total ~3 KB minified; safe to ship on slow Uzbek cellular.
*/

/* ── Fluid container ──────────────────────────────────────────────────── */
/* Matches the max-w-6xl mx-auto px-5 sm:px-6 pattern used everywhere,
   but as a single class so legacy templates can opt-in without a refactor. */
.zj-container {
  width: 100%;
  max-width: 72rem;            /* matches Tailwind max-w-6xl */
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;       /* 20px */
  padding-right: 1.25rem;
}
@media (min-width: 640px) {
  .zj-container { padding-left: 1.5rem; padding-right: 1.5rem; }
}

/* Narrow variant for reading pages (about / privacy) */
.zj-container-narrow {
  width: 100%;
  max-width: 44rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* ── Breakpoint visibility helpers ────────────────────────────────────── */
/* For one-off cases where Tailwind sm:/md:/lg: aren't convenient. */
.zj-hide-mobile { }
.zj-only-mobile { display: none; }
@media (max-width: 639px) {
  .zj-hide-mobile { display: none !important; }
  .zj-only-mobile { display: block; }
}

/* ── Fluid typography (clamp) ─────────────────────────────────────────── */
/* Use these for hero/section headings so the same element scales from
   360px phones to 1440px desktops without per-breakpoint overrides. */
.h1-fluid {
  font-size: clamp(2rem, 1.4rem + 3.2vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 900;
}
.h2-fluid {
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-weight: 800;
}
.h3-fluid {
  font-size: clamp(1.125rem, 0.95rem + 0.9vw, 1.5rem);
  line-height: 1.25;
  font-weight: 700;
}
.text-fluid {
  font-size: clamp(0.95rem, 0.88rem + 0.3vw, 1.0625rem);
  line-height: 1.55;
}

/* ── Page fade-in transition ──────────────────────────────────────────── */
/* CSS-only, runs once per navigation. No JS, no FOUC: the body starts at
   opacity 0 and fades to 1 over 200ms via the keyframe — same frame the
   browser would paint anyway, so zero perceived performance cost. */
@keyframes zjPageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
body {
  animation: zjPageFadeIn 200ms ease-out both;
}
/* Respect users who asked the OS to cut motion */
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}

/* ── Skeleton loader ──────────────────────────────────────────────────── */
/* Drop-in placeholder for slow-loading sections (animal grid, shelter
   grid, chat list, channels). Usage:
     <div class="skeleton skeleton-card"></div>
     <div class="skeleton skeleton-line"></div>
     <div class="skeleton skeleton-avatar"></div>
   The shimmer is GPU-cheap (single linear-gradient slide). */
@keyframes zjSkeletonShimmer {
  0%   { background-position: -468px 0; }
  100% { background-position: 468px 0; }
}
.skeleton {
  display: block;
  border-radius: 12px;
  background-color: rgba(var(--bg3), 1);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0)   0%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0)   100%
  );
  background-size: 936px 100%;
  background-repeat: no-repeat;
  animation: zjSkeletonShimmer 1.4s linear infinite;
  position: relative;
  overflow: hidden;
}
/* Dark mode: dimmer base, dimmer sweep */
[data-theme="dark"] .skeleton {
  background-color: rgba(var(--bg2), 1);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0)    0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0)    100%
  );
}
.skeleton-card {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
}
.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
}
.skeleton-line.sm { height: 10px; width: 60%; }
.skeleton-line.md { height: 14px; width: 80%; }
.skeleton-line.lg { height: 18px; width: 95%; }
.skeleton-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-pill {
  height: 28px;
  width: 80px;
  border-radius: 999px;
}
/* Container helpers for the common shapes */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.25rem;
}
@media (min-width: 640px)  { .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .skeleton-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgb(var(--bg2));
  margin-bottom: 8px;
}
.skeleton-row .skeleton-line { margin-bottom: 6px; }

/* Respect reduced-motion: keep the placeholder, kill the shimmer */
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background-image: none; }
}

/* ── Safety: prevent horizontal scroll on narrow phones ───────────────── */
/* Catches any rogue 400+ px wide element that escaped the cascade. */
@media (max-width: 480px) {
  html, body { overflow-x: hidden; }
  /* Long unbroken text (URLs in chat, etc.) — soft-wrap so it doesn't
     push the viewport. */
  p, h1, h2, h3, h4, span, a { word-wrap: break-word; overflow-wrap: anywhere; }
  /* Tables on tiny screens: let them scroll horizontally inside their
     own box instead of breaking page layout. */
  table { display: block; max-width: 100%; overflow-x: auto; }
}

/* ── Touch-target safety on tiny phones (360px) ───────────────────────── */
/* Tailwind sometimes lays out icon-only buttons at 28-32px — Apple HIG
   wants 44, but 36 is the lived-in compromise already enforced in
   base.html. We tighten min-width for inputs/selects too. */
@media (max-width: 360px) {
  input, select, textarea { font-size: 16px; }  /* prevent iOS zoom */
}
