/* IRANSans is shared with the panel */
@font-face {
    font-family: IRANSans;
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("../../panel/css/font/woff2/IRANSansWeb(FaNum).woff2") format("woff2");
}

@font-face {
    font-family: IRANSans;
    font-style: normal;
    font-weight: bold;
    font-display: swap;
    src: url("../../panel/css/font/woff2/IRANSansWeb(FaNum)_Bold.woff2") format("woff2");
}

/* Black, white and cool steel grays only: no accent colour anywhere.
   The grays lean slightly blue so the page feels crisp rather than dull. */
:root {
    color-scheme: light;

    --ink: #0e1013;
    --ink-soft: #3a404b;   /* secondary text: 9:1 on the page background */
    --bg-top: #f6f8fb;
    --bg-mid: #e5e9ef;
    --bg-low: #cdd3dd;
    --paper: #eef0f3;
    --graphite: #14171c;
    --graphite-2: #262b34;

    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 40px;

    --fab: 60px;
    --spring: cubic-bezier(.34, 1.56, .64, 1);
    --spring-soft: cubic-bezier(.34, 1.28, .64, 1);
    --smooth: cubic-bezier(.22, 1, .36, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
}

html {
    background: var(--bg-mid);
}

body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(60% 46% at 16% 6%, rgba(255, 255, 255, .95), transparent 70%),
        radial-gradient(42% 36% at 96% 14%, rgba(210, 217, 229, .85), transparent 72%),
        radial-gradient(58% 52% at 90% 96%, rgba(150, 162, 184, .5), transparent 72%),
        linear-gradient(165deg, var(--bg-top), var(--bg-mid) 55%, var(--bg-low));
    color: var(--ink);
    font-family: IRANSans, Tahoma, sans-serif;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

/* ---------- liquid glass ----------
   A translucent, blurred pane with a bright top edge, a soft inner glow and a
   light that follows the pointer. Controls press down and spring back. */

.glass {
    --lx: 30%;
    --ly: 0%;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    color: var(--ink);
    border: 1px solid rgba(255, 255, 255, .62);
    background: linear-gradient(140deg, rgba(255, 255, 255, .64), rgba(255, 255, 255, .2) 55%, rgba(255, 255, 255, .36));
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    backdrop-filter: blur(20px) saturate(1.8);
    box-shadow:
        inset 0 1.5px 0 rgba(255, 255, 255, .95),
        inset 0 10px 16px -10px rgba(255, 255, 255, .85),
        inset 0 -1px 0 rgba(255, 255, 255, .35),
        inset 0 -10px 18px -10px rgba(110, 124, 150, .3),
        0 12px 28px -10px rgba(28, 36, 52, .38),
        0 2px 6px rgba(28, 36, 52, .12);
    transition: transform .55s var(--spring), box-shadow .35s ease, opacity .25s ease;
}

.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(130px circle at var(--lx) var(--ly), rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease;
}

.glass:focus-visible::before,
.glass:active::before {
    opacity: 1;
}

@media (hover: hover) {
    .glass:hover::before {
        opacity: 1;
    }
}

.glass--pill { border-radius: 999px; }
.glass--circle { border-radius: 50%; }
.glass--tile { border-radius: 24px; }

/* tinted (black) glass: the main action */
.glass--dark {
    color: #fff;
    border-color: rgba(255, 255, 255, .24);
    background: linear-gradient(150deg, rgba(62, 68, 82, .8), rgba(14, 16, 19, .92));
    box-shadow:
        inset 0 1.5px 0 rgba(255, 255, 255, .42),
        inset 0 10px 16px -10px rgba(255, 255, 255, .24),
        inset 0 -1px 0 rgba(255, 255, 255, .08),
        0 16px 30px -10px rgba(14, 18, 28, .6),
        0 3px 8px rgba(14, 18, 28, .28);
}

.glass--dark::before {
    background: radial-gradient(120px circle at var(--lx) var(--ly), rgba(255, 255, 255, .34), rgba(255, 255, 255, 0) 70%);
}

/* buttons: lift a little on hover, press down fast, spring back slowly */
@media (hover: hover) {
    .glass--circle:hover:not(:disabled),
    .glass--tile:hover {
        transform: translateY(-2px) scale(1.05);
    }
}

.glass--circle:active:not(:disabled),
.glass--tile:active {
    transform: scale(.92);
    transition-duration: .14s;
    transition-timing-function: var(--smooth);
}

:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

.ico {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- header ---------- */

.top {
    display: flex;
    justify-content: center;
    padding: var(--space-3) var(--space-2) var(--space-1);
}

.top__logo {
    display: block;
    border-radius: 12px;
}

.top__logo img {
    display: block;
    height: clamp(60px, 11vh, 104px);
    width: auto;
}

/* ---------- stage ---------- */

.stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0;
    padding: var(--space-1) var(--space-2);
}

/* faint mihrab arch behind the catalogue, echoing the logo frame */
.stage::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: min(70vh, 90vw);
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 300' preserveAspectRatio='none'%3E%3Cpath d='M8 300V118Q8 62 58 42Q88 30 100 2Q112 30 142 42Q192 62 192 118V300' fill='none' stroke='%230e1013' stroke-opacity='.1' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
    pointer-events: none;
}

