/*! Duofy 1.0.0 — the book's styles. Everything is scoped to .duofy (the overlay) and html.duofy-open. */

/* StPageFlip's own layout */
.duofy .stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); touch-action: none; }
.duofy .stf__parent canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
.duofy .stf__block { position: absolute; width: 100%; height: 100%; box-sizing: border-box; perspective: 2000px; }
.duofy .stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.duofy .stf__outerShadow, .duofy .stf__innerShadow, .duofy .stf__hardShadow, .duofy .stf__hardInnerShadow { position: absolute; left: 0; top: 0; }

/* The overlay: the whole screen, edge to edge, under the notch and the home indicator */
.duofy {
    --duofy-accent: #ff6a00;
    --duofy-dark: #101010;
    --duofy-light: #ffffff;
    --duofy-paper: #ffffff;
    --duofy-font: "Helvetica Neue", Arial, system-ui, sans-serif;
    --sa-t: env(safe-area-inset-top, 0px); /* for the controls and the text only, never the pages' surface */
    --sa-r: env(safe-area-inset-right, 0px);
    --sa-b: env(safe-area-inset-bottom, 0px);
    --sa-l: env(safe-area-inset-left, 0px);
    --duofy-control: 44px;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 2147483000;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    display: grid;
    grid-template-areas: "book";
    place-items: center;
    margin: 0;
    background: var(--duofy-dark);
    color: var(--duofy-light);
    font-family: var(--duofy-font);
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}
.duofy *, .duofy *::before, .duofy *::after { box-sizing: border-box; }
html.duofy-open { overflow: hidden; overscroll-behavior: none; }

/* the book; a new one (after a fold) is drawn in the same place before the old one goes */
.duofy__book { grid-area: book; position: relative; overscroll-behavior: none; }

/* Pages */
.duofy-page { position: relative; overflow: hidden; background: var(--duofy-paper); }
.duofy-page__img, .duofy-page__video, .duofy-cover__img, .duofy-cover__still, .duofy-cover__video {
    position: absolute; inset: 0; width: 100%; height: 100%; display: block; max-width: none; margin: 0;
    -webkit-user-drag: none; user-select: none; pointer-events: none;
}
.duofy-page__img { object-fit: contain; }
.duofy-page__link {
    position: absolute;
    right: calc(1rem + var(--sa-r));
    bottom: calc(1rem + var(--sa-b));
    z-index: 2;
    display: inline-flex;
    align-items: center;
    min-height: var(--duofy-control);
    padding: 0 1.1rem;
    border-radius: 999px;
    background: var(--duofy-dark);
    color: var(--duofy-light);
    font: 500 0.9rem/1 var(--duofy-font);
    text-decoration: none;
    touch-action: manipulation;
}
.duofy-page__link:focus-visible { outline: 2px solid var(--duofy-accent); outline-offset: 3px; }

/* a video that cannot load or stalls before its first picture: the picture under it (its poster) shows */
.duofy video.is-failed, .duofy video.is-stalled { visibility: hidden; }

/* Covers: a picture or a colour, the video over it at its opacity, the title and subtitle as real text */
.duofy-cover { background: var(--duofy-dark); }
.duofy-cover__img { object-fit: cover; }
.duofy-cover__motion { position: absolute; inset: 0; pointer-events: none; }
.duofy-cover__video, .duofy-cover__still { object-fit: cover; }
.duofy-cover__shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0) 55%); pointer-events: none; }
.duofy-cover__text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.5rem calc(1.5rem + var(--sa-r)) calc(5rem + var(--sa-b)) calc(1.5rem + var(--sa-l));
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}
.duofy-cover__subtitle { margin: 0 0 0.5rem; font-size: 0.75rem; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 500; opacity: 0.85; }
.duofy-cover__title { margin: 0; font-size: clamp(1.9rem, 7vmin, 3.6rem); line-height: 1.02; letter-spacing: -0.02em; font-weight: 500; }
.duofy.is-bleed:not(.is-portrait) .duofy-cover.is-front .duofy-cover__text { padding-left: 1.5rem; }
.duofy.is-bleed:not(.is-portrait) .duofy-cover.is-back .duofy-cover__text { padding-right: 1.5rem; }

