/* ───────────── حائط الذكريات ───────────── */

@font-face {
    font-family: "Graphik Arabic";
    src: url("/fonts/GraphikArabic-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Graphik Arabic";
    src: url("/fonts/GraphikArabic-Medium.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Graphik Arabic";
    src: url("/fonts/GraphikArabic-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

:root {
    --mw-bg: #141112;
    --mw-ink: #f6f1ea;
    --mw-muted: rgba(246, 241, 234, 0.6);
    --mw-glass: rgba(30, 26, 27, 0.62);
    --mw-glass-border: rgba(255, 255, 255, 0.09);
    --mw-accent: var(--color-author, #e8651a);
    --mw-spring: cubic-bezier(0.32, 0.72, 0, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--mw-bg);
    color: var(--mw-ink);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ─── الشريط العلوي ─── */
.mw-bar {
    position: fixed;
    top: 0;
    inset-inline: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: calc(14px + var(--safe-top)) 20px 14px;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(20, 17, 18, 0.85), rgba(20, 17, 18, 0));
}

.mw-bar > * { pointer-events: auto; }

.mw-bar__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--mw-ink);
    text-decoration: none;
    justify-self: start;
}

.mw-bar__brand img {
    height: 30px;
    width: auto;
    opacity: 0.92;
}

.mw-bar__back {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--mw-glass);
    border: 1px solid var(--mw-glass-border);
    backdrop-filter: blur(12px);
    transition: transform var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.mw-bar__back i { font-size: 15px; }
.mw-bar__brand:active .mw-bar__back { transform: scale(0.94); }

.mw-bar__title {
    text-align: center;
    line-height: 1.3;
}

.mw-bar__title h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
}

.mw-bar__title span {
    font-size: 12px;
    color: var(--mw-muted);
    font-variant-numeric: tabular-nums;
}

.mw-bar__link {
    justify-self: end;
    color: var(--mw-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--mw-glass-border);
    background: var(--mw-glass);
    backdrop-filter: blur(12px);
    transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .mw-bar__back:hover { background: rgba(255, 255, 255, 0.12); }
    .mw-bar__link:hover { color: var(--mw-ink); border-color: rgba(255, 255, 255, 0.24); }
}

/* ─── المسرح ─── */
.mw-stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    background:
        radial-gradient(60% 55% at 50% 50%, rgba(232, 101, 26, 0.09), transparent 70%),
        radial-gradient(120% 90% at 50% 50%, #1d1819 0%, var(--mw-bg) 62%);
}

.mw-stage.is-grabbing { cursor: grabbing; }

/* نقاط خفيفة كأنها نجوم خلفية — تعطي إحساسًا بالعمق */
.mw-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.35), transparent),
        radial-gradient(1px 1px at 70% 80%, rgba(255, 255, 255, 0.25), transparent),
        radial-gradient(1.5px 1.5px at 85% 20%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 40% 65%, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 10% 85%, rgba(255, 255, 255, 0.25), transparent);
    background-size: 340px 340px;
    opacity: 0.6;
}

.mw-world {
    position: absolute;
    inset: 0;
}

/* تعتيم الحواف يعزز إحساس الكرة */
.mw-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5000;
    background: radial-gradient(closest-side at 50% 50%, transparent 62%, rgba(20, 17, 18, 0.55) 88%, var(--mw-bg) 100%);
    background-size: max(100vw, 100vh) max(100vw, 100vh);
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 0 120px 40px var(--mw-bg);
}

/* ─── الصور ─── */
.mw-item {
    position: absolute;
    top: 0;
    left: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: inherit;
    transform-origin: 50% 50%;
    will-change: transform, opacity;
    -webkit-tap-highlight-color: transparent;
}

.mw-item__inner {
    position: absolute;
    inset: 0;
    display: block;
    border-radius: 10px;
    overflow: hidden;
    background: #2a2425;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 18px 40px -12px rgba(0, 0, 0, 0.7),
        0 4px 10px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: scale(0.82);
    transition:
        opacity 420ms var(--ease-out),
        transform 560ms var(--mw-spring),
        box-shadow var(--duration-normal) var(--ease-out);
}

