/*
  flipbook.css
  Original source code by Roko C. Buljan (https://codepen.io/rokobuljan/pen/jORNEyz)
  Copyright (c) 2025 Roko C. Buljan
  Modified by shamimsulaiman.com
  License: MIT
/* ------------------------------------------------------------------
   Layout
   (positioning, sizing, stacking, transform-style, perspective)
   ------------------------------------------------------------------ */

* { box-sizing: border-box; }

/* centers flipbook and provides 3D perspective */
.flipbook-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 2000px;
  height: 100vh;
}

/* book container: maintains aspect ratio and vertical scaling */
.book {
  position: relative;
  display: flex;
  margin-left: 90vw;
  height: 100vh; /* Force vertical scaling */
  aspect-ratio: 2159 / 2794; /* Maintain US Letter shape */
  width: auto; /* Auto width based on height and aspect ratio */
  max-width: 100vw;
  pointer-events: none;
  transform-style: preserve-3d;
  transition: translate 1s;
  translate: calc(min(var(--c), 1) * 50%) -10vh; /* optional adjustment */
  rotate: 1 0 0 20deg;
  counter-reset: page -1; /* page counter reset kept here */
}

/* page layout and stacking in 3D */
.page {
  --thickness: 4; /* PS: Don't go below thickness 0.5 or the pages might transpare */
  flex: none;
  display: flex;
  height: 100%;
  width: 100%;
  font-size: 2cqmin;
  pointer-events: all; /* allow pointer events on pages */
  user-select: none;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition:
    transform 1s,
    rotate 1s ease-in calc((min(var(--i), var(--c)) - max(var(--i), var(--c))) * 50ms);
  translate: calc(var(--i) * -100%) 0px 0px;
  transform: translateZ( calc((var(--c) - var(--i) - 0.5) * calc(var(--thickness) * .23cqmin)));
  rotate: 0 1 0 calc(clamp(0, var(--c) - var(--i), 1) * -180deg);
  box-shadow: 0em .5em 1em -.2em #00000020; /* subtle page shadow */
}

