/* ==========================================================================
   Game Catalog – styles.css
   1 Tokens · 2 Base · 3 Layout · 4 Components · 5 Hero · 6 Catalog
   7 Modal/Lightbox · 8 Admin tool · 9 Motion
   RTL is handled with CSS logical properties (inline-start/end, block-*),
   so the same sheet works unchanged for an LTR locale.
   ========================================================================== */

/* ---------- 1. Design tokens (dark by default) ---------- */
:root {
  color-scheme: dark;
  /* Brand: "مكتب حيدر كيارة" – deep indigo night + doodle orange, sampled from the shop logo
     (logo background ≈ #0B0022, doodle orange ≈ #BC6A14). Surfaces step up for elevation. */
  --bg: #0a0420;
  --surface-1: #120a2e;
  --surface-2: #1a1138;
  --surface-3: #241846;
  --line: rgb(255 214 170 / .08);
  --line-strong: rgb(255 214 170 / .16);
  /* text – warm white to sit well next to the orange */
  --text: #fbf5ec;
  --text-2: #c2b6d6;
  --text-3: #85799e;
  /* orange accent: brightened from the logo's #BC6A14 so it passes contrast on indigo */
  --accent: #e08a2c;
  --accent-hover: #f09c3e;
  --accent-deep: #bc6a14;
  --accent-soft: rgb(224 138 44 / .15);
  --accent-ink: #1c0d00; /* dark text on orange buttons */
  --pattern-opacity: .07;
  --ok: #34d399; --warn: #fbbf24; --danger: #f87171; --gold: #fbbf24;
  --steam: #66c0f4; --ps: #2f6bff;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow: 0 12px 40px -8px rgb(0 0 0 / .6);
  --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / .8);
  --ring: 0 0 0 2px var(--accent);

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1440px;

  --font-display: 'Lalezar', 'Noto Kufi Arabic', sans-serif; /* chunky display face like the shop sign */
  --font-head: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --fs-xs: .78rem;
  --fs-sm: clamp(.84rem, .82rem + .1vw, .9rem);
  --fs-md: clamp(.95rem, .92rem + .15vw, 1.02rem);
  --fs-lg: clamp(1.1rem, 1rem + .4vw, 1.3rem);
  --fs-xl: clamp(1.4rem, 1.15rem + 1vw, 2rem);
  --fs-hero: clamp(1.9rem, 1.3rem + 2.6vw, 3.6rem);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #fbf6ee; --surface-1: #fff; --surface-2: #fff; --surface-3: #f3ebdf;
  --line: rgb(40 20 60 / .09); --line-strong: rgb(40 20 60 / .18);
  --text: #160b2e; --text-2: #4d4266; --text-3: #8a7f9f;
  --accent: #bc6a14; --accent-hover: #a75c0f; --accent-ink: #fff;
  --accent-soft: rgb(188 106 20 / .1);
  --pattern-opacity: .09;
  --shadow: 0 12px 40px -12px rgb(40 20 60 / .25);
  --shadow-lg: 0 30px 80px -20px rgb(40 20 60 / .35);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-block-size: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 400 var(--fs-md)/1.75 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
/* the shop's gaming-doodle wallpaper, very faint, fixed behind everything */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url('pattern.svg') 0 0 / 360px repeat;
  opacity: var(--pattern-opacity);
}
img, video, iframe { max-inline-size: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.35; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; inset-block-start: 10px; inset-inline-start: 10px; inline-size: auto; block-size: auto; clip-path: none; z-index: 200; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); border-radius: 8px; }
[hidden] { display: none !important; }
.icon { inline-size: 1.1em; block-size: 1.1em; flex: none; }
/* names come in any script: dir=auto picks their direction, alignment follows the page */
[dir='auto'] { text-align: match-parent; }
/* directional icons point "forward" in the reading direction */
:dir(rtl) .flip-rtl { transform: scaleX(-1); }

