/* ============================================================
   TypeRenew — Themes Gallery (themes.html)
   Page-specific styles. Prefix: trp-  (no conflicts with style.css)
   Depends on style.css variables & shared components
   (--brand, --grad, --card-glass, --border, --ease, ...).
   RTL + Light/Dark via [data-theme] — fully automatic.
   ============================================================ */

/* ============================================================
   1. HERO EXTRAS (badge + title reuse .tr-hero from style.css)
   ============================================================ */
.trp-hero-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 0 10px;
}
.trp-hero-stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--card-glass);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.trp-hero-stat b {
  color: var(--brand);
  font-weight: 800;
  font-size: 14px;
}
[data-theme="dark"] .trp-hero-stat b { color: #5BA4F2; }
.trp-hero-stat svg { color: var(--brand-2); flex: none; }
[data-theme="dark"] .trp-hero-stat svg { color: #34D399; }

/* ============================================================
   2. THEMES GRID  (desktop: 3 cols / tablet: 2 / mobile: 1)
   ============================================================ */
.trp-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

/* ============================================================
   3. THEME CARD — glass card + browser-frame screenshot
   ============================================================ */
.trp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform .35s var(--ease), border-color .3s var(--ease),
              box-shadow .35s var(--ease), background .45s var(--ease);
}
/* soft radial glow following the cursor (set via JS --trp-mx/--trp-my) */
.trp-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(420px circle at var(--trp-mx, 50%) var(--trp-my, 0%),
              var(--accent-subtle), transparent 45%);
  opacity: 0;
  transition: opacity .4s var(--ease);
  pointer-events: none;
}
.trp-card:hover {
  border-color: rgba(11, 111, 232, .35);
  box-shadow: var(--shadow);
  transform: translateY(-5px);
}
.trp-card:hover::before { opacity: 1; }

/* ---- screenshot button (browser mockup frame) ---- */
.trp-shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  cursor: zoom-in;
  text-align: inherit;
  font-family: inherit;
  position: relative;
  z-index: 1;
}
/* browser chrome bar */
.trp-shot-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--mock-side-bg);
  border-bottom: 1px solid var(--border);
  transition: background .45s var(--ease);
}
.trp-shot-dots { display: inline-flex; gap: 6px; flex: none; }
.trp-shot-dots i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #FF5F57;
}
.trp-shot-dots i:nth-child(2) { background: #FEBC2E; }
.trp-shot-dots i:nth-child(3) { background: #28C840; }
/* zoom icon — appears on hover */
.trp-shot-zoom {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  margin-inline-start: auto;
  border-radius: 8px;
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  transition: color .25s var(--ease), background .25s var(--ease),
              transform .35s var(--ease-spring), opacity .25s var(--ease);
  opacity: .55;
}
.trp-shot:hover .trp-shot-zoom {
  opacity: 1;
  color: var(--brand);
  background: var(--accent-subtle);
  transform: scale(1.06);
}
.trp-shot:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
/* screenshot image */
.trp-shot-screen {
  display: block;
  overflow: hidden;
  aspect-ratio: 8 / 5;
  background: var(--bg-3);
}
.trp-shot-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.001);
  transition: transform .6s var(--ease), opacity .5s var(--ease);
  opacity: 0;
}
.trp-shot-screen img.trp-img-ready { opacity: 1; }
.trp-card:hover .trp-shot-screen img { transform: scale(1.04); }

/* ---- card body ---- */
.trp-card-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  padding: 20px 20px 22px;
}
.trp-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.trp-card-title {
  margin: 0;
  font-size: 18.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.4;
}
.trp-card-version {
  flex: none;
  direction: ltr;
  font-family: 'Sarasa Mono SC', 'SFMono-Regular', Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand);
  background: var(--accent-subtle);
  border: 1px solid rgba(11, 111, 232, .16);
  border-radius: 999px;
  padding: 3px 10px;
}
[data-theme="dark"] .trp-card-version { color: #5BA4F2; }

.trp-card-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--text-2);
}

/* ---- meta cells: version / date / author ---- */
.trp-card-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}
.trp-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 11px;
  min-width: 0;
  transition: background .45s var(--ease), border-color .3s var(--ease);
}
.trp-card:hover .trp-meta-item { background: var(--accent-subtle); }
.trp-meta-item dt {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}
.trp-meta-item dd {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- author link (inside the سازنده meta cell) ---- */
.trp-meta-link {
  color: var(--brand);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  border-radius: 4px;
  transition: color .25s var(--ease), text-decoration-color .25s var(--ease);
}
[data-theme="dark"] .trp-meta-link { color: #5BA4F2; }
.trp-meta-link:hover {
  text-decoration-color: currentColor;
}
.trp-meta-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---- download button ---- */
.trp-card-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: auto;
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  background: var(--grad);
  border-radius: 13px;
  box-shadow: var(--shadow-brand);
  overflow: hidden;
  transition: transform .3s var(--ease-spring), box-shadow .3s var(--ease);
}
.trp-card-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .35) 50%, transparent 60%);
  transform: translateX(160%);
  transition: transform .7s var(--ease);
}
.trp-card-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(11, 111, 232, .38), 0 4px 12px rgba(0, 176, 155, .25);
}
.trp-card-btn:hover::after { transform: translateX(-160%); }
.trp-card-btn:active { transform: translateY(0); }
.trp-card-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.trp-card-btn svg { flex: none; }

/* ============================================================
   4. SKELETON LOADING CARDS
   ============================================================ */