/* object/embed inside page */
.page object {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

/* ensure page images/objects don't intercept pointer events */
.page object,
.page img {
  pointer-events: none;
}

/* front/back panels positioned and sized */
.front,
.back {
  position: relative;
  flex: none;
  height: 100%;
  width: 100%;
  backface-visibility: hidden;
  overflow: hidden;
  background-color: #f6f2f2; /* initial page background */
  translate: 0px; /* Fix backface visibility Firefox */
  display: flex;
  flex-flow: column wrap;
  justify-content: space-between;
  border: 1px solid #0002;
}

/* back panel flipped */
.back {
  translate: -100% 0;
  rotate: 0 1 0 180deg;
}

/* images inside front/back */
.front img,
.back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* page number pseudo-element (shared for front/back) */
.front::after,
.back::after {
  position: absolute;
  bottom: 1em;
  counter-increment: page;
  font-size: 0.8em;
}

/* cover specifics: remove pseudo content for covers */
.cover::after {
  content: "";
}

/* front vs back small differences */
.front::after { right: 1em; }
.back::after  { left: 1em; }

.front {
  background: linear-gradient(to left, #f7f7f7 80%, #eee 100%);
  border-radius: .1em .5em .5em .1em;
}

.back {
  background-image: linear-gradient(to right, #f7f7f7 80%, #eee 100%);
  border-radius: .5em .1em .1em .5em;
}

/* cover artwork and color */
.cover {
  background: radial-gradient(circle farthest-corner at 80% 20%, hsl(150 80% 20% / .3) 0%, hsl(170 60% 10% / .1) 100%),
    hsl(231, 32%, 29%) url("https://picsum.photos/id/984/800/900") 50% / cover;
  color: hsl(200 30% 98%);
}

/* anchor tag color inside book (flattened from nested rule) */
.book a { color: inherit; }


/* ------------------------------------------------------------------
   Visuals & Overrides
   (colors, backgrounds, shadows, forced overrides)
   ------------------------------------------------------------------ */

/* Important cascade-preserving overrides from original file:
   These were present late in the source and intentionally remove
   backgrounds/borders/shadows for certain containers — keep them
   so the final visual output remains identical. */

/* drop backgrounds and decorative borders on book/page base */
.book,
.page {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* front/back visual reset (keeps background-size/position from original) */
.front,
.back {
  background-size: contain;
  background-position: center center;
  background-repeat: no-repeat;
  background-color: transparent;
  border: none !important;
  box-shadow: none !important;
}


/* ------------------------------------------------------------------
   States
   (interactive, pointer, backface, :has usage)
   ------------------------------------------------------------------ */

/* when front/back has an image, remove padding (flattened :has usage) */
.front:has(img),
.back:has(img) {
  padding: 0;
}

/* pointer-events already set on .page above; keep it explicit if needed */
.page { pointer-events: all; }

/* keep backface and transform-origin rules above to ensure flip behavior */


/* ------------------------------------------------------------------
   Content (images, counters, embeds)
   ------------------------------------------------------------------ */

/* object and img rules already defined above; keep additional content rules here */
/* (no renames or content changes) */


/* ------------------------------------------------------------------
   Animations & Transforms
   (rotations, transitions, translate/rotate properties)
   ------------------------------------------------------------------ */

/* transitions and transforms are defined on .book and .page earlier */
/* kept identical to ensure animations and timing remain exactly the same */


/* ------------------------------------------------------------------
   Responsive (mobile → desktop)
   ------------------------------------------------------------------ */

/* Small phones (e.g., iPhone SE) */
@media (max-width: 375px) {
  .book {
    margin-left: 95vw;
  }
}

/* Standard phones (e.g., iPhone 14 Pro Max, Pixel 7, S20 Ultra) */
@media (min-width: 376px) and (max-width: 599px) {
  .book {
    margin-left: 95vw;
  }
}

/* Small tablets (e.g., iPad Mini, small Android tablets) */
@media (min-width: 600px) and (max-width: 767px) {
  .book {
    margin-left: 95vw;
  }
}

/* Medium tablets (e.g., iPad Air, portrait iPad Pro) */
@media (min-width: 768px) and (max-width: 1023px) {
  .book {
    margin-left: 95vw;
  }
}

/* Large tablets / small laptops (e.g., iPad Pro landscape, 13" laptops) */
@media (min-width: 1024px) and (max-width: 1439px) {
  .book {
    margin-left: 95vw;
  }
}

/* Full desktop and ultrawide screens */
@media (min-width: 1440px) {
  .book {
    margin-left: 0;
  }
}

/* ------------------------------------------------------------------
   Landscape auto-adjustment (Nest Hub, iPad landscape)
   ------------------------------------------------------------------ */

/* For wide, short viewports like Nest Hub */
@media (orientation: landscape) and (max-height: 700px) {
  .book {
    margin-left: 10vw; /* reduce spacing for short landscape displays */
  }
}

/* For larger landscape tablets (e.g., iPad Pro landscape) */
@media (orientation: landscape) and (min-height: 701px) and (min-width: 1024px) {
  .book {
    margin-left: 30vw; /* slightly reduced spacing */
  }
}

/* ------------------------------------------------------------------
   Device type auto-adjustment (touch vs desktop)
   ------------------------------------------------------------------ */

/* Desktops only — center the book fully */
@media (hover: hover) and (pointer: fine) {
  .book {
    margin-left: 0;
  }
}

/* ------------------------------------------------------------------
   Responsive — desktop only
   ------------------------------------------------------------------ */

/* Super Small desktop screens */
@media (hover: hover) and (pointer: fine) and (min-width: 150px) {
  .book {
    margin-left: 90vw;
  }
}
/* Small desktop screens */
@media (hover: hover) and (pointer: fine) and (min-width: 600px) {
  .book {
    margin-left: 90vw;
  }
}

/* Medium desktop screens */
@media (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  .book {
    margin-left: 50vw;
  }
}

/* Large and ultrawide desktops */
@media (hover: hover) and (pointer: fine) and (min-width: 1440px) {
  .book {
    margin-left: 0; /* center on large screens */
  }
}

/* ------------------------------------------------------------------
   End of file
   ------------------------------------------------------------------ */