/* ---------- 3. Layout ---------- */
.container { inline-size: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; }
.topbar {
  position: sticky; inset-block-start: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.6);
  border-block-end: 1px solid var(--line);
}
.topbar .container { display: flex; align-items: center; gap: clamp(10px, 2vw, 24px); block-size: 68px; }
/* phones: the admin header has up to 5 controls (brand, publish status/button, links, theme). A fixed 68px nowrap
   row pushed the last ones off-screen and made the whole page scroll sideways – let it wrap onto a second row. */
@media (max-width: 640px) {
  .topbar .container { block-size: auto; min-block-size: 68px; flex-wrap: wrap; padding-block: 8px; gap: 8px 10px; }
  .topbar .container > .btn { min-block-size: 38px; padding-inline: .8em; }
  body.admin .topbar { position: static; } /* two rows tall: don't pin it over the work area */
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font: 400 clamp(1.25rem, 1.1rem + .6vw, 1.6rem)/1 var(--font-display); white-space: nowrap; text-shadow: 0 2px 0 rgb(0 0 0 / .35); }
.brand-name b { color: var(--accent); font-weight: 400; }
/* round shop logo with an orange ring, like a sticker */
.brand-mark { inline-size: 44px; block-size: 44px; border-radius: 50%; overflow: hidden; flex: none; background: #0b0022; box-shadow: 0 0 0 2px var(--accent), 0 4px 14px -2px rgb(224 138 44 / .45); }
.brand-mark img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.topbar-search { flex: 1; max-inline-size: 520px; margin-inline: auto; position: relative; }
.topbar-search .input { padding-inline-start: 2.7em; border-radius: 999px; background: var(--surface-2); block-size: 42px; }
.topbar-search .icon { position: absolute; inset-inline-start: 1em; inset-block-start: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 600px) { .brand-name { display: none; } }

main { flex: 1; }
.section { padding-block: clamp(28px, 4vw, 48px); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-block-end: 20px; }
.section-head h2 { font: 400 clamp(1.6rem, 1.3rem + 1.2vw, 2.3rem)/1.3 var(--font-display); display: flex; align-items: baseline; gap: 12px; }
.count { font: 500 var(--fs-sm) var(--font-body); color: var(--text-3); }
.muted { color: var(--text-2); font-size: var(--fs-sm); }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-block: 32px 22px; }
.page-head h1 { font: 400 clamp(1.6rem, 1.3rem + 1.2vw, 2.3rem)/1.3 var(--font-display); }
.site-footer { border-block-start: 1px solid var(--line); padding-block: 30px 22px; color: var(--text-3); font-size: var(--fs-sm); background: color-mix(in srgb, var(--surface-1) 70%, transparent); }
.site-footer .container { display: grid; gap: 18px; }
.footer-main { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.footer-brand { font-size: 1.3rem; }
.footer-brand .brand-mark { inline-size: 40px; block-size: 40px; }

/* contact: WhatsApp + address + map (from shop-info.js) */
.contact { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; font-style: normal; }
.contact-item { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.contact-item .icon { inline-size: 36px; block-size: 36px; padding: 8px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); flex: none; }
.contact-item small { display: block; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.4; }
.contact-item:hover > span:last-child { color: var(--accent); }
.contact-map .icon { color: var(--accent); }

/* WhatsApp button in the header – WhatsApp green so it reads instantly */
/* (.btn.btn-wa: this block sits before the generic .btn rules, so it needs the extra class to win) */
.btn.btn-wa { background: #25d366; color: #062b14; border-color: transparent; font-weight: 700; }
.btn.btn-wa:hover { background: #3fe07a; }
@media (max-width: 760px) { .btn-wa .wa-num { display: none; } .btn.btn-wa { inline-size: 42px; padding: 0; border-radius: 999px; } }

/* ---------- 4. Components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-block-size: 42px; padding-block: .5em; padding-inline: 1.15em; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); font-weight: 600; font-size: var(--fs-sm);
  color: var(--text); white-space: nowrap;
  transition: background .2s, border-color .2s, transform .2s var(--ease), box-shadow .2s;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 8px 24px -6px rgb(224 138 44 / .55); }
.btn-light { background: #fff; color: #0b0d12; border-color: transparent; }
.btn-light:hover { background: #e9ecf2; }
.btn-glass { background: rgb(255 255 255 / .12); border-color: rgb(255 255 255 / .18); color: #fff; backdrop-filter: blur(10px); }
.btn-glass:hover { background: rgb(255 255 255 / .2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-lg { min-block-size: 50px; padding-inline: 1.5em; font-size: var(--fs-md); border-radius: 12px; }
.btn-icon { padding: 0; inline-size: 42px; block-size: 42px; min-block-size: 0; border-radius: 999px; }

.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.input, .select, .textarea {
  inline-size: 100%; min-block-size: 42px; padding-block: .5em; padding-inline: .95em;
  background: var(--surface-1); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.select { appearance: none; padding-inline-end: 2.4em; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a92a6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 1.1em; background-position: left .8em center; }
[dir='ltr'] .select { background-position: right .8em center; }
.textarea { min-block-size: 170px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-sm); direction: ltr; text-align: start; line-height: 1.7; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-block-size: 34px; padding-inline: 1em;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
}
button.chip { transition: background .2s, color .2s, border-color .2s; }
button.chip:hover { color: var(--text); border-color: var(--line-strong); }
button.chip[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.tag { display: inline-flex; padding-inline: .7em; border-radius: 6px; font-size: var(--fs-xs); font-weight: 600; background: rgb(255 255 255 / .1); color: inherit; line-height: 1.9; }
.badge { padding-inline: .6em; border-radius: 6px; font-size: var(--fs-xs); font-weight: 700; line-height: 1.8; color: #fff; }
.badge-steam { background: #1b2838; color: var(--steam); }
.badge-ps { background: var(--ps); }
.badge-manual { background: var(--accent); color: var(--accent-ink); }

/* ---------- Admin game editor (editor.js) ---------- */
.ed-modal { inline-size: min(100%, 920px); }
.ed-head { position: sticky; inset-block-start: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px clamp(16px, 3vw, 28px); background: var(--surface-1); border-block-end: 1px solid var(--line); }
.ed-head h2 { font-size: var(--fs-lg); }
.ed-form { display: grid; gap: 18px; padding: clamp(16px, 3vw, 28px); }
.ed-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.ed-note { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: var(--fs-sm); }
.ed-prose { font-family: var(--font-body); font-size: var(--fs-md); direction: inherit; text-align: start; min-block-size: 150px; }
.ed-image-row { display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 560px) { .ed-image-row { grid-template-columns: 1fr; } }
.ed-preview { position: relative; inline-size: 100%; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px dashed var(--line-strong); display: grid; place-items: center; }
.ed-preview-img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; }
.ed-preview-empty { color: var(--text-3); font-size: var(--fs-sm); }
.ed-image-ctl { display: grid; gap: 10px; align-content: start; }
.ed-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ed-shot { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.ed-shot img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.ed-shot .btn { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; inline-size: 30px; block-size: 30px; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 10px; position: sticky; inset-block-end: 0; padding-block: 12px; background: var(--surface-1); border-block-start: 1px solid var(--line); }

.toast-host { position: fixed; inset-block-end: 20px; inset-inline: 0; display: grid; justify-items: center; gap: 8px; z-index: 300; pointer-events: none; padding-inline: var(--gutter); }
.toast { pointer-events: auto; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); padding: .75em 1.2em; border-radius: 12px; box-shadow: var(--shadow); animation: rise .3s var(--ease); max-inline-size: 560px; font-size: var(--fs-sm); display: flex; gap: 10px; align-items: center; }
.toast::before { content: ''; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.ok::before { background: var(--ok); }
.toast.err::before { background: var(--danger); }

/* ---------- 5. Hero (featured carousel) ---------- */
.hero { position: relative; block-size: clamp(440px, 72vh, 720px); overflow: hidden; isolation: isolate; background: var(--surface-1); }
.hero-slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .8s ease, visibility .8s; }
.hero-slide.is-active { opacity: 1; visibility: visible; }
.hero-bg { position: absolute; inset: 0; z-index: -2; inline-size: 100%; block-size: 100%; object-fit: cover; transform: scale(1.06); transition: transform 8s linear; }
.hero-slide.is-active .hero-bg { transform: scale(1); }
/* scrim: darken the text side + fade into the page at the bottom */
.hero-slide::after { content: ''; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to bottom, rgb(0 0 0 / .55), transparent 22%),
    linear-gradient(to top, var(--bg) 0%, color-mix(in srgb, var(--bg) 75%, transparent) 25%, transparent 60%),
    linear-gradient(to right, rgb(10 4 32 / .9) 0%, rgb(10 4 32 / .62) 38%, transparent 75%); }
:root[dir='rtl'] .hero-slide::after { background:
    linear-gradient(to bottom, rgb(0 0 0 / .55), transparent 22%),
    linear-gradient(to top, var(--bg) 0%, color-mix(in srgb, var(--bg) 75%, transparent) 25%, transparent 60%),
    linear-gradient(to left, rgb(10 4 32 / .9) 0%, rgb(10 4 32 / .62) 38%, transparent 75%); }
.hero-content { position: absolute; inset-block-end: clamp(70px, 12vh, 120px); inset-inline: 0; color: #fff; }
.hero-content .inner { max-inline-size: 620px; display: grid; gap: 16px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; color: #ffc98a; }
.eyebrow::before { content: ''; inline-size: 18px; block-size: 2px; background: var(--accent); border-radius: 2px; }
.hero-title { font: 400 var(--fs-hero)/1.2 var(--font-display); text-shadow: 0 2px 30px rgb(0 0 0 / .5); }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; color: rgb(255 255 255 / .85); font-size: var(--fs-sm); }
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-meta .icon { opacity: .75; }
.hero-desc { color: rgb(255 255 255 / .78); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-inline-size: 56ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 6px; }
.hero-picker { position: absolute; inset-block-end: clamp(70px, 12vh, 120px); inset-inline-end: var(--gutter); display: flex; gap: 10px; z-index: 2; }
.hero-thumb { inline-size: 64px; block-size: 64px; padding: 0; border-radius: 12px; overflow: hidden; border: 2px solid rgb(255 255 255 / .2); background: #000; opacity: .55; transition: opacity .25s, border-color .25s, transform .25s var(--ease); }
.hero-thumb img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.hero-thumb:hover { opacity: .85; }
.hero-thumb[aria-selected='true'] { opacity: 1; border-color: #fff; transform: translateY(-4px); }
.hero-progress { position: absolute; inset-block-end: 0; inset-inline: 0; block-size: 3px; background: rgb(255 255 255 / .08); }
.hero-progress i { display: block; block-size: 100%; inline-size: 0; background: var(--accent); }
.hero-progress i.run { animation: progress var(--hero-interval, 7s) linear forwards; }
.hero.paused .hero-progress i { animation-play-state: paused; }
@media (max-width: 760px) {
  .hero-picker { inset-inline: var(--gutter); inset-block-end: 22px; justify-content: center; }
  .hero-thumb { inline-size: 48px; block-size: 48px; }
  .hero-content { inset-block-end: 90px; }
  .hero-desc { -webkit-line-clamp: 2; }
}

/* ---------- 6. Catalog ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 20px; margin-block-end: 26px; }
/* genres wrap onto more lines (no hidden horizontal scroll); app.js shows the top ones + a "+N" toggle */
.chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 420px; padding-block: 2px; }
.chip-count { display: inline-grid; place-items: center; min-inline-size: 1.6em; padding-inline: .35em; border-radius: 999px;
  background: rgb(255 255 255 / .08); font-size: .72rem; font-weight: 700; line-height: 1.6; color: var(--text-3); }
button.chip[aria-pressed='true'] .chip-count { background: rgb(0 0 0 / .18); color: inherit; }
.chip-more { border-style: dashed; color: var(--accent); }
.chip-more:hover { border-color: var(--accent); }

/* pagination: ‹ السابق  ١ ٢ ٣ … ٩  التالي › */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-block-start: 36px; }
.pg-nums { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-inline-size: 42px; block-size: 42px; padding-inline: .8em;
  border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-weight: 700; font-size: var(--fs-sm);
  transition: background .2s, border-color .2s, transform .2s var(--ease); }
.pg-btn:hover:not([disabled]):not([aria-current]) { border-color: var(--accent); background: var(--surface-3); }
.pg-btn[aria-current='page'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); cursor: default; box-shadow: 0 6px 18px -6px rgb(224 138 44 / .6); }
.pg-btn[disabled] { opacity: .35; cursor: not-allowed; }
.pg-gap { color: var(--text-3); padding-inline: 2px; align-self: center; }
.pg-info { inline-size: 100%; text-align: center; color: var(--text-3); font-size: var(--fs-xs); }
/* phones: smaller buttons so ‹ ١ ٢ ٣ ٤ … ٣٠ › stay on ONE row (the "next" arrow used to wrap onto its own line) */
@media (max-width: 520px) {
  .pager { gap: 8px 6px; }
  .pg-label { display: none; }
  .pg-btn { min-inline-size: 36px; block-size: 38px; padding-inline: .3em; border-radius: 10px; }
  .pg-nums { gap: 4px; }
  .pg-step { padding-inline: 0; }
}
@media (max-width: 350px) { .pg-btn { min-inline-size: 30px; block-size: 36px; font-size: .8rem; } .pg-nums { gap: 3px; } }
.sort { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: var(--fs-sm); }
.sort .select { inline-size: auto; min-inline-size: 190px; background-color: var(--surface-2); }

/* Platform switch: segmented control (الكل / PS5 / PS4) */
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); }
.seg button { min-block-size: 36px; min-inline-size: 64px; padding-inline: 1.1em; border: 0; border-radius: 999px; background: transparent; color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); transition: background .2s, color .2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked='true'] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px -4px rgb(224 138 44 / .6); }

