/* =====================================================
   Pixelary — Phase 1 MVP Stylesheet
   Mobile-first, RTL Persian UI, Dark mode native
   ===================================================== */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand */
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #ec4899;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

  /* Light theme */
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-muted: #f3f4f6;
  --bg-overlay: rgba(0, 0, 0, 0.55);
  --text: #0f0f17;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --shadow-sm: 0 1px 2px rgba(15, 15, 23, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 15, 23, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 15, 23, 0.12);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Typography */
  --font-sans: "Vazirmatn", -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono",
               Menlo, Consolas, monospace;

  /* Layout */
  --max-w: 1280px;
  --header-h: 60px;
  --bottom-nav-h: 64px;

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.18s var(--ease);
  --t-med: 0.32s var(--ease);
}

[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-elevated: #14141c;
  --bg-muted: #1c1c28;
  --bg-overlay: rgba(0, 0, 0, 0.75);
  --text: #f5f5f7;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --border: #27272f;
  --border-strong: #3f3f46;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-med), color var(--t-med);
  overflow-x: hidden;
}
img, picture, video, canvas { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h3 { font-size: 1.125rem; }
p  { color: var(--text); }
small { color: var(--text-muted); }
code, pre { font-family: var(--font-mono); font-size: 0.875em; }

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}
@media (min-width: 768px) {
  .container { padding-inline: var(--sp-6); }
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  z-index: 200;
  transition: top var(--t-fast);
}
.skip-link:focus { top: var(--sp-4); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: 100%;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-gradient);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.logo-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  margin-inline: auto;
}
.header-search input {
  width: 100%;
  height: 40px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-4) 0 44px;
  font-size: 0.9rem;
  transition: all var(--t-fast);
}
[dir="rtl"] .header-search input { padding: 0 44px 0 var(--sp-4); }
.header-search input::placeholder { color: var(--text-faint); }
.header-search input:focus {
  background: var(--bg-elevated);
  border-color: var(--brand-1);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 18%, transparent);
  outline: none;
}
.header-search .search-icon {
  position: absolute;
  inset-inline-start: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  transition: all var(--t-fast);
}
.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 20px; height: 20px; }

.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* Mobile: hide search bar from header, show FAB instead */
@media (max-width: 640px) {
  .header-search { display: none; }
  .header-actions .desktop-only { display: none; }
  /* Theme toggle stays visible on mobile */
  .header-actions [data-theme-toggle] { display: grid !important; }
}

/* ---------- Bottom Nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  height: var(--bottom-nav-h);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 500;
  height: 100%;
  transition: color var(--t-fast);
  position: relative;
}
.bottom-nav-item.active { color: var(--brand-1); }
.bottom-nav-item:active { transform: scale(0.92); }
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  background: var(--brand-gradient);
  border-radius: 0 0 var(--r-pill) var(--r-pill);
}
@media (min-width: 769px) {
  .bottom-nav { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  padding: var(--sp-8) 0 var(--sp-6);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 280px;
  background: radial-gradient(60% 50% at 50% 50%,
              color-mix(in srgb, var(--brand-1) 18%, transparent) 0%,
              transparent 70%);
  pointer-events: none;
  z-index: -1;
}
.hero h1 { margin-bottom: var(--sp-3); }
.hero h1 .accent {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto var(--sp-6);
  font-size: 1rem;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}
.hero-stat {
  text-align: center;
}
.hero-stat .num {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: block;
}
.hero-stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ---------- Category Chips ---------- */
.category-bar {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding: var(--sp-4) 0 var(--sp-2);
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-inline: calc(-1 * var(--sp-4));
  padding-inline: var(--sp-4);
}
.category-bar::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .category-bar {
    justify-content: center;
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }
}
.chip {
  flex-shrink: 0;
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--t-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.chip:hover {
  border-color: var(--brand-1);
  color: var(--text);
}
.chip.active {
  background: var(--brand-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-1) 30%, transparent);
}
.chip .count {
  font-size: 0.7rem;
  opacity: 0.7;
  padding-inline-start: var(--sp-1);
}

/* ---------- Gallery Grid ---------- */
.gallery {
  padding: var(--sp-4) 0 calc(var(--bottom-nav-h) + var(--sp-8));
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}
@media (min-width: 480px) {
  .gallery { grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
}
@media (min-width: 768px) {
  .gallery { grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
}
@media (min-width: 1024px) {
  .gallery { grid-template-columns: repeat(5, 1fr); }
}

.photo-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-muted);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.photo-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.photo-card:active { transform: scale(0.98); }
.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-med), opacity var(--t-med);
}
.photo-card:hover img { transform: scale(1.06); }
.photo-card .skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg,
              var(--bg-muted) 30%,
              color-mix(in srgb, var(--bg-muted) 50%, var(--bg-elevated)) 50%,
              var(--bg-muted) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.photo-card.loaded .skeleton { opacity: 0; pointer-events: none; }