.empty {
    margin: auto;
    color: var(--ink-soft);
    font-size: 18px;
}

/* ---------- catalogue ---------- */

.album {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- single page (phones) ---------- */

.single {
    position: relative;
    flex: none;
    border-radius: 2px;
    background: var(--graphite);
    box-shadow: 0 24px 44px -14px rgba(24, 32, 48, .5), 0 6px 14px -6px rgba(24, 32, 48, .28);
    /* the engine handles every drag itself */
    touch-action: none;
    cursor: grab;
}

.single:active {
    cursor: grabbing;
}

/* each page is hinged on the spine, its right edge */
.leaf {
    position: absolute;
    inset: 0;
    visibility: hidden;
    transform-origin: right center;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.leaf > .sheet {
    position: absolute;
    inset: 0;
    border-radius: 2px;
}

.leaf > .sheet::after {
    background: linear-gradient(to left, rgba(0, 0, 0, .24), transparent 6%, rgba(255, 255, 255, .05) 9%, transparent 14%);
}

.leaf__shade,
.leaf__cast {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    border-radius: 2px;
}

/* the lifted page darkening as it turns away from the light */
.leaf__shade {
    background: linear-gradient(to left, rgba(0, 0, 0, .25), rgba(0, 0, 0, .7));
}

/* the shadow a lifted page casts on the page below, strongest at the spine */
.leaf__cast {
    background: linear-gradient(to left, rgba(0, 0, 0, .6), rgba(0, 0, 0, .15) 45%, transparent 80%);
}

.album__book {
    position: relative;
    flex: none;
    transition: transform .6s cubic-bezier(.645, .045, .355, 1);
    filter: drop-shadow(0 22px 26px rgba(24, 32, 48, .32));
}

.sheet {
    overflow: hidden;
    background: var(--paper);
}

.sheet img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .4s ease;
    pointer-events: none;
}

.sheet img.is-loaded {
    opacity: 1;
}

/* spine shading: StPageFlip marks pages left or right of the spine */
.sheet::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.stf__item.--left .sheet::after,
.sheet.--left::after {
    background: linear-gradient(to left, rgba(0, 0, 0, .26), transparent 8%, rgba(255, 255, 255, .06) 12%, transparent 20%);
}

.stf__item.--right .sheet::after,
.sheet.--right::after {
    background: linear-gradient(to right, rgba(0, 0, 0, .26), transparent 8%, rgba(255, 255, 255, .06) 12%, transparent 20%);
}

/* cover and back cover: graphite with the white logo; the inner end-paper stays paper */
.sheet--cover,
.sheet--end {
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse 80% 55% at 30% 12%, rgba(255, 255, 255, .16), transparent 70%),
        linear-gradient(160deg, var(--graphite-2), var(--graphite));
}

.sheet--cover::before,
.sheet--end::before {
    content: "";
    position: absolute;
    inset: 7%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 300' preserveAspectRatio='none'%3E%3Cpath d='M4 296V118Q4 62 56 40Q88 28 100 4Q112 28 144 40Q196 62 196 118V296Z' fill='none' stroke='%23ffffff' stroke-opacity='.34' stroke-width='1.2' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* StPageFlip sets the sheet's display itself, so centre the logo absolutely */
.sheet--cover img,
.sheet--end img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 62%;
    height: auto;
    object-fit: contain;
}

.sheet--end img {
    width: 34%;
}

.sheet--end img.is-loaded {
    opacity: .85;
}

.sheet--blank {
    background: var(--paper);
}

/* ---------- dock: pager in the middle, contact button in the corner ---------- */

.dock {
    display: grid;
    grid-template-columns: minmax(var(--fab), 1fr) auto minmax(var(--fab), 1fr);
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2) max(var(--space-3), calc(env(safe-area-inset-bottom) + 8px));
}

.dock .pager {
    grid-column: 2;
}

.dock .fab {
    grid-column: 3;
    justify-self: end;
}

.pager {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px;
}

.pager__btn {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: transform .55s var(--spring), background-color .25s ease, box-shadow .25s ease, opacity .25s ease;
}

@media (hover: hover) {
    .pager__btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, .72);
        box-shadow: inset 0 1px 0 #fff, 0 4px 10px -4px rgba(28, 36, 52, .35);
    }
}

