/* public/css/games.css — صفحهٔ کتابخانهٔ بازی‌ها (/games)
   توکن‌ها (رنگ، شعاع، سایه، فونت) از ezlan-tokens.css می‌آیند و باید قبل از این فایل لود شوند. */

:root {
  --gap: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 12px); }
html.gl-lock, html.gl-lock body { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  line-height: 1.7;
  background: var(--bg);
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.gl-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;
}
.gl-skip {
  position: absolute; top: -60px; inset-inline-start: 12px; z-index: 100;
  background: var(--accent); color:var(--on-accent); font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: var(--r-pill); text-decoration: none;
}
.gl-skip:focus { top: 10px; }

/* ---------- نوار بالا (هم‌ظاهر با صفحهٔ اصلی) ---------- */

/* ---------- ساختار صفحه ---------- */
.gl-main { width: 100%; max-width: var(--page-w); margin: 0 auto; padding: 18px 20px 28px; }

/* ---------- Hero (جمع‌وجور) ---------- */
.gl-hero {
  position: relative; overflow: hidden; isolation: isolate;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  min-height: 150px; padding: 26px 30px;
  display: flex; align-items: center;
  background: var(--surface); box-shadow: var(--shadow-1);
}
.gl-hero-art {
  position: absolute; inset: 0 auto 0 0; width: 58%; z-index: -1;
  background-image: image-set(url("/images/games-hero.webp") type("image/webp"), url("/images/games-hero.jpg") type("image/jpeg"));
  background-image: -webkit-image-set(url("/images/games-hero.jpg") 1x);
  background-size: cover; background-position: center 38%;
  opacity: 0.38; filter: saturate(0.55);
  -webkit-mask-image: linear-gradient(to right, #000 25%, transparent 100%);
          mask-image: linear-gradient(to right, #000 25%, transparent 100%);
}
.gl-hero::after { /* پرده برای کنتراست متن */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to left, var(--surface) 0%, rgba(var(--surface-rgb), 0.82) 50%, rgba(var(--surface-rgb), 0) 100%);
}
.gl-hero-text { max-width: 640px; }
.gl-hero h1 {
  margin: 0 0 6px; font-size: clamp(22px, 3.4vw, 32px); font-weight: 800; line-height: 1.4;
  display: flex; align-items: center; gap: 12px;
}
.gl-hero-icon { flex: none; width: 34px; height: 34px; color: var(--accent-ink); }
.gl-hero p { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.gl-hero-stat {
  display: inline-flex !important; align-items: center; gap: 8px; margin-top: 12px !important;
  font-size: 12.5px; padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink-2);
}
.gl-hero-stat[hidden] { display: none !important; }
.gl-hero-stat strong { color: var(--accent-ink); font-size: 15px; font-weight: 800; }

/* ---------- جست‌وجو و فیلتر ---------- */
.gl-toolbar { margin-top: 16px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.gl-toolbar > * { min-width: 0; }
.gl-search { position: relative; display: flex; align-items: center; }
.gl-search-icon {
  position: absolute; inset-inline-start: 16px; width: 20px; height: 20px;
  color: var(--ink-3); pointer-events: none;
}
.gl-search input {
  width: 100%; height: 50px; padding-inline: 46px 44px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 15px; outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none; appearance: none;
}
.gl-search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.gl-search input::placeholder { color: var(--ink-3); }
.gl-search input:hover { border-color: var(--line-strong); }
.gl-search input:focus {
  border-color: var(--accent); background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}
.gl-search-clear {
  position: absolute; inset-inline-end: 8px; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
}
.gl-search-clear:hover { background: var(--surface-3); color: var(--ink); }
.gl-search-clear svg { width: 18px; height: 18px; }
.gl-search-clear[hidden] { display: none; }

.gl-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; min-width: 0; max-width: 100%; }
.gl-filter-group { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
.gl-filter-label { flex: none; font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.gl-chips { display: flex; gap: 8px; min-width: 0; }
.gl-chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 6px 14px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.gl-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.gl-chip[aria-pressed="true"] {
  color: var(--accent-ink); background: var(--accent-soft-2); border-color: var(--accent-line);
}
.gl-chip-n { font-size: 11.5px; font-weight: 700; padding: 0 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--ink-2); }
.gl-chip[aria-pressed="true"] .gl-chip-n { background: var(--accent-soft-2); color: var(--accent-ink); }
.gl-chip.is-zero:not([aria-pressed="true"]) { opacity: 0.5; }

.gl-reset {
  display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 14px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: transparent; border: 1px dashed var(--line-strong);
}
.gl-reset:hover { color: var(--ink); border-color: var(--ink-3); }
.gl-reset svg { width: 16px; height: 16px; }
.gl-reset[hidden] { display: none; }

/* ---------- چیدمان نتایج + ستون راهنما ---------- */
.gl-layout { margin-top: 18px; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.gl-results { min-width: 0; outline: none; scroll-margin-top: calc(var(--nav-h) + 12px); }

.gl-results-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  margin-bottom: 14px; min-height: 40px;
}
.gl-count { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.gl-count strong { color: var(--ink); font-weight: 800; font-size: 15px; }
.gl-count .gl-muted { color: var(--ink-3); font-size: 12.5px; }
.gl-install-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 14px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 600; color: var(--accent-ink);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.gl-install-btn:hover { background: var(--accent-soft-2); }
.gl-install-btn svg { width: 17px; height: 17px; }
.gl-install-btn[hidden] { display: none; }

/* ---------- گرید کارت‌ها ---------- */
.gl-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr));
}
.gl-grid[hidden], .gl-filter-group[hidden] { display: none; }
.gl-grid > li { display: flex; min-width: 0; }