.photo-card .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--t-fast);
  display: flex;
  align-items: flex-end;
  padding: var(--sp-3);
  pointer-events: none;
}
.photo-card:hover .overlay,
.photo-card:focus-within .overlay { opacity: 1; }
.photo-card .overlay-content {
  color: white;
  font-size: 0.8rem;
  width: 100%;
}
.photo-card .overlay-title {
  font-weight: 600;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.photo-card .overlay-author {
  opacity: 0.85;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.photo-card .license-badge {
  position: absolute;
  top: var(--sp-2);
  inset-inline-end: var(--sp-2);
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0.85;
  transition: opacity var(--t-fast);
}
.photo-card:hover .license-badge { opacity: 1; }

/* ---------- Load more / sentinel ---------- */
.load-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--sp-8) 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.load-more .spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--sp-3);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Photo Detail Page ---------- */
.photo-detail {
  padding: var(--sp-6) 0 var(--sp-12);
}
.photo-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6);
}
@media (min-width: 1024px) {
  .photo-detail-grid {
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--sp-8);
  }
}
.photo-image-wrap {
  background: var(--bg-muted);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.photo-info {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.photo-info h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin-bottom: var(--sp-2);
}
.photo-info .meta-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.photo-info .meta-row .author {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 600;
  color: var(--text);
}
.photo-info .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-gradient);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.photo-info .description {
  color: var(--text);
  line-height: 1.7;
  padding: var(--sp-4);
  background: var(--bg-muted);
  border-radius: var(--r-md);
}
.info-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  background: var(--bg-elevated);
}
.info-card h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  font-weight: 700;
}
.info-card .info-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.info-card .info-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: 0.875rem;
}
.info-card .info-row .label { color: var(--text-muted); }
.info-card .info-row .value { color: var(--text); font-weight: 500; text-align: end; }
.info-card .info-row .value a { color: var(--brand-1); }
.license-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--brand-2) 14%, transparent);
  color: var(--brand-2);
  font-size: 0.75rem;
  font-weight: 600;
}
[data-theme="dark"] .license-pill {
  background: color-mix(in srgb, var(--brand-2) 25%, transparent);
  color: #c4b5fd;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-4);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all var(--t-fast);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-1) 30%, transparent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--bg-muted);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--brand-1); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }
.btn svg { width: 16px; height: 16px; }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--sp-4));
  inset-inline: var(--sp-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
@media (min-width: 769px) {
  .toast-container { bottom: var(--sp-4); inset-inline: auto; right: var(--sp-4); }
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: auto;
  animation: toast-in var(--t-fast);
}
.toast.success { border-inline-start: 3px solid #10b981; }
.toast.error { border-inline-start: 3px solid #ef4444; }
.toast.info { border-inline-start: 3px solid var(--brand-1); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Empty / Error State ---------- */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-4);
  color: var(--text-muted);
}
.empty-state svg {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--sp-4);
  color: var(--text-faint);
  opacity: 0.6;
}
.empty-state h2 {
  color: var(--text);
  margin-bottom: var(--sp-2);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-8) 0 calc(var(--bottom-nav-h) + var(--sp-8));
  margin-top: var(--sp-12);
  background: var(--bg-elevated);
}
@media (min-width: 769px) {
  .site-footer { padding-bottom: var(--sp-8); }
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6);
}
@media (min-width: 640px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
.footer-brand h3 {
  font-size: 1.125rem;
  margin-bottom: var(--sp-2);
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}
.footer-brand p { color: var(--text-muted); font-size: 0.875rem; max-width: 360px; }
.footer-col h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  font-weight: 700;
}
.footer-col ul { display: flex; flex-direction: column; gap: var(--sp-2); }
.footer-col a {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: color var(--t-fast);
}
.footer-col a:hover { color: var(--brand-1); }
.footer-bottom {
  margin-top: var(--sp-8);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ---------- Generic Page (about / submit) ---------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--sp-6) 0 var(--sp-12);
}
.page h1 { margin-bottom: var(--sp-3); }
.page h2 { margin-top: var(--sp-8); margin-bottom: var(--sp-3); }
.page p { color: var(--text); margin-bottom: var(--sp-4); line-height: 1.75; }
.page ul { margin: 0 0 var(--sp-4) var(--sp-4); }
[dir="rtl"] .page ul { margin: 0 var(--sp-4) 0 0; }
.page li { margin-bottom: var(--sp-2); color: var(--text); line-height: 1.7; }
.page code {
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--brand-2);
}
.page pre {
  background: var(--bg-muted);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  overflow-x: auto;
  margin-bottom: var(--sp-4);
  border: 1px solid var(--border);
}
.page pre code { background: none; padding: 0; color: var(--text); }
.page .lead { font-size: 1.125rem; color: var(--text-muted); margin-bottom: var(--sp-6); }
.callout {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--brand-1) 8%, transparent);
  border-inline-start: 3px solid var(--brand-1);
  margin-bottom: var(--sp-4);
}
[data-theme="dark"] .callout {
  background: color-mix(in srgb, var(--brand-1) 14%, transparent);
}
.callout p { margin-bottom: 0; color: var(--text); }