/* console tag on the cover (top inline-start corner; the Arabic tag takes the other one).
   No `direction: ltr` on positioned badges: inset-inline-* follows the element's own
   direction, so it would flip the badge into the opposite corner. */
.console-tag { position: absolute; inset-block-start: 10px; inset-inline-start: 52px; z-index: 1; padding-inline: .6em; border-radius: 7px; font-size: var(--fs-xs); font-weight: 800; line-height: 1.9; letter-spacing: .02em; unicode-bidi: isolate;
  background: rgb(10 4 32 / .78); color: #fff; border: 1px solid rgb(224 138 44 / .55); backdrop-filter: blur(6px); }
/* Arabic-support tag: official = solid orange, unofficial = outlined. It sits on its own row under the
   select button (top-start column): beside the console tag the two collided on 140–190px phone cards. */
.arabic-tag { position: absolute; inset-block-start: 52px; inset-inline-start: 10px; max-inline-size: calc(100% - 20px); z-index: 1; padding-inline: .6em; border-radius: 7px; font-size: var(--fs-xs); font-weight: 800; line-height: 1.9; backdrop-filter: blur(6px); }
.arabic-tag.ar-official { background: var(--accent); color: var(--accent-ink); }
.arabic-tag.ar-fan { background: rgb(10 4 32 / .78); color: #ffc98a; border: 1px dashed rgb(224 138 44 / .8); }
.modal-genres .tag-console { background: var(--accent); color: var(--accent-ink); font-weight: 800; direction: ltr; }

/* 2 columns on phones (even 320px wide: 2×128 + gap < 288), ~5–7 on desktop – one fluid rule, no breakpoints */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(128px, 22vw, 210px)), 1fr)); gap: clamp(14px, 2vw, 26px) clamp(12px, 1.6vw, 20px); }
.card { position: relative; display: grid; gap: 12px; align-content: start; }
.card-open { display: grid; gap: 12px; align-content: start; padding: 0; text-align: start; background: none; border: 0; color: inherit; border-radius: var(--radius); }
.card-open:focus-visible { outline-offset: 6px; }
/* select-for-order toggle, round like a checkbox (top inline-start; the console tag shifts over) */
.card-select { position: absolute; inset-block-start: 10px; inset-inline-start: 10px; z-index: 2; inline-size: 34px; block-size: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgb(255 255 255 / .35); background: rgb(10 4 32 / .62); color: #fff; backdrop-filter: blur(6px);
  transition: background .2s, border-color .2s, color .2s, transform .2s var(--ease); }
