/* GENERAL */
html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    min-height: 100dvh;
}

input {
    display: none;
}

.visually_hidden {
    width: 1px;
    height: 1px;
    position: absolute;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
}

/* NOTEBOOK CAMERA */
.notebook_viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
    overflow: clip;
    background-color: #f7f7f5;
    overscroll-behavior: none;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.notebook_viewport:focus-visible {
    outline: 2px solid rgb(201 164 93 / 75%);
    outline-offset: -4px;
}

.notebook_camera {
    --camera-x: 0px;
    --camera-y: 0px;
    --camera-scale: 1;
    width: 675px;
    height: 550px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -275px 0 0 -337.5px;
    transform: translate3d(var(--camera-x), var(--camera-y), 0) scale(var(--camera-scale));
    transform-origin: center;
    will-change: transform;
}

.notebook_viewport.is_panning,
.notebook_viewport.is_panning * {
    cursor: grabbing !important;
}

.notebook_controls {
    position: absolute;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    padding: 4px;
    border: 1px solid rgb(255 255 255 / 14%);
    border-radius: 999px;
    background: rgb(24 24 23 / 86%);
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
    backdrop-filter: blur(8px);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    z-index: 1000;
}

.notebook_control {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    color: #f8f4e8;
    background: transparent;
    font: 600 16px/1 ui-sans-serif, system-ui, sans-serif;
    cursor: pointer;
}

.notebook_control:hover {
    background: rgb(255 255 255 / 10%);
}

.notebook_control:focus-visible {
    outline: 2px solid var(--book-gold, #c9a45d);
    outline-offset: 1px;
}

.notebook_control:active {
    background: rgb(255 255 255 / 16%);
}

.notebook_zoom_value {
    min-width: 58px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* FLIP BOOK */
/* 2.5px represents 1mm: 130mm x 210mm pages inside 135mm x 220mm covers. */
.book_scene {
    width: 337.5px;
    height: 550px;
    perspective: 3750px;
    perspective-origin: center;
    position: absolute;
    top: 0;
    left: 168.75px;
}

#flip_book {
    --book-depth: 35px;
    --book-gold: #c9a45d;
    width: 337.5px;
    height: 550px;
    position: relative;
    transform: rotateY(38deg);
    transform-origin: center;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.2, 0.75, 0.25, 1);
}