/* ---------- Step list ---------- */
.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin: var(--sp-6) 0;
}
.step-item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--bg-muted);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.875rem;
}
.step-content h3 { margin-bottom: var(--sp-1); font-size: 1rem; }
.step-content p { color: var(--text-muted); font-size: 0.875rem; margin: 0; }

/* ---------- Loading skeleton for detail ---------- */
.detail-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.detail-skeleton .line {
  height: 14px;
  background: var(--bg-muted);
  border-radius: 4px;
  animation: shimmer 1.5s infinite linear;
  background: linear-gradient(110deg,
              var(--bg-muted) 30%,
              color-mix(in srgb, var(--bg-muted) 50%, var(--bg-elevated)) 50%,
              var(--bg-muted) 70%);
  background-size: 200% 100%;
}
.detail-skeleton .line.title { height: 24px; width: 80%; }
.detail-skeleton .line.short { width: 40%; }

/* ---------- Mobile search overlay ---------- */
.search-fab {
  position: fixed;
  inset-inline-end: var(--sp-4);
  bottom: calc(var(--bottom-nav-h) + var(--sp-4));
  width: 56px;
  height: 56px;
  border-radius: var(--r-pill);
  background: var(--brand-gradient);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  display: none;
}
@media (max-width: 640px) {
  .search-fab { display: grid; }
}
.search-fab:active { transform: scale(0.92); }
.search-fab svg { width: 22px; height: 22px; }