.mw-item.is-in .mw-item__inner {
    opacity: 1;
    transform: scale(1);
}

/* لمعة أثناء تحميل الصورة */
.mw-item__inner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%);
    background-size: 200% 100%;
    animation: mw-shimmer 1.4s linear infinite;
}

.mw-item.is-loaded .mw-item__inner::before { display: none; }

.mw-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 500ms var(--ease-out);
    pointer-events: none;
}

.mw-item.is-loaded img { opacity: 1; }
.mw-item.is-broken .mw-item__inner { background: #2a2425; }

@media (hover: hover) and (pointer: fine) {
    .mw-stage:not(.is-grabbing) .mw-item:hover .mw-item__inner {
        transform: scale(1.045);
        box-shadow:
            0 0 0 1.5px rgba(255, 255, 255, 0.55),
            0 26px 60px -14px rgba(0, 0, 0, 0.8);
    }

    .mw-stage:not(.is-grabbing) .mw-item:hover { cursor: zoom-in; }
}

.mw-item:focus-visible .mw-item__inner {
    box-shadow: 0 0 0 3px var(--mw-accent), 0 20px 50px rgba(0, 0, 0, 0.7);
}

@keyframes mw-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ─── التلميح ─── */
.mw-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 6000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--mw-glass);
    border: 1px solid var(--mw-glass-border);
    backdrop-filter: blur(16px);
    font-size: 14px;
    color: var(--mw-ink);
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: mw-hint-in 700ms var(--ease-out) 900ms both;
    transition: opacity 400ms var(--ease-out), transform 500ms var(--ease-out);
}

.mw-hint.is-gone {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 10px)) scale(0.96);
}

.mw-hint__icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(232, 101, 26, 0.18);
    color: var(--mw-accent);
}

.mw-hint__icon i { font-size: 17px; animation: mw-nudge 2.2s var(--ease-in-out) infinite; }

@keyframes mw-hint-in {
    from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes mw-nudge {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
}

/* ─── أدوات التحكم ─── */
.mw-controls {
    position: absolute;
    bottom: calc(22px + var(--safe-bottom));
    left: 50%;
    z-index: 6000;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border-radius: 999px;
    background: var(--mw-glass);
    border: 1px solid var(--mw-glass-border);
    backdrop-filter: blur(18px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    transform: translateX(-50%);
    animation: mw-controls-in 600ms var(--ease-out) 500ms both;
    cursor: default;
}

@keyframes mw-controls-in {
    from { opacity: 0; transform: translate(-50%, 16px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.mw-ctrl {
    height: 40px;
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--mw-ink);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out), transform var(--duration-instant) var(--ease-out);
}

.mw-ctrl i { font-size: 15px; flex: none; }
.mw-ctrl:active { transform: scale(0.94); }
.mw-ctrl:focus-visible { outline: 2px solid var(--mw-accent); outline-offset: 1px; }

.mw-ctrl--readout {
    min-width: 58px;
    font-variant-numeric: tabular-nums;
    color: var(--mw-muted);
}

.mw-ctrl--wide { padding: 0 14px; }

.mw-controls__sep {
    width: 1px;
    height: 22px;
    background: var(--mw-glass-border);
    margin: 0 4px;
}

@media (hover: hover) and (pointer: fine) {
    .mw-ctrl:hover { background: rgba(255, 255, 255, 0.1); }
    .mw-ctrl--readout:hover { color: var(--mw-ink); }
}

/* ─── العرض المكبّر ─── */
.mw-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 72px 72px 48px;
}

.mw-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 10, 11, 0.86);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 320ms var(--ease-out);
}

.mw-lightbox.is-open .mw-lightbox__backdrop { opacity: 1; }