.book_spine {
    width: var(--book-depth);
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 3.75px 0 0 3.75px;
    background: linear-gradient(90deg, #111110, #343432 55%, #181817);
    box-shadow: inset 1.25px 0 rgb(255 255 255 / 8%);
    transform: translateZ(calc(var(--book-depth) * -1)) rotateY(-90deg);
    transform-origin: left center;
    pointer-events: none;
}

.spine_name {
    position: absolute;
    left: 50%;
    bottom: 25px;
    color: var(--book-gold);
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    line-height: 1;
    text-shadow: 0 1.25px 1.25px rgb(0 0 0 / 60%);
    text-orientation: mixed;
    writing-mode: vertical-rl;
    transform: translateX(-50%) rotate(180deg);
    white-space: nowrap;
}

.front_cover,
.back_cover {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 0 10px 10px 0;
    background-image: linear-gradient(90deg, rgb(0 0 0 / 18%), transparent 5%, transparent 95%, rgb(0 0 0 / 15%));
    background-color: #20201f;
    box-shadow: 0 2.5px 10px rgb(25 25 25 / 30%);
}

.front_cover {
    position: absolute;
    background-color: transparent;
    background-image: none;
    cursor: pointer;
    transform-origin: center left;
    transform-style: preserve-3d;
    transition: transform 0.5s, box-shadow 0.6s;
    z-index: 99;
}

.front_cover label {
    width: 100%;
    height: 100%;
    position: absolute;
    cursor: pointer;
    z-index: 2;
}

.cover_face {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-color: #20201f;
    background-image: linear-gradient(90deg, rgb(0 0 0 / 18%), transparent 5%, transparent 95%, rgb(0 0 0 / 15%));
    backface-visibility: hidden;
    pointer-events: none;
}

.cover_outside {
    transform: rotateY(0deg);
}

.cover_inside {
    border-radius: 10px 3.75px 3.75px 10px;
    background-image: linear-gradient(270deg, rgb(0 0 0 / 18%), transparent 7%);
    box-shadow: inset -10px 0 17.5px rgb(0 0 0 / 18%);
    transform: rotateY(180deg);
}

.cover_name {
    position: absolute;
    right: 25px;
    bottom: 22.5px;
    color: var(--book-gold);
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 11.25px;
    font-weight: 600;
    letter-spacing: 0.18em;
    line-height: 1;
    text-shadow: 0 1.25px 1.25px rgb(0 0 0 / 55%);
    pointer-events: none;
    z-index: 1;
}

.page {
    width: 325px;
    height: 525px;
    position: absolute;
    top: 12.5px;
    left: 0;
    border-radius: 0 6.25px 6.25px 0;
    background-color: white;
    transform-origin: left;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition-duration: 0.5s;
}

.front_page {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 0 6.25px 6.25px 0;
    background-color: #fffdf4;
    background-image: linear-gradient(90deg, rgb(0 0 0 / 5%), transparent 3%);
}

.front_page label {
    width: 100%;
    height: 100%;
    position: absolute;
    cursor: pointer;
    z-index: 100;
}

.back_page {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    z-index: 100;
    border-radius: 6.25px 0 0 6.25px;
    background-color: #fffdf4;
    background-image: linear-gradient(270deg, rgb(0 0 0 / 7%), transparent 6%);
}

.front_page::before,
.back_page::before {
    content: "";
    position: absolute;
    inset: 6.25px;
    background-image: radial-gradient(circle, #dfdcd2 0.5px, transparent 0.75px);
    background-size: 12.5px 12.5px;
    pointer-events: none;
}

.back_page label {
    width: 100%;
    height: 100%;
    position: absolute;
    cursor: pointer;
    z-index: 100;
}

.back_cover {
    position: relative;
    transform: translateZ(calc(var(--book-depth) * -1));
    z-index: -1;
}

#page1 {
    z-index: 8;
}

#page2 {
    z-index: 5;
}

#page3 {
    z-index: 4;
}

#page4 {
    z-index: 3;
}

#page5 {
    z-index: 2;
}

#cover_checkbox:not(:checked)~#flip_book .front_cover {
    box-shadow: 16.25px 16.25px 22.5px rgb(25 25 25 / 30%);
}

.notebook_viewport:not(.is_panning) #cover_checkbox:not(:checked)~#flip_book:hover {
    transform: rotateY(0deg);
}

.notebook_viewport:not(.is_panning) #cover_checkbox:not(:checked)~#flip_book:hover .front_cover {
    box-shadow: 0 3.75px 11.25px rgb(25 25 25 / 30%);
}

#cover_checkbox:checked~#flip_book {
    transform: translateX(168.75px) rotateY(0deg);
}

#cover_checkbox:checked~#flip_book .front_cover {
    transform: rotateY(-180deg);
    transition: transform 1.5s, z-index 0.5s 0.5s;
    z-index: 1;
}

#cover_checkbox:checked~#flip_book #cover {
    width: 80%;
    height: 80%;
    position: absolute;
}

#page1_checkbox:checked~#flip_book #page1 {
    transform: rotateY(-180deg);
    z-index: 3;
}

#page2_checkbox:checked~#flip_book #page2 {
    transform: rotateY(-180deg);
    z-index: 4;
}

#page3_checkbox:checked~#flip_book #page3 {
    transform: rotateY(-180deg);
    z-index: 5;
}

#page4_checkbox:checked~#flip_book #page4 {
    transform: rotateY(-180deg);
    z-index: 6;
}

#page5_checkbox:checked~#flip_book #page5 {
    transform: rotateY(-180deg);
    z-index: 9;
}