.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 80;
  display: none;
  padding: var(--sp-4);
  align-items: flex-start;
  justify-content: center;
}
.search-overlay.active { display: flex; }
.search-overlay-content {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  margin-top: var(--sp-12);
  padding: var(--sp-4);
  box-shadow: var(--shadow-lg);
  animation: slide-down var(--t-fast);
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-overlay-content input {
  width: 100%;
  height: 44px;
  background: var(--bg-muted);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 var(--sp-4);
  font-size: 1rem;
}
.search-overlay-content input:focus {
  outline: none;
  border-color: var(--brand-1);
}
.search-overlay-results {
  margin-top: var(--sp-3);
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.search-result-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
  cursor: pointer;
}
.search-result-item:hover { background: var(--bg-muted); }
.search-result-item img {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-muted);
}
.search-result-item .info { flex: 1; min-width: 0; }
.search-result-item .title {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-8 { margin-top: var(--sp-8); }

/* ---------- Print ---------- */
@media print {
  .site-header, .bottom-nav, .site-footer, .search-fab, .toast-container { display: none !important; }
  body { background: white; color: black; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================================
   Phase 2: Video Gallery & Player Styles
   ===================================================== */

/* ---------- Video cards (gallery) ---------- */
.video-card {
  position: relative;
  display: block;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-muted);
  aspect-ratio: 16 / 9;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-sm);
  isolation: isolate;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.video-card:focus-visible {
  outline: 3px solid var(--brand-1);
  outline-offset: 2px;
}
.video-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--t-med), opacity var(--t-fast);
}
.video-card:hover img {
  transform: scale(1.04);
}
.video-card .skeleton {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.video-card.loaded .skeleton {
  display: none;
}

/* Play icon overlay (center) */
.video-card .play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.video-card .play-icon svg {
  width: 48px;
  height: 48px;
  color: white;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  padding: 12px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform var(--t-fast), background var(--t-fast);
}
.video-card:hover .play-icon svg {
  transform: scale(1.1);
  background: var(--brand-1);
}

/* Duration badge (bottom-right) */
.video-card .duration-badge {
  position: absolute;
  bottom: var(--sp-2);
  inset-inline-end: var(--sp-2);
  background: rgba(0, 0, 0, 0.78);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
  z-index: 3;
  font-family: var(--font-mono);
}

/* ---------- Video gallery grid ---------- */
.video-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
@media (min-width: 600px) {
  .video-gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
  }
}
@media (min-width: 960px) {
  .video-gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- Hero variant for videos ---------- */
.hero-videos h1 .accent {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero-videos .hero-stats {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) {
  .hero-videos .hero-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- Filter bar (category + sort) ---------- */
.filter-bar {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.filter-bar .category-bar {
  flex: 1 1 100%;
  margin-bottom: 0;
}
.sort-wrap {
  position: relative;
  flex: 0 0 auto;
  margin-inline-start: auto;
}
.sort-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 8px 36px 8px 16px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.sort-select:hover {
  border-color: var(--brand-1);
}
.sort-select:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.sort-wrap svg {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
[dir="rtl"] .sort-select {
  padding: 8px 16px 8px 36px;
}

/* ---------- Duration pill (detail page) ---------- */
.duration-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  margin-inline-end: 6px;
}

/* ---------- Video detail layout ---------- */
.video-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}
@media (min-width: 900px) {
  .video-detail-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--sp-8);
  }
}

.video-info {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.video-info h1 {
  font-size: 1.4rem;
  line-height: 1.4;
  margin: 0;
}
@media (min-width: 768px) {
  .video-info h1 {
    font-size: 1.6rem;
  }
}

/* =====================================================
   Custom Video Player
   ===================================================== */
.video-player-wrap {
  position: relative;
  background: #000;
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow-lg);
  isolation: isolate;
}
.video-player-wrap.is-fullscreen-active,
.video-player.is-fullscreen {
  border-radius: 0;
  aspect-ratio: auto;
}

.video-player {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}
.video-player:focus-visible {
  outline: 3px solid var(--brand-1);
  outline-offset: -3px;
}

.video-el {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* ---------- Overlay (center play button) ---------- */
.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  transition: opacity var(--t-med);
}
.video-overlay.controls-visible {
  background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.6) 100%);
}
.video-center-btn {
  width: 72px;
  height: 72px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform var(--t-fast), background var(--t-fast);
  position: relative;
}
.video-center-btn:hover {
  background: var(--brand-1);
  transform: scale(1.08);
}
.video-center-btn svg {
  width: 32px;
  height: 32px;
}
.video-center-btn .icon-play {
  margin-inline-start: 4px; /* visual centering for play triangle */
}
.video-center-btn.playing {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}
.video-player .video-overlay.controls-visible ~ .video-center-btn,
.video-player.show-center .video-center-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Loading spinner */
.video-loading-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: video-spin 0.7s linear infinite;
  display: none;
}
@keyframes video-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Controls bar ---------- */
.video-controls {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  z-index: 3;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 60%, rgba(0,0,0,0) 100%);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  pointer-events: none;
}
.video-controls.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Progress bar */
.video-progress {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: var(--sp-2);
  touch-action: none;
  transition: height var(--t-fast);
}
.video-progress:hover,
.video-progress:focus-visible {
  height: 8px;
  outline: none;
}
.video-buffered {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  transition: width 0.2s linear;
}
.video-played {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  background: var(--brand-1);
  border-radius: 3px;
  width: 0;
  transition: width 0.05s linear;
}
.video-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity var(--t-fast), transform var(--t-fast);
  pointer-events: none;
}
.video-progress:hover .video-thumb,
.video-progress:focus-visible .video-thumb {
  opacity: 1;
}

/* Controls row (buttons + time) */
.video-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  color: white;
}
.video-controls-left,
.video-controls-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.video-btn {
  background: transparent;
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  padding: 0;
}
.video-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}
.video-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}
.video-btn:active {
  transform: scale(0.92);
}
.video-btn svg {
  width: 20px;
  height: 20px;
}
.video-btn.active {
  color: var(--brand-2);
}

/* Time display */
.video-time {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  display: flex;
  gap: 4px;
  opacity: 0.95;
  padding: 0 4px;
}
.video-time-sep {
  opacity: 0.5;
}