.card-select:hover { background: rgb(10 4 32 / .9); transform: scale(1.08); }
.card-select .icon { inline-size: 17px; block-size: 17px; }
.card.selected .card-select { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.card.selected .card-media::after { box-shadow: inset 0 0 0 2px var(--accent); }
.card-media { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-sm); isolation: isolate;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease); }
.card-media::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .35s; pointer-events: none; }
.card-media img { inline-size: 100%; block-size: 100%; object-fit: cover; transition: transform .6s var(--ease), opacity .4s; opacity: 0; }
.card-media img.loaded { opacity: 1; }
.card-media .shade { position: absolute; inset: 0; background: linear-gradient(to top, rgb(0 0 0 / .75), transparent 45%); opacity: .9; transition: opacity .3s; }
.card-size { position: absolute; inset-block-end: 10px; inset-inline-start: 10px; max-inline-size: calc(100% - 20px); line-height: 1.35; display: inline-flex; align-items: center; gap: 6px; color: #fff; font-size: var(--fs-xs); font-weight: 700; unicode-bidi: isolate; text-shadow: 0 1px 6px rgb(0 0 0 / .6); }
.card-play { position: absolute; inset-block-end: 10px; inset-inline-end: 10px; inline-size: 34px; block-size: 34px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #0b0d12; opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s var(--ease); }
.card-play .icon { inline-size: 14px; block-size: 14px; }
/* touch screens have no hover to reveal it, and it would sit on top of a two-console size label */
@media (hover: none) { .card-play { display: none; } }
.card:hover .card-media, .card-open:focus-visible .card-media { transform: translateY(-6px); box-shadow: var(--shadow); }
.card:hover .card-media::after, .card-open:focus-visible .card-media::after { box-shadow: inset 0 0 0 2px var(--accent); }
.card:hover .card-media img { transform: scale(1.05); }
.card:hover .card-play, .card-open:focus-visible .card-play { opacity: 1; transform: none; }
.card-body { display: grid; gap: 2px; padding-inline: 2px; }
.card-title { font: 600 var(--fs-md)/1.5 var(--font-head); color: var(--text); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Floating order bar: appears once at least one game is selected. */
.quote-bar { position: fixed; inset-block-end: 14px; inset-inline: 0; z-index: 90; pointer-events: none; animation: rise .3s var(--ease); }
.quote-bar .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; padding: 10px 18px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface-1) 94%, transparent); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); backdrop-filter: blur(16px) saturate(1.4); pointer-events: auto; }
.quote-info { display: flex; align-items: baseline; gap: 12px; font-weight: 700; }
.quote-total { color: var(--accent); font-weight: 800; }
.quote-actions { display: flex; gap: 8px; }
@media (max-width: 560px) { .quote-actions { flex: 1 1 100%; } .quote-actions .btn { flex: 1; } }
/* keep toasts above the bar while it is visible */
body.has-quote .toast-host { inset-block-end: 96px; }
/* the fixed bar (up to ~100px tall on phones) must not cover the end of the page: leave room for it */
body.has-quote { padding-block-end: 124px; }