.pager__btn:active:not(:disabled) {
    transform: scale(.86);
    background: rgba(255, 255, 255, .92);
    transition-duration: .14s;
    transition-timing-function: var(--smooth);
}

.pager__btn:disabled {
    opacity: .32;
    cursor: default;
}

.pager__count {
    min-width: 96px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.fab {
    display: grid;
    place-items: center;
    width: var(--fab);
    height: var(--fab);
    padding: 0;
    cursor: pointer;
}

.fab .ico {
    width: 26px;
    height: 26px;
}

/* ---------- contact modal ---------- */

.contact {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: var(--space-2);
    border: 0;
    background: transparent;
    color: inherit;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.contact[open] {
    display: flex;
}

.contact::backdrop {
    background: rgba(24, 30, 42, 0);
    -webkit-backdrop-filter: blur(0);
    backdrop-filter: blur(0);
    transition: background-color .4s ease, backdrop-filter .45s ease, -webkit-backdrop-filter .45s ease;
}

.contact.is-open::backdrop {
    background: rgba(24, 30, 42, .34);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    backdrop-filter: blur(10px) saturate(1.2);
}

/* the panel grows out of the corner button (the origin is set from script) */
.contact__panel {
    position: relative;
    width: min(100%, 360px);
    padding: 28px 20px 20px;
    border-radius: 32px;
    text-align: center;
    background: linear-gradient(150deg, rgba(255, 255, 255, .74), rgba(255, 255, 255, .44));
    -webkit-backdrop-filter: blur(30px) saturate(1.9);
    backdrop-filter: blur(30px) saturate(1.9);
    transform: scale(.14);
    opacity: 0;
    transition: transform .65s var(--spring-soft), opacity .22s ease, box-shadow .3s ease;
}

.contact.is-open .contact__panel {
    transform: none;
    opacity: 1;
}

.contact.is-closing .contact__panel {
    transition: transform .38s cubic-bezier(.5, 0, .75, 0), opacity .24s ease .08s;
}

.contact__title {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: bold;
}

.contact__hint {
    margin: 0 0 20px;
    color: var(--ink-soft);
    font-size: 13px;
}

.contact__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* an odd last tile takes the whole row */
.contact__item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.contact__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 100px;
    padding: 14px 8px;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
}

.contact__item .ico {
    width: 30px;
    height: 30px;
}

.contact.is-open .contact__item {
    animation: tile-in .6s var(--spring) backwards;
    animation-delay: calc(var(--i, 0) * 55ms + 140ms);
}

@keyframes tile-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.86);
    }
}

.contact__close {
    position: absolute;
    top: 12px;
    inset-inline-start: 12px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
}

.contact__close .ico {
    width: 18px;
    height: 18px;
}

/* ---------- responsive ---------- */

@media (min-width: 1024px) {
    .stage { padding-inline: var(--space-4); }
    .dock { padding-inline: var(--space-4); }
}

@media (max-width: 480px) {
    .top { padding-top: var(--space-2); }
    .dock { gap: 0; padding-inline: var(--space-2); }
    .pager__count { min-width: 88px; }
}

@media (max-width: 360px) {
    :root { --fab: 52px; }
    .dock { padding-inline: 12px; }
    .pager__btn { width: 38px; height: 38px; }
    .pager__count { min-width: 72px; }
}

/* short screens (phones in landscape): tighter header and dock */
@media (max-height: 560px) {
    :root { --fab: 48px; }
    .top { padding: var(--space-1) var(--space-2) 0; }
    .top__logo img { height: 44px; }
    .dock { padding-bottom: max(var(--space-1), env(safe-area-inset-bottom)); }
    .pager__btn { width: 36px; height: 36px; }
    .fab .ico { width: 22px; height: 22px; }
    .contact__item { min-height: 76px; gap: 6px; }
    .contact__hint { margin-bottom: 12px; }
}

/* ---------- accessibility fallbacks ---------- */

@media (prefers-reduced-motion: reduce) {
    .album__book { transition: none; }
    .glass,
    .pager__btn { transition-property: opacity, background-color; }
    .contact__panel,
    .contact.is-closing .contact__panel {
        transform: none;
        transition: opacity .15s ease;
    }
    .contact.is-open .contact__item { animation: none; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass { background: rgba(244, 246, 250, .94); }
    .glass--dark { background: var(--graphite); }
    .contact__panel { background: #f4f6fa; }
}

@media (prefers-reduced-transparency: reduce) {
    .glass { background: rgba(244, 246, 250, .96); -webkit-backdrop-filter: none; backdrop-filter: none; }
    .glass--dark { background: var(--graphite); }
    .contact__panel { background: #f4f6fa; }
}