.gl-card {
  flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: start;
  padding: 0; overflow: hidden; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.gl-card:hover { border-color: var(--accent-line); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.gl-card:active { transform: translateY(0); }

/* کاور: نسبت ثابت → هیچ پرشی موقع لود عکس نداریم */
.gl-cover {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--surface-3);
}
.gl-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s ease; }
.gl-cover.is-loaded img { opacity: 1; }
/* عکس‌های مربعی/لوگویی: کامل و وسط، روی نسخهٔ محو‌شدهٔ خودشون */
.gl-cover.is-art::before {
  content: ""; position: absolute; inset: -14px; background: var(--cover) center / cover;
  filter: blur(16px) saturate(1.25) brightness(0.95);
}
.gl-cover.is-art img { object-fit: contain; }
/* بدون عکس: جای‌نگه‌دار هماهنگ با برند */
.gl-cover.is-missing img { display: none; }
.gl-cover.is-missing::after {
  content: ""; position: absolute; inset: 0;
  background: url("/favicon-192.png") center / 44px no-repeat, var(--surface-3);
  opacity: 0.85;
}
.gl-dl-flag {
  position: absolute; inset-block-start: 8px; inset-inline-start: 8px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 8px;
  font-size: 11px; font-weight: 700; color: var(--accent-ink);
  background: rgba(var(--surface-rgb), 0.94); border: 1px solid var(--accent-line); border-radius: var(--r-pill);
}
.gl-dl-flag svg { width: 12px; height: 12px; }

.gl-body { flex: 1; display: flex; flex-direction: column; gap: 9px; padding: 12px 12px 12px; }
.gl-name {
  font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 3em; overflow-wrap: anywhere;
}
.gl-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.gl-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; min-height: 24px;
  font-size: 11.5px; font-weight: 600; line-height: 1.4; border-radius: var(--r-pill);
  color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line);
}
.gl-badge svg { width: 13px; height: 13px; flex: none; }
.gl-badge.b-lan { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.gl-badge.b-ip { color: var(--badge-ip); background: var(--badge-ip-bg); border-color: var(--badge-ip-line); }
.gl-badge.b-direct { color: var(--badge-direct); background: var(--badge-direct-bg); border-color: var(--badge-direct-line); }

.gl-cta {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 8px 12px; border-radius: 12px; font-size: 12.5px; font-weight: 700; color: var(--accent-ink);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  transition: background 0.18s ease;
}
.gl-cta svg { flex: none; width: 15px; height: 15px; }
.gl-card:hover .gl-cta { background: var(--accent-soft-2); }

/* ---------- حالت بدون نتیجه ---------- */
.gl-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 48px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  background: var(--surface-2);
}
.gl-empty[hidden] { display: none; }
.gl-empty svg { width: 44px; height: 44px; color: var(--ink-3); }
.gl-empty p { margin: 0; color: var(--ink-2); font-size: 15px; font-weight: 600; }