/* Quality selector */
.video-quality-wrap {
  position: relative;
}
.video-quality-btn {
  width: auto;
  padding: 0 10px;
  border-radius: var(--r-pill);
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}
.video-quality-btn svg {
  width: 12px;
  height: 12px;
}
.video-quality-btn .quality-label {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.video-quality-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-end: 0;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  min-width: 140px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  z-index: 10;
}
.video-quality-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.video-quality-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  text-align: start;
}
.video-quality-item:hover {
  background: var(--bg-muted);
}
.video-quality-item.active {
  color: var(--brand-1);
  font-weight: 700;
}
.video-quality-item .dim {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

/* Fullscreen tweaks */
.video-player.is-fullscreen .video-controls {
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
}
.video-player.is-fullscreen .video-btn {
  width: 44px;
  height: 44px;
}
.video-player.is-fullscreen .video-btn svg {
  width: 24px;
  height: 24px;
}
.video-player.is-fullscreen .video-center-btn {
  width: 96px;
  height: 96px;
}
.video-player.is-fullscreen .video-center-btn svg {
  width: 44px;
  height: 44px;
}

/* Compact mode (for related cards / inline previews) */
.video-player--compact .video-controls .video-controls-right {
  display: none;
}
.video-player--compact .video-controls {
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
}
.video-player--compact .video-center-btn {
  width: 48px;
  height: 48px;
}
.video-player--compact .video-center-btn svg {
  width: 22px;
  height: 22px;
}

/* ---------- Mobile player tweaks ---------- */
@media (max-width: 640px) {
  .video-btn {
    width: 32px;
    height: 32px;
  }
  .video-btn svg {
    width: 18px;
    height: 18px;
  }
  .video-time {
    font-size: 0.72rem;
  }
  .video-quality-btn {
    padding: 0 6px;
    font-size: 0.72rem;
  }
  .video-controls {
    padding: var(--sp-2);
  }
  .video-center-btn {
    width: 56px;
    height: 56px;
  }
  .video-center-btn svg {
    width: 26px;
    height: 26px;
  }
}

/* ---------- Bottom nav 5-item layout (Phase 2) ---------- */
.bottom-nav {
  /* Was 4 items; now supports up to 5 */
}
.bottom-nav-item {
  flex: 1 1 0;
  min-width: 0;
}
.bottom-nav-item span {
  font-size: 0.65rem;
}
@media (min-width: 400px) {
  .bottom-nav-item span {
    font-size: 0.7rem;
  }
}
@media (min-width: 768px) {
  .bottom-nav-item span {
    font-size: 0.78rem;
  }
}

/* ---------- Visually-hidden (sr-only) ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Promo banner (Phase 2 launch) ---------- */
.promo-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-4) 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(236, 72, 153, 0.12));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--r-lg);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  position: relative;
  overflow: hidden;
}
.promo-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.04));
  pointer-events: none;
}
.promo-banner:hover {
  transform: translateY(-1px);
  border-color: var(--brand-1);
  box-shadow: var(--shadow-md);
}
.promo-banner-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--brand-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.promo-banner-icon svg {
  width: 24px;
  height: 24px;
}
.promo-banner-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.promo-banner-text strong {
  color: var(--brand-1);
  font-size: 0.9rem;
  font-weight: 700;
}
.promo-banner-text span {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}
.promo-banner-arrow {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--brand-1);
  transform: rotate(0deg);
  /* In RTL the arrow visually points left, which is correct for "forward" */
}
[dir="rtl"] .promo-banner-arrow {
  transform: scaleX(-1);
}

/* Reels promo banner — distinct gradient styling */
.promo-banner-reels {
  border: 1px solid color-mix(in srgb, var(--brand-3) 30%, var(--border));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--brand-1) 8%, var(--bg-elevated)) 0%,
    color-mix(in srgb, var(--brand-3) 12%, var(--bg-elevated)) 100%
  );
}
.promo-banner-reels:hover {
  border-color: var(--brand-3);
}
.promo-banner-icon-reels {
  background: linear-gradient(135deg, var(--brand-3), var(--brand-2)) !important;
}
.promo-banner-reels .promo-banner-text strong {
  color: var(--brand-3);
  background: linear-gradient(135deg, var(--brand-2), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.promo-banner-reels .promo-banner-arrow {
  color: var(--brand-3);
}

/* Upload promo banner — green/teal accent */
.promo-banner-upload {
  border: 1px solid color-mix(in srgb, #10b981 30%, var(--border));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, #10b981 8%, var(--bg-elevated)) 0%,
    color-mix(in srgb, var(--brand-1) 8%, var(--bg-elevated)) 100%
  );
}
.promo-banner-upload:hover {
  border-color: #10b981;
}
.promo-banner-icon-upload {
  background: linear-gradient(135deg, #10b981, var(--brand-1)) !important;
}
.promo-banner-upload .promo-banner-text strong {
  background: linear-gradient(135deg, #10b981, var(--brand-1));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.promo-banner-upload .promo-banner-arrow {
  color: #10b981;
}