.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding-block: 80px; color: var(--text-2); }
.empty .icon { inline-size: 48px; block-size: 48px; color: var(--text-3); stroke-width: 1.5; }
.empty h3 { font-size: var(--fs-lg); color: var(--text); }
.empty-logo { inline-size: 120px; block-size: 120px; border-radius: 50%; box-shadow: 0 0 0 3px var(--accent), var(--shadow); margin-block-end: 6px; }
.skeleton { display: grid; gap: 12px; }
.skeleton::before, .skeleton::after { content: ''; border-radius: var(--radius); background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton::before { aspect-ratio: 1 / 1; }
.skeleton::after { block-size: 14px; inline-size: 70%; border-radius: 6px; }

/* ---------- 7. Modal + Lightbox ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: clamp(0px, 3vw, 40px); background: rgb(3 4 8 / .8); backdrop-filter: blur(8px); animation: fade .25s ease; overflow: auto; }
.modal { position: relative; inline-size: min(100%, 1120px); max-block-size: 100%; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: rise .35s var(--ease); }
@media (max-width: 680px) { .overlay { padding: 0; } .modal { border-radius: 0; block-size: 100%; border: 0; } }
.modal-close { position: absolute; inset-block-start: 14px; inset-inline-end: 14px; z-index: 5; }
.media-stage { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.media-stage video, .media-stage > img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.media-stage iframe { inline-size: 100%; block-size: 100%; border: 0; }
.media-stage .yt-thumb { position: absolute; inset: 0; }
.modal-body { display: grid; gap: clamp(22px, 3vw, 40px); padding: clamp(20px, 3.5vw, 40px); }
@media (min-width: 860px) { .modal-body { grid-template-columns: minmax(0, 1fr) 300px; } }
.modal-main { display: grid; gap: 24px; align-content: start; min-inline-size: 0; }
.modal-title { font-size: var(--fs-xl); font-weight: 800; }
.modal-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 10px; }
.modal-genres .tag { background: var(--surface-3); color: var(--text-2); }
.section-title { font-size: var(--fs-md); font-weight: 700; color: var(--text); margin-block-end: 10px; display: flex; align-items: center; gap: 8px; }
.section-title .icon { color: var(--text-3); }
.desc { white-space: pre-line; color: var(--text-2); max-inline-size: 72ch; }
.note { color: var(--text-3); font-size: var(--fs-xs); margin-block-start: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 10px; }
.gallery button { padding: 0; border: 0; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 16 / 9; background: var(--surface-2); position: relative; }
.gallery button::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s; }
.gallery button:hover::after { box-shadow: inset 0 0 0 2px var(--accent); }
.gallery img { inline-size: 100%; block-size: 100%; object-fit: cover; transition: transform .4s var(--ease); }
.gallery button:hover img { transform: scale(1.05); }

.modal-aside { display: grid; gap: 16px; align-content: start; }
@media (min-width: 860px) { .modal-aside { position: sticky; inset-block-start: 20px; } }
.modal-cover { position: relative; isolation: isolate; overflow: hidden; inline-size: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius); background: var(--surface-2); box-shadow: var(--shadow); }
.modal-cover img { inline-size: 100%; block-size: 100%; object-fit: cover; }

/* Letterbox for non-square cover art (set by fitCover() in app.js): show the
   whole cover and fill the side bands with a blurred, darkened copy of it. */
.letterbox img { object-fit: contain; }
.letterbox::before {
  content: ''; position: absolute; inset: -24px; z-index: -1;
  background: var(--cover-bg) center / cover no-repeat;
  filter: blur(22px) saturate(1.3) brightness(.55);
}
.card:hover .letterbox img { transform: scale(1.03); }
@media (max-width: 859px) { .modal-cover { display: none; } }
.size-box { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.size-box .icon { inline-size: 28px; block-size: 28px; color: var(--accent); }
.size-box small { display: block; color: var(--text-2); font-size: var(--fs-xs); }
.size-box strong { font: 800 var(--fs-xl)/1.2 var(--font-head); direction: ltr; display: block; text-align: start; unicode-bidi: plaintext; }
.size-lines { display: grid; gap: 2px; }
.size-lines > div { display: flex; align-items: baseline; gap: 10px; }
.size-lines strong { font-size: var(--fs-lg); }
.size-con { min-inline-size: 2.6em; color: var(--accent); font: 800 var(--fs-xs) var(--font-head); direction: ltr; text-align: start; }
/* «أضف إلى الطلب» in the details modal */
.btn-quote { inline-size: 100%; }
.btn-quote.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.facts { margin: 0; display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.fact { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 13px 16px; }
.fact + .fact { border-block-start: 1px solid var(--line); }
.fact .icon { grid-row: span 2; color: var(--text-3); inline-size: 20px; block-size: 20px; }
.fact dt { color: var(--text-3); font-size: var(--fs-xs); }
.fact dd { margin: 0; font-weight: 600; font-size: var(--fs-sm); }
.stars { display: inline-flex; align-items: center; gap: 6px; }
.stars .icon { color: var(--gold); fill: var(--gold); inline-size: 16px; block-size: 16px; grid-row: auto; }

.lightbox { background: rgb(0 0 0 / .95); z-index: 150; }
.lightbox img { max-inline-size: min(100%, 1600px); max-block-size: 86dvh; object-fit: contain; border-radius: 10px; box-shadow: var(--shadow-lg); }
.lb-btn { position: fixed; }
.lb-prev { inset-inline-start: 18px; inset-block-start: 50%; translate: 0 -50%; }
.lb-next { inset-inline-end: 18px; inset-block-start: 50%; translate: 0 -50%; }
.lb-close { inset-inline-end: 18px; inset-block-start: 18px; }
.lb-count { position: fixed; inset-block-end: 18px; inset-inline: 0; text-align: center; color: rgb(255 255 255 / .7); font-size: var(--fs-sm); direction: ltr; }

/* ---------- 8. Admin tool ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 22px; align-items: start; padding-block-end: 48px; }
.panel { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(18px, 2.6vw, 28px); display: grid; gap: 16px; }
.panel h2 { font-size: var(--fs-lg); }
.panel-sub { color: var(--text-3); font-size: var(--fs-sm); margin-block-start: -10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.row > .grow { flex: 1 1 200px; }
.results { display: grid; gap: 8px; max-block-size: 420px; overflow: auto; scrollbar-width: thin; }
.result { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; text-align: start; padding: 8px; padding-inline-end: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; transition: border-color .2s, background .2s; }
.result:hover { border-color: var(--line-strong); }
.result[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); }
.result img { inline-size: 52px; block-size: 52px; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.result .name { font-weight: 600; font-size: var(--fs-sm); }
.result .muted { font-size: var(--fs-xs); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-block-size: 42px; font-size: var(--fs-sm); }
.switch input { inline-size: 1.15em; block-size: 1.15em; accent-color: var(--accent); }
.progress { block-size: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; block-size: 100%; inline-size: 0; background: var(--accent); border-radius: inherit; transition: inline-size .4s var(--ease); }
.log { display: grid; gap: 2px; max-block-size: 260px; overflow: auto; font-size: var(--fs-sm); }
.log > div { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.log .ok { color: var(--ok); } .log .error { color: var(--danger); } .log .skipped { color: var(--warn); }
/* GitHub publish status pill (admin header) */
.pub { display: inline-flex; align-items: center; gap: 8px; min-block-size: 36px; padding-inline: .9em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); font-size: var(--fs-sm); white-space: nowrap; }
.pub::before { content: ''; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.pub[data-state='pending']::before, .pub[data-state='publishing']::before { background: var(--warn); animation: blink 1s ease-in-out infinite alternate; }
.pub[data-state='error'] { color: var(--danger); cursor: help; }
.pub[data-state='error']::before { background: var(--danger); }
.pub[data-state='disabled']::before { background: var(--text-3); }
@keyframes blink { to { opacity: .25; } }
@media (max-width: 760px) { .pub { display: none; } }
.tbl-wrap { overflow: auto; max-block-size: 420px; border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { inline-size: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th { position: sticky; inset-block-start: 0; background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: var(--fs-xs); }
.tbl th, .tbl td { text-align: start; padding: 10px 14px; border-block-end: 1px solid var(--line); }
.tbl tr:last-child td { border-block-end: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- 9. Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
@keyframes shimmer { to { background-position: -300% 0; } }
@keyframes progress { to { inline-size: 100%; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .hero-bg { transform: none !important; }
  .card:hover .card-media, .card-open:focus-visible .card-media { transform: none; }
}
