/* ==========================================================================
   3D TEMPLATES DIRECTORY — Live Scaled Iframe Previews + Quick View Modal
   Inspired by modern 3D template galleries · 100% Arabic RTL & Responsive
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #07080b;
  --panel: #0e1015;
  --panel-hi: #141720;
  --ink: #f4f6fa;
  --muted: #939bb0;
  --lime: #b8ff2e;
  --lime-ink: #070b02;
  --border: rgba(255, 255, 255, 0.10);
  --border-hi: rgba(184, 255, 46, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 75% 38% at 50% 0%, rgba(184, 255, 46, 0.08), transparent 68%),
    linear-gradient(to right, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    var(--bg);
  background-size: 100% 100%, 64px 64px, 64px 64px, 100% 100%;
  color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  line-height: 1.65;
  padding-bottom: 92px;
}

.dir-wrap {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding: 0 clamp(16px, 3.2vw, 40px);
}

/* Top Header Bar */
.dir-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.dir-brand-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dir-seen-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0, 71, 255, 0.24), rgba(56, 189, 248, 0.14));
  border: 1px solid rgba(56, 189, 248, 0.36);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, background 0.2s ease;
}
.dir-seen-badge:hover {
  transform: translateY(-1px);
  border-color: #38bdf8;
  background: linear-gradient(135deg, rgba(0, 71, 255, 0.42), rgba(56, 189, 248, 0.22));
}
.dir-seen-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #0000fe;
  color: #21ff3e;
  display: inline-grid;
  place-items: center;
  font-family: 'Readex Pro', 'Cairo', sans-serif;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(0, 0, 254, 0.55);
}
.dir-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  text-decoration: none;
}
.dir-logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 16px rgba(184, 255, 46, 0.7);
}
.dir-top-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', 'IBM Plex Sans Arabic', sans-serif;
  font-size: 12px;
  color: var(--muted);
}
.dir-top-link {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 600 12.5px/1.1 'IBM Plex Sans Arabic', sans-serif;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dir-top-link:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}
.dir-top-cta {
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--lime-ink);
  font: 700 12.5px/1.1 'IBM Plex Sans Arabic', sans-serif;
  text-decoration: none;
  transition: transform 0.2s var(--ease), filter 0.2s ease;
}
.dir-top-cta:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.dir-pill-stat {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--ink);
}
.dir-pill-stat b { color: var(--lime); }

.dir-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.dir-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  font: 700 13.5px/1.2 'IBM Plex Sans Arabic', sans-serif;
  text-decoration: none;
  transition: transform 0.22s var(--ease), filter 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.dir-hero-btn.is-primary {
  background: linear-gradient(135deg, #0047ff 0%, #0096ff 100%);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(0, 71, 255, 0.35);
}
.dir-hero-btn.is-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.dir-hero-btn.is-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--ink);
}
.dir-hero-btn.is-ghost:hover {
  transform: translateY(-2px);
  border-color: rgba(184, 255, 46, 0.5);
  background: rgba(184, 255, 46, 0.1);
}

/* Hero */
.dir-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(36px, 5vw, 64px) 0 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dir-hero > :not(.dir-hero-3d) {
  position: relative;
  z-index: 2;
}
.dir-hero-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.82;
}
.dir-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
}
.dir-hero h1 {
  font-family: 'Readex Pro', 'Cairo', sans-serif;
  font-weight: 700;
  font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.16;
}
.dir-hero h1 span { color: var(--lime); }
.dir-hero p {
  max-width: 70ch;
  color: var(--muted);
  font-size: 15.5px;
}

/* Search & Filter Toolbar */
.dir-controls {
  position: sticky;
  top: 8px;
  z-index: 40;
  margin-bottom: 24px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(14, 16, 21, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dir-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.dir-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: 500 12.2px/1.2 'IBM Plex Sans Arabic', sans-serif;
  transition: all 0.2s var(--ease);
}
.dir-filter b {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}
.dir-filter:hover { color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.dir-filter.is-active {
  background: rgba(184, 255, 46, 0.14);
  border-color: var(--border-hi);
  color: #ffffff;
  font-weight: 600;
}
.dir-filter.is-active b {
  background: var(--lime);
  color: var(--lime-ink);
  font-weight: 700;
}
.dir-search {
  flex: 1 1 220px;
  max-width: 320px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(7, 8, 11, 0.85);
  color: var(--ink);
  font: 400 13.5px/1.2 'IBM Plex Sans Arabic', sans-serif;
}
.dir-search::placeholder { color: rgba(147, 155, 176, 0.78); }
.dir-search:focus { outline: 1.5px solid var(--lime); outline-offset: 1px; }

/* 2-Column Live 3D Template Showcase Grid (Matches 3d-templates layout!) */
.dir-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding-bottom: 56px;
}
@media (max-width: 720px) {
  .dir-grid { grid-template-columns: 1fr; }
  .dir-search { max-width: 100%; }
}

.tpl-card {
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.32s var(--ease), border-color 0.25s ease, box-shadow 0.32s var(--ease);
}
.tpl-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 28px 60px -16px rgba(0, 0, 0, 0.78);
}
.tpl-card.is-hidden { display: none !important; }

