/*
 * @almadah-clean-room — كُتب من الصفر من وصف السلوك، لا نسخًا من كود المورّد (10/11/2026)
 *
 * تنسيق الرئيسية الجديدة (resources/views/almadah/home). بطاقة المنتج نفسها من am-plp.css (am-card).
 * كل الأصناف بالبادئة am- ولا تعتمد على ملفات المورّد. الألوان من tokens طبقة almadah-clean.css (--c-*)
 * مع قيم احتياطية — لا تركواز هنا (قاعدة المالك 25/10: التركواز للهيدر والفوتر فقط).
 * الاتجاه منطقي (inline-start/end) فيعمل بالعربية والإنجليزية بلا قواعد مكرّرة.
 *
 * المسارات الأفقية (am-rail): شبكة عمودية التدفق تُمرَّر بالسحب مع scroll-snap، وعدد العناصر في العرض
 * متغيّر --per لكل نوع ولكل عرض شاشة (مطابق لما تعرضه الرئيسية الحالية).
 */

.am-home {
    --am-ink: var(--c-ink, #0f1111);
    --am-ink-2: var(--c-ink-2, #565959);
    --am-line: var(--c-line, #d5d9d9);
    --am-line-soft: var(--c-line-soft, #e7e7e7);
    --am-band: var(--c-band, #f7f7f7);
    --am-hover: var(--c-hover, #f7fafa);
    --am-link: var(--c-link, #0b5cad);
    --am-link-h: var(--c-link-h, #c7511f);
    --am-sale: var(--c-sale, #cc0c39);
    --am-yellow: var(--c-yellow, #ffd814);
    --am-yellow-h: var(--c-yellow-h, #f7ca00);
    --am-radius: var(--r-box, 8px);
    color: var(--am-ink);
    font-size: 14px;
    line-height: 1.5;
}
.am-home *, .am-home *::before, .am-home *::after { box-sizing: border-box; }
.am-home img { max-width: 100%; }
.am-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.am-wrap { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 15px; }

/* ───────── الشرائح ───────── */
.am-hero { position: relative; margin-bottom: 16px; }
.am-hero__track { display: grid; overflow: hidden; height: 140px; }
/* الشريحة الحالية ظاهرة كاملة تحت السابقة، والسابقة وحدها تتلاشى فوقها ⇒ لا لحظة بيضاء بين الشريحتين */
.am-hero__slide { grid-area: 1 / 1; display: block; height: 100%; opacity: 0; pointer-events: none; }
.am-hero__slide.is-on { opacity: 1; z-index: 1; pointer-events: auto; }
.am-hero__slide.is-out { opacity: 1; z-index: 2; animation: am-hero-out .6s ease forwards; }
@keyframes am-hero-out { from { opacity: 1; } to { opacity: 0; } }
.am-hero__slide picture { display: contents; }
.am-hero__slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 767.98px) {
    .am-hero__track:has(.has-m) { height: auto; }
    .am-hero__slide.has-m img { height: auto; }
}
@media (min-width: 768px) { .am-hero__track { height: 240px; } }
@media (min-width: 992px) { .am-hero__track { height: 340px; } }
@media (min-width: 1200px) { .am-hero__track { height: 420px; } }
@media (min-width: 1500px) { .am-hero__track { height: 460px; } }

.am-promos { margin: -8px auto 16px; }
.am-rail__track--promo { --per: 1; }
.am-promo { position: relative; display: block; overflow: hidden; border-radius: var(--am-radius); color: #fff; }
.am-promo img { display: block; width: 100%; transition: transform .3s; }
.am-promo:hover img { transform: scale(1.04); }
.am-promo__text { position: absolute; top: 0; inset-inline-start: 0; width: 70%; padding: 24px; display: flex; flex-direction: column; }
.am-promo__text strong { font-size: 26px; font-weight: 700; text-transform: uppercase; }
.am-promo.is-dark { color: var(--am-ink); }
@media (min-width: 576px) { .am-rail__track--promo { --per: 1.5; } }
@media (min-width: 768px) { .am-rail__track--promo { --per: 2; } }
@media (min-width: 1200px) { .am-rail__track--promo { --per: 3; } }

/* ───────── مربعات الأقسام (جوال/لوحي) ───────── */
.am-tiles { background: var(--am-band); padding: 14px 0 10px; margin-bottom: 10px; }
.am-tiles__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.am-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--am-ink); text-align: center; }
.am-tile:hover { color: var(--am-link-h); text-decoration: none; }
.am-tile__img { display: block; width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--am-line-soft); }
.am-tile__img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.am-tile__name { font-size: 12px; font-weight: 600; line-height: 1.35; }
@media (min-width: 768px) { .am-tiles__grid { grid-template-columns: repeat(8, 1fr); } }
@media (min-width: 1200px) { .am-tiles { display: none; } }

/* ───────── رأس القسم والصناديق ───────── */
.am-sec { margin-top: 12px; margin-bottom: 12px; }
@media (min-width: 768px) { .am-sec { margin-top: 16px; margin-bottom: 16px; } }
.am-box { border: 1px solid var(--am-line-soft); background: #fff; }
.am-wrap.am-box, .am-box.am-wrap { padding-inline: 0; width: calc(100% - 30px); max-width: 1110px; }
.am-sec__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 8px; }
.am-sec__title { margin: 0 !important; font-size: 16px !important; font-weight: 700 !important; line-height: 1.4 !important; color: var(--am-ink); }
.am-sec__title small { font-size: 12px; font-weight: 400; color: var(--am-ink-2); margin-inline-start: 6px; }
@media (max-width: 767.98px) { .am-sec__title small { display: none; } }
@media (min-width: 768px) { .am-sec__title { font-size: 20px !important; } .am-sec__head { padding: 20px 20px 10px; } }
.am-sec__tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.am-sec__more { font-size: 12px; font-weight: 700; color: var(--am-link) !important; text-decoration: none; white-space: nowrap; }
.am-sec__more:hover { color: var(--am-link-h) !important; text-decoration: underline; }
.am-arrow { width: 30px; height: 30px; display: inline-flex !important; align-items: center; justify-content: center; padding: 0; border: 0 !important; background: transparent !important; color: var(--am-ink-2) !important; border-radius: 50%; cursor: pointer; }
.am-arrow:hover { background: var(--am-band) !important; color: var(--am-ink) !important; }
.am-arrow[disabled] { opacity: .3; cursor: default; }
[dir="rtl"] .am-arrow svg { transform: scaleX(-1); }
.am-arrow:focus-visible, .am-arrow--float { position: absolute; top: 50%; inset-inline-start: 6px; transform: translateY(-50%); z-index: 3; background: #fff !important; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); width: 34px; height: 34px; }
.am-arrow--float.am-arrow--end { inset-inline-start: auto; inset-inline-end: 6px; }
.am-arrow--float[disabled] { display: none !important; }

/* ───────── المسار الأفقي ───────── */
.am-rail { position: relative; --gap: 0px; --per: 2; --rows: 1; }
.am-rail__track {
    display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows), auto);
    grid-auto-columns: calc((100% - (var(--per) - 1) * var(--gap)) / var(--per));
    gap: var(--gap); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.am-rail__track::-webkit-scrollbar { display: none; }
.am-rail__track > * { scroll-snap-align: start; min-width: 0; }
.am-rail--2rows { --rows: 2; }
.am-rail--3rows { --rows: 3; }
.am-rail .am-card { padding-inline: 16px; }

.am-rail--wide { --per: 2; padding: 0 0 6px; }
@media (min-width: 768px) { .am-rail--wide { --per: 3; } }
@media (min-width: 992px) { .am-rail--wide { --per: 4; } }
@media (min-width: 1200px) { .am-rail--wide { --per: 5; } }
@media (min-width: 1500px) { .am-rail--wide { --per: 6; } }

.am-rail--half { --per: 2; }
@media (min-width: 768px) { .am-rail--half { --per: 3; } }
@media (min-width: 992px) { .am-rail--half { --per: 4; } }
@media (min-width: 1200px) { .am-rail--half { --per: 3; } }

.am-rail--cat { --per: 2; flex: 1 1 auto; min-width: 0; }
@media (min-width: 992px) { .am-rail--cat { --per: 3; } }
@media (min-width: 1200px) { .am-rail--cat { --per: 3.5; } }
@media (min-width: 1500px) { .am-rail--cat { --per: 5; } }

.am-rail--flash { --per: 2; flex: 1 1 auto; min-width: 0; }
@media (min-width: 768px) { .am-rail--flash { --per: 3; } }
@media (min-width: 1200px) { .am-rail--flash { --per: 4; } }

/* ───────── الصفّان المتجاوران ───────── */
.am-pair { display: grid; grid-template-columns: 1fr; gap: 0 30px; }
.am-pair > * { min-width: 0; }
@media (min-width: 1200px) { .am-pair { grid-template-columns: 1fr 1fr; } }
.am-pair--low { margin-top: 16px; margin-bottom: 32px; gap: 24px 30px; }
.am-pair--low .am-sec { margin: 0; height: 100%; }
.am-pair--low #home-provider-map { margin-top: 0 !important; }

/* ───────── عرض الفلاش ───────── */
.am-flash .am-sec__head { padding-inline: 0; }
.am-flash__body { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 992px) { .am-flash__body { grid-template-columns: 1fr 2fr; } }
.am-flash__banner { display: flex; align-items: flex-end; min-height: 220px; border-radius: var(--am-radius); background-size: cover; background-position: center; padding: 16px; text-decoration: none; }
.am-countdown { display: inline-flex; gap: 6px; direction: ltr; }
.am-countdown span { min-width: 48px; padding: 6px 4px; border-radius: 6px; background: rgba(0, 0, 0, .65); color: #fff; text-align: center; font-weight: 700; font-size: 16px; line-height: 1.1; }
.am-countdown small { display: block; font-size: 10px; font-weight: 400; opacity: .8; }
.am-flash .am-rail { border: 1px solid var(--am-line-soft); }

/* ───────── «عروض اليوم» ───────── */
.am-deal__banner img { display: block; width: 100%; }
.am-deal__box { border: 1px solid var(--am-line-soft); background: #fff; padding-bottom: 14px; }
.am-rail--deal { --per: 2; padding: 0 16px; }
@media (min-width: 576px) { .am-rail--deal { --per: 3; } }
@media (min-width: 768px) { .am-rail--deal { --per: 4; } }
@media (min-width: 992px) { .am-rail--deal { --per: 5; } }
@media (min-width: 1200px) { .am-rail--deal { --per: 6; } }
@media (min-width: 1500px) { .am-rail--deal { --per: 7; } }
.am-mini { display: flex; flex-direction: column; align-items: center; padding: 4px 8px; text-decoration: none !important; color: var(--am-ink); text-align: center; }
.am-mini__img { display: block; width: 80px; height: 80px; border-radius: 50%; overflow: hidden; background: #fff; }
.am-mini__img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.am-mini:hover .am-mini__img img { transform: scale(1.08); }
.am-mini__now { margin-top: 12px; font-size: 14px; font-weight: 700; color: var(--c-price, #0f1111); }
.am-mini__was { font-size: 13px; color: var(--am-ink-2); }

/* ───────── الأقسام المميزة (حاسوب) ───────── */
.am-fcats { display: none; }
@media (min-width: 1200px) { .am-fcats { display: block; margin-top: 16px; margin-bottom: 16px; } }
.am-rail--fcat { --per: 3.5; }
@media (min-width: 1500px) { .am-rail--fcat { --per: 4; } }
.am-rail--fcat .am-rail__track { border-inline-start: 1px solid var(--am-line-soft); }
.am-fcat { position: relative; display: block; height: 340px; overflow: hidden; border: 1px solid var(--am-line-soft); border-inline-start: 0; text-decoration: none !important; background: #fff; }
.am-fcat__img { position: absolute; inset: 0 0 80px; display: block; overflow: hidden; }
.am-fcat__img img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.am-fcat:hover .am-fcat__img img { transform: scale(1.05); }
.am-fcat__name { position: absolute; inset: auto 0 0; height: 80px; display: flex; align-items: center; justify-content: center; padding: 0 12px; color: var(--am-ink); font-size: 16px; font-weight: 700; text-align: center; }
.am-fcat:hover .am-fcat__name { color: var(--am-link-h); }

/* ───────── البانرات ───────── */
.am-banners { margin-top: 16px; margin-bottom: 16px; }
.am-rail--banner { --gap: 16px; --per: 1; }
@media (min-width: 768px) { .am-rail--banner { --per: min(2, var(--am-n)); } }
@media (min-width: 1200px) { .am-rail--banner { --per: var(--am-n); } }
.am-banner { display: block; overflow: hidden; }
.am-banner img { display: block; width: 100%; height: auto; transition: transform .35s; }
.am-banner:hover img { transform: scale(1.03); }
.am-arrow--narrow { display: none !important; }
@media (max-width: 767.98px) { .am-arrow--narrow { display: inline-flex !important; } .am-arrow--narrow[disabled] { display: none !important; } }

/* ───────── «فئات الرئيسية» ───────── */
.am-hcat__body { display: flex; flex-direction: column; gap: 12px; padding: 0 0 12px; }
@media (min-width: 576px) { .am-hcat__body { flex-direction: row; padding: 4px 20px 20px; gap: 20px; } }
.am-hcat__cover { display: block; flex: 0 0 auto; width: 100%; height: 260px; overflow: hidden; }
@media (min-width: 576px) { .am-hcat__cover { width: 260px; } }
.am-hcat__cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.am-hcat__cover { position: relative; }
.am-hcat__cover::before { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .3); opacity: 0; transition: opacity .4s; z-index: 1; }
.am-hcat__go { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; min-width: 100px; height: 36px; padding: 0 14px; display: flex; align-items: center; justify-content: center; border-radius: 24px; background: rgba(2, 0, 0, .8); color: #fff; font-size: 14px; font-weight: 500; opacity: 0; transition: opacity .4s; white-space: nowrap; }
.am-hcat__cover:hover img, .am-hcat__cover:focus-visible img { transform: scale(1.04); }
.am-hcat__cover:hover::before, .am-hcat__cover:hover .am-hcat__go, .am-hcat__cover:focus-visible::before, .am-hcat__cover:focus-visible .am-hcat__go { opacity: 1; }

/* ───────── الإعلانات المبوّبة ───────── */
.am-classified__banner img { display: block; width: 100%; }
.am-classified { border: 1px solid var(--am-line-soft); padding-bottom: 12px; }
.am-classified__grid { display: grid; grid-template-columns: 1fr; padding: 0 12px; }
@media (min-width: 768px) { .am-classified__grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .am-classified__grid { grid-template-columns: repeat(3, 1fr); } }
.am-ad { display: flex; gap: 12px; padding: 10px; text-decoration: none !important; color: var(--am-ink); }
.am-ad:hover { background: var(--am-hover); }
.am-ad__img { flex: 0 0 34%; aspect-ratio: 1 / 1; display: block; }
.am-ad__img img { width: 100%; height: 100%; object-fit: contain; }
.am-ad__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.am-ad__name { font-size: 14px; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
.am-ad__seller { font-size: 13px; color: var(--am-ink-2); }
.am-ad__price { font-size: 14px; }
.am-pill { align-self: flex-start; padding: 3px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.am-pill--new { background: #e6f4fb; color: #0b7aa8; }
.am-pill--used { background: #fdecef; color: var(--am-sale); }

/* ───────── الكوبونات ───────── */
.am-coupon-wrap { margin-top: 16px; }
.am-coupon { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 40px 24px; color: #fff; }
.am-coupon__text h3 { color: #fff; font-size: 30px; font-weight: 400; margin: 0 0 10px; }
.am-coupon__text p { font-size: 18px; margin: 0 0 24px; }
.am-coupon__btn { display: inline-block; padding: 8px 36px; border-radius: 28px; background: rgba(255, 255, 255, .2); color: #fff !important; text-decoration: none !important; box-shadow: 0 20px 30px rgba(0, 0, 0, .16); }
.am-coupon__btn:hover { background: #fff; color: var(--am-ink) !important; }
@media (min-width: 992px) { .am-coupon { padding: 48px; } .am-coupon__art { order: 2; } }

/* ───────── البائعون والعلامات ───────── */
.am-rail--shop { --per: 1.4; padding: 0 12px 12px; }
@media (min-width: 576px) { .am-rail--shop { --per: 2; } }
@media (min-width: 768px) { .am-rail--shop { --per: 2.5; } }
@media (min-width: 992px) { .am-rail--shop { --per: 3.4; } }
@media (min-width: 1200px) { .am-rail--shop { --per: 2.5; } }
@media (min-width: 1500px) { .am-rail--shop { --per: 3; } }
.am-shop { padding: 16px 8px; text-align: center; }
.am-shop__logo { display: flex; align-items: center; justify-content: center; width: 100px; height: 100px; margin: 0 auto; border: 1px solid #e5e5e5; border-radius: 50%; overflow: hidden; box-shadow: 0 10px 20px rgba(0, 0, 0, .06); background: #fff; }
.am-shop__logo img { width: 100%; height: 100%; object-fit: cover; }
.am-shop__name { margin: 16px 0 8px !important; font-size: 14px !important; font-weight: 700 !important; line-height: 1.4 !important; height: 2.8em; overflow: hidden; }
.am-shop__name a { color: var(--am-ink); text-decoration: none; }
.am-shop__name a:hover { color: var(--am-link-h); }
.am-shop__rate { font-size: 13px; color: var(--am-ink-2); }
.am-stars { display: inline-flex; gap: 2px; vertical-align: -2px; }
.am-star { fill: #d5d9d9; }
.am-star--full { fill: #ffa41c; }
.am-star--half { fill: #ffcf87; }
.am-rail--brand { --per: 1.4; padding: 0 12px 12px; }
@media (min-width: 576px) { .am-rail--brand { --per: 2; } }
@media (min-width: 768px) { .am-rail--brand { --per: 3; } }
@media (min-width: 992px) { .am-rail--brand { --per: 4; } }
@media (min-width: 1200px) { .am-rail--brand { --per: 3; } }
.am-brand { display: block; padding: 8px; text-align: center; text-decoration: none !important; color: var(--am-ink); }
.am-brand img { height: 100px; object-fit: contain; padding: 12px; }
.am-brand span { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───────── الفقرة التعريفية ───────── */
.am-intro { margin-top: 16px; margin-bottom: 16px; }
.am-intro { background: var(--light, #f7f7f7); border: 1px solid var(--soft-light, #e7e7e7); border-radius: 4px; padding: 16px; width: calc(100% - 30px); max-width: 1110px; }
@media (min-width: 768px) { .am-intro { padding: 24px; } }
.am-intro h2 { font-size: 16px !important; font-weight: 700 !important; margin: 0 0 10px !important; color: var(--am-ink); }
@media (min-width: 768px) { .am-intro h2 { font-size: 20px !important; margin-bottom: 16px !important; } }
.am-intro p { font-size: 13px; line-height: 1.9; margin: 0 0 8px; text-align: start; }
@media (min-width: 768px) { .am-intro p { font-size: 14px; } }
.am-intro a { font-size: 13px; font-weight: 600; color: var(--am-link); }

/* حالة التحميل لقسم مؤجّل: مساحة محجوزة تقلّل قفز الصفحة، وتُزال حين يصل المحتوى */
[data-am-section][aria-busy="true"] { min-height: 120px; }
[data-am-section="todays_deal"][aria-busy="true"] { min-height: 190px; }

@media (prefers-reduced-motion: reduce) {
    .am-hero__slide.is-out { animation: none; opacity: 0; }
    .am-promo img, .am-fcat__img img, .am-banner img, .am-hcat__cover img, .am-mini__img img { transition: none; }
}