.gl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 20px;
  border-radius: var(--r-md); font-size: 13.5px; font-weight: 700; text-decoration: none; border: 0;
  color:var(--on-accent); background: var(--accent);
}
.gl-btn:hover { filter: brightness(1.06); }
.gl-btn svg { width: 17px; height: 17px; }
.gl-btn-outline {
  color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--accent-line);
  width: 100%;
}
.gl-btn-outline:hover { background: var(--accent-soft-2); filter: none; }

/* ---------- صفحه‌بندی ---------- */
.gl-pagination { margin-top: 22px; display: flex; justify-content: center; }
.gl-pagination[hidden] { display: none; }
.gl-pagination ul {
  list-style: none; margin: 0; padding: 6px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center;
  border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line);
}
.gl-page {
  min-width: 40px; height: 40px; padding: 0 10px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 14px;
}
.gl-page:hover:not([disabled]):not([aria-current]) { background: var(--surface-3); color: var(--ink); }
.gl-page[aria-current="page"] { color:var(--on-accent); background: var(--accent); cursor: default; }
.gl-page[disabled] { opacity: 0.35; cursor: not-allowed; }
.gl-page svg { width: 18px; height: 18px; }
.gl-page-gap { padding: 0 4px; color: var(--ink-3); }

/* ---------- ستون راهنما ---------- */
.gl-side { display: grid; gap: 14px; align-content: start; }
.gl-side-card {
  padding: 18px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line);
}
.gl-side-card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 9px; }
.gl-side-card h2 svg { flex: none; width: 20px; height: 20px; color: var(--accent-ink); }
.gl-side-card p { margin: 0 0 14px; font-size: 13px; line-height: 1.95; color: var(--ink-2); }
.gl-side-card p:last-child { margin-bottom: 0; }

.gl-noscript { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink-2); font-size: 13px; }
.gl-noscript ul { margin: 8px 0 0; padding-inline-start: 20px; }


/* ---------- مودال‌ها ---------- */
.gl-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: var(--overlay);
}
.gl-overlay[hidden] { display: none; }
.gl-modal {
  position: relative; width: 100%; max-width: 560px; max-height: min(88vh, 760px); display: flex; flex-direction: column;
  border-radius: var(--r-lg); overflow: hidden; outline: none;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
}
.gl-modal-scroll { padding: 20px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.gl-modal-cover { position: relative; margin: -20px -20px 16px; aspect-ratio: 16 / 7; overflow: hidden; background: var(--surface-3); }
.gl-modal-cover[hidden] { display: none; }
.gl-modal-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gl-modal-cover.is-art::before { content: ""; position: absolute; inset: -14px; background: var(--cover) center / cover; filter: blur(18px) saturate(1.25) brightness(0.95); }
.gl-modal-cover.is-art img { object-fit: contain; }
.gl-modal-cover::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; background: linear-gradient(to top, var(--surface), transparent); pointer-events: none; }
.gl-modal-cover.is-missing img { display: none; }
.gl-modal-cover.is-missing { background: url("/favicon-192.png") center / 48px no-repeat, var(--surface-3); }

.gl-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.gl-modal-head h2 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.6; overflow-wrap: anywhere; }
.gl-modal-close {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.gl-modal-close:hover { color: var(--ink); background: var(--surface-3); }
.gl-modal-close svg { width: 18px; height: 18px; }
.gl-modal .gl-badges { margin-bottom: 10px; }
.gl-modal-type { margin: 0 0 12px; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--ink-3); text-align: end; }
.gl-modal-type[hidden], .gl-modal-desc[hidden], .gl-modal-note[hidden], .gl-modal-blog[hidden], .gl-modal-download[hidden] { display: none; }
.gl-modal-desc { margin: 0 0 14px; font-size: 13.5px; color: var(--ink-2); line-height: 1.95; }

