@font-face {
    font-family: IRANYekan;
    src: url('../fonts/iranyekan/iranyekan-400.woff') format('woff');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: IRANYekan;
    src: url('../fonts/iranyekan/iranyekan-700.woff') format('woff');
    font-weight: 700;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --gallery-bg: #0c0b0b;
    --gallery-fg: #fcf7ef;
    --gallery-muted: #c4bcb1;
    --gallery-accent: #ffb35c;
    --gallery-line: #fff4df2c;
    --gallery-gutter: clamp(20px, 4vw, 64px);
    font-family: IRANYekan, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--gallery-bg); color: var(--gallery-fg); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .36; cursor: default; }
:focus-visible { outline: 2px solid var(--gallery-accent); outline-offset: 4px; }

.gallery {
    position: relative;
    height: 100vh;
    height: 100dvh;
    min-height: 270px;
    overflow: hidden;
    isolation: isolate;
}

.gallery-wall, .gallery-shade { position: absolute; inset: 0; width: 100%; height: 100%; }

.gallery-wall {
    display: block;
    touch-action: none;
    cursor: grab;
    outline-offset: -4px;
}

.gallery-wall:active { cursor: grabbing; }

.gallery-shade {
    pointer-events: none;
    background:
        linear-gradient(180deg, #0c0b0bf5 0%, #0c0b0b16 21%, transparent 59%, #0c0b0bec 100%),
        radial-gradient(ellipse at 54% 50%, transparent 26%, #0c0b0b90 100%);
}

.gallery-header, .gallery-footer {
    position: absolute;
    inset-inline: var(--gallery-gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    pointer-events: none;
}

.gallery-header { inset-block-start: max(24px, env(safe-area-inset-top)); }
.gallery-footer { inset-block-end: max(24px, env(safe-area-inset-bottom)); }
.gallery-header a, .gallery-footer button { pointer-events: auto; }
.gallery-brand { display: flex; align-items: center; gap: 16px; }
.gallery-brand img { display: block; width: clamp(74px, 8vw, 103px); height: auto; }

.gallery-brand h1 {
    margin: 0;
    border-inline-start: 1px solid var(--gallery-line);
    padding-inline-start: 16px;
    color: var(--gallery-fg);
    font-size: clamp(.94rem, 1.3vw, 1.18rem);
    font-weight: 700;
    line-height: 1.5;
}

.gallery-back, .gallery-current-open, .gallery-movie-link, .gallery-status button, .gallery-detail-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid var(--gallery-line);
    border-radius: 9px;
    padding: 8px 13px;
    background: #171513d9;
    font-size: .82rem;
    min-height: 42px;
}

.gallery-back:hover, .gallery-current-open:hover, .gallery-zoom button:hover:enabled,
.gallery-status button:hover, .gallery-detail-retry:hover, .gallery-close:hover {
    background: #302922;
    border-color: var(--gallery-accent);
}

.gallery-back span, .gallery-current-open span { color: var(--gallery-accent); }

.gallery-current {
    position: absolute;
    inset-inline-start: var(--gallery-gutter);
    inset-block-start: 27%;
    width: min(29vw, 400px);
    text-shadow: 0 2px 22px #000, 0 1px 8px #000;
    pointer-events: none;
}

.gallery:has(.gallery-details[open]) .gallery-current { visibility: hidden; }

.gallery-current h2 {
    margin: 0 0 11px;
    font-size: clamp(1.55rem, 3.15vw, 3.15rem);
    line-height: 1.32;
    letter-spacing: -.03em;
    overflow-wrap: anywhere;
    text-align: right;
}

.gallery-current-open { margin-top: 18px; pointer-events: auto; }
.gallery-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .89rem; color: var(--gallery-muted); }
.gallery-meta span:empty { display: none; }
.gallery-meta [data-current-rating], .gallery-meta [data-detail-rating] { color: var(--gallery-accent); }
.gallery-footer p { color: var(--gallery-muted); font-size: .76rem; margin: 0; text-shadow: 0 1px 10px #000; }
.gallery-footer p span:first-child { display: none; }

.gallery-zoom {
    display: flex;
    flex: none;
    align-items: center;
    border: 1px solid var(--gallery-line);
    border-radius: 12px;
    padding: 3px;
    background: #151311e8;
    box-shadow: 0 8px 28px #0007;
}

.gallery-zoom button {
    min-width: 43px;
    height: 42px;
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font-size: 1.35rem;
}

.gallery-zoom [data-zoom='reset'] { min-width: 55px; font-size: .82rem; font-variant-numeric: tabular-nums; }

.gallery-status {
    position: absolute;
    inset: 50% 20px auto;
    text-align: center;
    transform: translateY(-50%);
    pointer-events: none;
}

.gallery-status button { pointer-events: auto; }

.gallery-details {
    color: var(--gallery-fg);
    background: #171411f5;
    border: 1px solid var(--gallery-line);
    border-radius: 18px;
    box-shadow: 0 18px 90px #000a;
    width: min(455px, calc(100% - 2 * var(--gallery-gutter)));
    max-height: calc(100% - 2 * var(--gallery-gutter));
    margin: auto auto auto var(--gallery-gutter);
    padding: 28px;
    overscroll-behavior: contain;
}

.gallery-details::backdrop { background: #09080759; }
.gallery-close {
    position: absolute;
    inset: 9px auto auto 9px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--gallery-line);
    border-radius: 50%;
    background: #151311;
    font: 1.55rem/1 sans-serif;
}

.gallery-detail-head { display: flex; align-items: center; gap: 16px; padding-inline-end: 16px; }
.gallery-detail-poster { flex: 0 0 auto; display: block; border-radius: 9px; object-fit: cover; background: #27221c; }
.gallery-detail-head h2 { margin: 0; font-size: clamp(1.3rem, 3vw, 2rem); line-height: 1.35; text-align: right; }
.gallery-original-title { color: var(--gallery-muted); font-size: .85rem; margin: 5px 0 10px; text-align: right; }
.gallery-genres { display: flex; flex-wrap: wrap; list-style: none; padding: 0; margin: 17px 0 0; gap: 6px; }
.gallery-genres li { font-size: .74rem; border: 1px solid var(--gallery-line); border-radius: 6px; padding: 3px 8px; }
.gallery-description { font-size: .92rem; line-height: 1.9; margin: 16px 0 0; text-align: right; }
.gallery-detail-status { color: var(--gallery-muted); margin: 14px 0 0; }
.gallery-detail-status:empty { display: none; }
.gallery-detail-actions:has(> :not([hidden])) { display: flex; margin-top: 20px; }
.gallery-movie-link { background: var(--gallery-accent); color: #211407; font-weight: 700; padding-inline: 18px; }
.gallery-movie-link:hover { background: #ffc581; }

@media (pointer: coarse) {
    .gallery-footer p span:first-child { display: inline; }
    .gallery-footer p span:last-child { display: none; }
}

@media (max-width: 700px) {
    .gallery-header {
        inset-block-start: max(13px, env(safe-area-inset-top));
        display: grid;
        grid-template-columns: 1fr auto;
        row-gap: 8px;
    }
    .gallery-footer { inset-block-end: max(14px, env(safe-area-inset-bottom)); }
    .gallery-brand { display: contents; }
    .gallery-brand a { justify-self: start; }
    .gallery-brand h1 { grid-area: 2 / 1 / 3 / -1; border: 0; padding: 0; }
    .gallery-back { grid-area: 1 / 2; font-size: .72rem; min-height: 36px; padding: 5px 8px; gap: 5px; }
    .gallery-current { inset-block-start: max(102px, calc(env(safe-area-inset-top) + 89px)); width: min(85%, 420px); }
    .gallery-current h2 { margin-bottom: 6px; font-size: clamp(1.4rem, 5.7vw, 2.1rem); }
    .gallery-current-open { margin-top: 9px; font-size: .74rem; min-height: 36px; }
    .gallery-footer p { line-height: 1.75; font-size: .69rem; }
    .gallery-details { width: calc(100% - 24px); max-height: calc(100% - 32px); margin: auto auto max(12px, env(safe-area-inset-bottom)); padding: 21px; }
    .gallery-detail-poster { width: 73px; height: 110px; }
}

@media (max-height: 450px) and (orientation: landscape) {
    .gallery-header { inset-block-start: 10px; }
    .gallery-footer { inset-block-end: 10px; }
    .gallery-current { inset-block-start: max(96px, 24%); width: 26vw; }
    .gallery-current h2 { font-size: clamp(1.15rem, 3vw, 1.7rem); }
}