/* Live Scaled 1280x800 Iframe Viewport */
.tpl-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0a0c10;
  border-bottom: 1px solid var(--border);
}
.tpl-fallback-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
.tpl-fallback-plate {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  transition: opacity 0.45s ease;
  pointer-events: none;
  background-size: 32px 32px, 32px 32px, 100% 100%;
}
.tpl-fallback-plate strong {
  font-family: 'Readex Pro', 'Cairo', sans-serif;
  font-size: 22px;
  font-weight: 700;
}
.tpl-fallback-plate span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  opacity: 0.72;
}
.tpl-stage.has-live-frame .tpl-fallback-img,
.tpl-stage.has-live-frame .tpl-fallback-plate {
  opacity: 0;
}
.tpl-iframe-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.tpl-live-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 800px;
  border: 0;
  transform-origin: top left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: transparent;
}
.tpl-stage.has-live-frame .tpl-live-iframe {
  opacity: 1;
}

/* Clickable transparent overlay over stage -> opens full template */
.tpl-stage-link {
  position: absolute;
  inset: 0;
  z-index: 4;
  text-decoration: none;
}

/* Subtle top badges on stage */
.tpl-stage-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.tpl-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.76);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: #ffffff;
}
.tpl-live-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: dirLivePulse 2s ease-in-out infinite;
}
@keyframes dirLivePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.5; }
}
.tpl-swatches {
  display: inline-flex;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.68);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.tpl-swatches i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

/* Card Body */
.tpl-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.tpl-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tpl-chip {
  font-family: 'JetBrains Mono', 'IBM Plex Sans Arabic', sans-serif;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tpl-chip.is-cat {
  color: var(--lime);
  border-color: rgba(184, 255, 46, 0.28);
  background: rgba(184, 255, 46, 0.07);
}
.tpl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.tpl-head h2 {
  font-family: 'Readex Pro', sans-serif;
  font-size: 18.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
}
.tpl-en {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.tpl-desc {
  font-size: 13.8px;
  color: var(--muted);
  line-height: 1.7;
}

.tpl-actions {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.btn-qv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: 600 12.5px/1 'IBM Plex Sans Arabic', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-qv:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}
.btn-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--lime-ink);
  font: 700 12.5px/1 'IBM Plex Sans Arabic', sans-serif;
  text-decoration: none;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.btn-open:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

/* Footer */
.dir-footer {
  padding: 28px 0 22px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}
.dir-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.dir-footer-links a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}
.dir-footer-links a:hover {
  color: var(--lime);
}
.qv-order-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0047ff 0%, #0096ff 100%);
  color: #ffffff;
  font: 700 12.5px/1 'IBM Plex Sans Arabic', sans-serif;
  text-decoration: none;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.qv-order-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Interactive Quick View Modal (Desktop / Tablet / Mobile Switcher) */
.qv-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(5, 6, 9, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  flex-direction: column;
  padding: 16px;
}
.qv-modal.is-open { display: flex; }

.qv-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--panel-hi);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.qv-title-grp {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qv-title-grp strong { font-size: 15px; color: #fff; }
.qv-title-grp span { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); }

.qv-devices {
  display: inline-flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.qv-dev {
  padding: 5px 12px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1 'IBM Plex Sans Arabic', sans-serif;
  cursor: pointer;
}
.qv-dev.is-active {
  background: var(--lime);
  color: var(--lime-ink);
}
.qv-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.qv-nav-btn, .qv-close {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  font-size: 12.5px;
}
.qv-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.qv-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b0d12;
  transition: width 0.32s var(--ease);
}
.qv-frame.is-tablet { width: min(100%, 920px); }
.qv-frame.is-mobile { width: min(100%, 400px); }