.gl-steps { margin: 0 0 14px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.gl-steps li {
  counter-increment: step; position: relative; padding: 11px 14px; padding-inline-start: 48px; font-size: 13.5px; line-height: 1.9; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; overflow-wrap: anywhere;
}
.gl-steps li::before {
  content: counter(step, persian); position: absolute; inset-inline-start: 12px; inset-inline-end: auto; top: 10px;
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  font-size: 12px; font-weight: 800; color:var(--on-accent); background: var(--accent);
}
.gl-modal-note { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-3); }
.gl-modal-blog {
  display: block; padding: 12px 14px; margin-bottom: 6px; border-radius: 14px; font-size: 13px; font-weight: 700; text-decoration: none; color: var(--accent-ink);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.gl-modal-blog:hover { background: var(--accent-soft-2); }
.gl-modal-download {
  flex: none; margin: 0; display: block; text-align: center; padding: 15px; font-size: 14.5px; font-weight: 800; text-decoration: none;
  color:var(--on-accent); background: var(--accent);
}
.gl-modal-download:hover { filter: brightness(1.06); }

/* آموزش نصب ویندوز (منتقل‌شده از صفحهٔ اصلی) */
.tut-gif { display: block; width: 100%; border-radius: 14px; margin-bottom: 14px; border: 1px solid var(--line); }
.tut-step { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin-bottom: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.tut-step svg { flex: none; width: 28px; height: 28px; color: var(--accent-ink); }
.tut-step h4 { margin: 0 0 4px; font-size: 14px; font-weight: 800; }
.tut-step p { margin: 0; font-size: 13px; line-height: 1.9; color: var(--ink-2); }

/* ---------- ریسپانسیو ---------- */
@media (max-width: 639px) {
  .gl-main { padding: 12px 14px 24px; }
  .gl-hero { min-height: 118px; padding: 18px 16px; }
  .gl-hero-art { width: 100%; opacity: 0.32; }
  .gl-hero::after { background: linear-gradient(to left, var(--surface), rgba(var(--surface-rgb), 0.82)); }
  .gl-hero h1 { gap: 9px; }
  .gl-hero-icon { width: 28px; height: 28px; }
  .gl-hero p { font-size: 13px; }
  /* فیلترها: هر گروه یک ردیف قابل‌پیمایش افقی داخل خودش؛ صفحه هیچ‌وقت اسکرول افقی نمی‌گیره */
  .gl-filters { flex-direction: column; align-items: stretch; gap: 10px; }
  .gl-filter-group { flex-direction: column; align-items: stretch; gap: 6px; }
  .gl-chips { overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .gl-chips::-webkit-scrollbar { display: none; }
  .gl-reset { align-self: flex-start; }
  .gl-name { font-size: 13px; }
  .gl-body { padding: 10px; gap: 8px; }
  .gl-cta { font-size: 12px; padding: 7px 10px; }
  .gl-overlay { align-items: flex-end; padding: 0; }
  .gl-modal { max-width: none; max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .gl-page { min-width: 38px; height: 42px; }
}
/* موبایل باریک: کارت بازی به‌صورت ردیف (تصویر کنار متن) تا اسم‌ها و برچسب‌ها کامل و خوانا بمونن */
@media (max-width: 479px) {
  .gl-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .gl-card { flex-direction: row; align-items: stretch; }
  .gl-cover { flex: none; width: 108px; aspect-ratio: auto; min-height: 112px; }
  .gl-body { padding: 10px 12px; gap: 6px; justify-content: center; }
  .gl-name { min-height: 0; font-size: 14px; }
  .gl-dl-flag { inset-block-start: 6px; inset-inline-start: 6px; padding: 2px 7px 2px 6px; }
  .gl-cta { margin-top: 2px; padding: 6px 10px; }
}

@media (min-width: 640px) {
  .gl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
  .gl-side { grid-template-columns: 1fr 1fr; }
  .gl-name { font-size: 14.5px; }
}
@media (min-width: 1024px) {
  .gl-layout { grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
  /* در RTL ستون اول سمت راسته: ستون راهنما مثل طرح مرجع سمت راست می‌شینه */
  .gl-side { grid-column: 1; grid-row: 1; grid-template-columns: 1fr; position: sticky; top: calc(var(--nav-h) + 16px); }
  .gl-results { grid-column: 2; grid-row: 1; }
  .gl-hero { min-height: 168px; padding: 28px 38px; }
}
@media (min-width: 1280px) {
  .gl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .gl-card:hover { transform: none; }
}