/* Seen through: beside the front and back cover, the camera heavily blurred, or the brand's gradient */
.duofy-see { position: absolute; left: 0; top: 0; z-index: 0; overflow: hidden; background: var(--duofy-dark); }
.duofy-see__glass { position: absolute; inset: 0; overflow: hidden; }
.duofy-see__glass::before {
    content: "";
    position: absolute;
    inset: -10%;
    background:
        radial-gradient(40% 55% at 22% 30%, var(--duofy-accent), transparent 70%),
        radial-gradient(45% 60% at 78% 72%, var(--duofy-dark), transparent 70%),
        radial-gradient(50% 50% at 60% 20%, var(--duofy-light), transparent 70%),
        var(--duofy-paper);
    filter: blur(40px) saturate(1.2);
    opacity: 0.9;
}
.duofy-see__glass video {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover;
    filter: blur(40px) saturate(1.2);
    transform: scale(1.25);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}
.duofy-see.has-camera video { opacity: 1; }

/* the info card: real text, always shown on the empty half */
.duofy-card {
    position: absolute;
    top: 0;
    width: var(--duofy-w);
    height: 100%;
    display: grid;
    place-items: center;
    padding: calc(var(--sa-t) + var(--duofy-control) + 1rem) 1.25rem calc(var(--sa-b) + 1.25rem);
}
.duofy-card.is-left { left: 0; padding-left: calc(1.25rem + var(--sa-l)); }
.duofy-card.is-right { left: var(--duofy-w); padding-right: calc(1.25rem + var(--sa-r)); }
.duofy-card__box {
    max-width: 22rem;
    padding: 1.3rem 1.4rem 1.4rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.8);
    color: #101010;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    text-align: left;
}
.duofy-card__subtitle { margin: 0 0 0.45rem; font-size: 0.7rem; line-height: 1.3; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; opacity: 0.65; }
.duofy-card__title { margin: 0; font-size: clamp(1.35rem, 4.4vmin, 2rem); line-height: 1.1; letter-spacing: -0.015em; font-weight: 400; }
.duofy-card__text { margin: 0.7rem 0 0; font-size: 0.9rem; line-height: 1.5; opacity: 0.85; }

/* Controls: Back at the top left, the turns at the bottom corners, all at least 44 × 44 and clear of the notch */
.duofy__back, .duofy__turn {
    position: fixed;
    z-index: 9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: var(--duofy-control);
    height: var(--duofy-control);
    margin: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(16, 16, 16, 0.55);
    color: #fff;
    font: 500 0.85rem/1 var(--duofy-font);
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    touch-action: manipulation;
}
.duofy__back { top: calc(var(--sa-t) + 8px); left: calc(var(--sa-l) + 8px); padding: 0 0.95rem 0 0.6rem; }
.duofy__back svg, .duofy__turn svg { width: 20px; height: 20px; flex-shrink: 0; }
.duofy__turn { bottom: calc(var(--sa-b) + 8px); width: var(--duofy-control); padding: 0; }
.duofy__prev { left: calc(var(--sa-l) + 8px); }
.duofy__next { right: calc(var(--sa-r) + 8px); }
.duofy__turn:disabled { opacity: 0; pointer-events: none; }
.duofy__back:hover, .duofy__turn:hover { background: rgba(16, 16, 16, 0.72); }
.duofy__back:focus-visible, .duofy__turn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px rgba(16, 16, 16, 0.6); }

/* the page number, for screen readers */
.duofy__status { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
    .duofy *, .duofy *::before, .duofy *::after { transition: none !important; animation: none !important; }
}