.mw-lightbox__figure {
    position: relative;
    margin: 0;
    max-width: min(1200px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.mw-lightbox__figure img {
    max-width: 100%;
    max-height: calc(100dvh - 180px);
    border-radius: 6px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.mw-lightbox__figure figcaption {
    font-size: 15px;
    color: var(--mw-muted);
    text-align: center;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 300ms var(--ease-out) 160ms, transform 300ms var(--ease-out) 160ms;
}

.mw-lightbox.is-open figcaption { opacity: 1; transform: none; }

.mw-lb-btn {
    position: absolute;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--mw-glass-border);
    background: var(--mw-glass);
    color: var(--mw-ink);
    backdrop-filter: blur(12px);
    cursor: pointer;
    opacity: 0;
    transition: opacity 260ms var(--ease-out), background var(--duration-fast) var(--ease-out),
        transform var(--duration-instant) var(--ease-out);
}

.mw-lightbox.is-open .mw-lb-btn { opacity: 1; }
.mw-lb-btn i { font-size: 18px; }
.mw-lb-btn:active { transform: scale(0.94); }
.mw-lb-btn:focus-visible { outline: 2px solid var(--mw-accent); outline-offset: 2px; }

.mw-lb-btn--close { top: calc(16px + var(--safe-top)); inset-inline-start: 16px; }
.mw-lb-btn--prev { inset-inline-start: 16px; top: 50%; margin-top: -23px; }
.mw-lb-btn--next { inset-inline-end: 16px; top: 50%; margin-top: -23px; }

@media (hover: hover) and (pointer: fine) {
    .mw-lb-btn:hover { background: rgba(255, 255, 255, 0.14); }
}

/* ─── الحالة الفارغة ─── */
.mw-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 24px;
    cursor: default;
}

.mw-empty-state h2 { margin: 18px 0 0; font-size: 26px; }
.mw-empty-state p { margin: 0; color: var(--mw-muted); max-width: 36ch; line-height: 1.8; }

.mw-empty-state__orb {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.35), transparent 40%),
        radial-gradient(circle at 50% 50%, #e8651a, #6e1946 70%, #2a1418);
    box-shadow: 0 0 80px rgba(232, 101, 26, 0.35);
    animation: mw-orb 8s var(--ease-in-out) infinite alternate;
}

@keyframes mw-orb {
    from { transform: translateY(-6px) rotate(0deg); }
    to { transform: translateY(6px) rotate(25deg); }
}

.mw-btn {
    margin-top: 12px;
    display: inline-flex;
    padding: 10px 24px;
    border-radius: 10px;
    background: var(--mw-ink);
    color: var(--mw-bg);
    text-decoration: none;
    font-weight: 500;
    transition: transform var(--duration-instant) var(--ease-out);
}

.mw-btn:active { transform: scale(0.97); }

/* ─── الجوال ─── */
@media (max-width: 640px) {
    .mw-bar { grid-template-columns: auto 1fr auto; padding-inline: 14px; }
    .mw-bar__brand img { display: none; }
    .mw-bar__title { text-align: center; }
    .mw-bar__link { font-size: 12px; padding: 7px 12px; }
    .mw-hint { font-size: 12.5px; white-space: normal; width: max-content; max-width: calc(100vw - 48px); text-align: center; }
    .mw-ctrl--wide span { display: none; }
    .mw-lightbox { padding: 64px 12px 32px; }
    .mw-lb-btn--prev,
    .mw-lb-btn--next { top: auto; bottom: calc(18px + var(--safe-bottom)); margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .mw-item__inner,
    .mw-item img,
    .mw-hint,
    .mw-controls { transition: opacity 150ms linear; animation: none; }
    .mw-item__inner { transform: none; }
    .mw-hint__icon i,
    .mw-empty-state__orb,
    .mw-item__inner::before { animation: none; }
}

.mw-lightbox[hidden] { display: none; }

.mw-hint__text--touch { display: none; }

@media (hover: none) and (pointer: coarse) {
    .mw-hint__text--fine { display: none; }
    .mw-hint__text--touch { display: inline; }
}