.trp-skeleton {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.trp-skel-shot {
  aspect-ratio: 8 / 5;
  border-bottom: 1px solid var(--border);
}
.trp-skel-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.trp-skel-line { height: 14px; border-radius: 7px; }
.trp-skel-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.trp-skel-meta i {
  height: 46px;
  border-radius: 11px;
}
.trp-skel-btn { height: 44px; border-radius: 13px; }
.trp-skel-shot, .trp-skel-line, .trp-skel-meta i, .trp-skel-btn {
  background: linear-gradient(100deg, var(--bg-3) 40%, var(--accent-subtle) 50%, var(--bg-3) 60%);
  background-size: 200% 100%;
  animation: trpShimmer 1.4s ease-in-out infinite;
}
@keyframes trpShimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* ============================================================
   5. LOAD MORE — "نمایش بیشتر" control
   ============================================================ */
.trp-load-more {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}
.trp-load-more[hidden] { display: none; }

.trp-load-more-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 34px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: var(--card-glass);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  transition: color .25s var(--ease), border-color .25s var(--ease),
              transform .3s var(--ease-spring), box-shadow .3s var(--ease);
}
.trp-load-more-btn svg { transition: transform .35s var(--ease-spring); }
.trp-load-more-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.trp-load-more-btn:hover svg { transform: translateY(2px); }
.trp-load-more-btn:active { transform: translateY(0); }
.trp-load-more-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.trp-load-info {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  min-height: 1em;   /* reserves space so layout doesn't jump */
}
.trp-load-info:empty { display: none; }

/* ============================================================
   6. ERROR STATE
   ============================================================ */
.trp-error {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 56px 28px;
  background: var(--card-glass);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.trp-error.is-visible { display: flex; }
.trp-error-icon {
  width: 56px; height: 56px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--shadow-brand);
}
.trp-error-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
}
.trp-error-text {
  margin: 0;
  max-width: 480px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--text-2);
}
.trp-error-retry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--card-glass);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: color .25s var(--ease), border-color .25s var(--ease),
              transform .3s var(--ease-spring), box-shadow .3s var(--ease);
}
.trp-error-retry:hover {
  color: var(--brand);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   7. LIGHTBOX — full-screen preview with zoom
   ============================================================ */
.trp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.trp-lightbox[hidden] { display: none; }

.trp-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 14, .84);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  opacity: 0;
  transition: opacity .35s var(--ease);
}
.trp-lightbox.is-open .trp-lightbox-backdrop { opacity: 1; }

.trp-lightbox-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: min(94vw, 1120px);
  margin: 0;
  transform: scale(.94) translateY(12px);
  opacity: 0;
  transition: transform .38s var(--ease-spring), opacity .3s var(--ease);
}
.trp-lightbox.is-open .trp-lightbox-stage {
  transform: none;
  opacity: 1;
}

/* close button */
.trp-lightbox-close {
  position: absolute;
  top: -14px;
  inset-inline-end: -14px;
  z-index: 3;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 50%;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
  transition: transform .3s var(--ease-spring), background .25s var(--ease),
              border-color .25s var(--ease);
}
.trp-lightbox-close:hover {
  background: rgba(255, 255, 255, .22);
  border-color: rgba(255, 255, 255, .45);
  transform: rotate(90deg) scale(1.05);
}
.trp-lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* image wrap + zoom states */
.trp-lightbox-imgwrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  background: #0A0F1A;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.trp-lightbox-img {
  display: block;
  max-width: min(94vw, 1120px);
  max-height: calc(100vh - 170px);
  width: auto;
  height: auto;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform .45s var(--ease);
}
.trp-lightbox-imgwrap.is-zoomed {
  overflow: visible;           /* let panned image move freely */
  border-radius: 10px;
}
.trp-lightbox-imgwrap.is-zoomed .trp-lightbox-img {
  cursor: grab;
  /* translate is applied in visual (post-scale) space → clean pan math */
  transform: translate(var(--trp-tx, 0px), var(--trp-ty, 0px)) scale(var(--trp-zoom, 2.5));
  transition: none;            /* instant 1:1 tracking while dragging */
}
.trp-lightbox-imgwrap.is-zoomed .trp-lightbox-img.is-animating { transition: transform .45s var(--ease); }
.trp-lightbox-imgwrap.is-zoomed .trp-lightbox-img.is-grabbing { cursor: grabbing; }

/* caption */
.trp-lightbox-caption {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
  margin: 0;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 13.5px;
}
.trp-lightbox-caption strong { font-weight: 800; }
.trp-lightbox-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, .65);
  font-weight: 500;
}
.trp-lightbox-caption svg { color: rgba(255, 255, 255, .65); flex: none; }

/* ============================================================
   8. RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .trp-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .trp-grid { grid-template-columns: 1fr; gap: 18px; }
  .trp-hero-meta { flex-direction: column; align-items: stretch; }
  .trp-hero-stat { justify-content: center; }
  .trp-card-btn { width: 100%; }
  .trp-lightbox-close { top: -10px; inset-inline-end: -6px; width: 40px; height: 40px; }
  .trp-lightbox-img { max-height: calc(100vh - 190px); }
}

@media (max-width: 480px) {
  .trp-card-meta { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .trp-meta-item { padding: 8px 8px; }
  .trp-meta-item dd { font-size: 11.5px; }
  .trp-lightbox { padding: 14px; }
}

/* ============================================================
   9. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .trp-card, .trp-shot-screen img, .trp-card-btn, .trp-card-btn::after {
    transition: none !important;
  }
  .trp-shot-screen img { opacity: 1; }
  .trp-skel-shot, .trp-skel-line, .trp-skel-meta i, .trp-skel-btn {
    animation: none;
  }
  .trp-lightbox-img { transition: none !important; }
  .trp-lightbox-stage { transition: opacity .01ms; transform: none; }
}
