/* project5.css - Sketchbook, restyled to match project0's light design system */

:root {
  --bg-solid: #ffffff;
  --bg: #ffffff;
  --text: #100f0e;
  --muted: #47423d;
  --accent: #D03A46;
  --accent-light: #e0636c;
  --paper: #faf8f2;
  --shadow: rgba(16, 15, 14, 0.25);
  --card-bg: #ffffff;
  --card-border: rgba(16, 15, 14, 0.14);
  --card-hover-bg: #fbfaf8;
  --shadow-sm: 0 1px 2px rgba(16, 15, 14, 0.04), 0 4px 14px rgba(16, 15, 14, 0.07);
  --shadow-md: 0 4px 10px rgba(16, 15, 14, 0.06), 0 12px 28px rgba(16, 15, 14, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Space Grotesk', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-solid);
  overflow-x: hidden;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
}

/* Back Link */
.back-link {
  position: absolute;
  top: 50px;
  left: max(2rem, calc((100vw - 900px) / 2));
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}

.back-link-arrow {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.back-link-arrow svg {
  width: 16px;
  height: 16px;
  stroke: var(--text);
  transition: stroke 0.3s ease, transform 0.3s ease;
}

.back-link:hover .back-link-arrow,
.footer-back-link:hover .back-link-arrow {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateX(-3px);
}

.back-link:hover .back-link-arrow svg,
.footer-back-link:hover .back-link-arrow svg {
  stroke: #ffffff;
}

.project4 {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* HEADER */
.p4-header {
  text-align: center;
  padding: 7rem 2rem 3rem;
}

.p4-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3.1rem;
  font-weight: 800;
  letter-spacing: -1px;
  text-transform: none;
  margin-bottom: 1.5rem;
  color: var(--text);
  line-height: 1.15;
  opacity: 0;
  animation: fadeIn 0.8s ease forwards 0.2s;
}

.p4-header .sub {
  font-size: 1.2rem;
  line-height: 1.65;
  color: var(--muted);
  font-weight: 400;
  max-width: 700px;
  margin: 0 auto;
  letter-spacing: 0;
  opacity: 0;
  animation: fadeIn 0.8s ease forwards 0.4s;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Flipbook wrapper */
.flipbook-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 50px;
  padding-bottom: 2rem;
}

/* Book */
.book {
  width: min(75vw, 720px);
  margin: 0 auto;
  perspective: 1800px;
}

/* Keep aspect ratio ~ landscape notebook (w:h ≈ 3:2) */
.sheets {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: transparent;
  filter: drop-shadow(0 20px 40px var(--shadow));
}

/* Covers (static background pages) — kept as a physical book object, not a UI card */
.cover {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  background-color: #6e6d6d;
  background-image:
    radial-gradient(circle, #f9f8f8 30%, transparent 31%),
    radial-gradient(circle, #ffffff 30%, transparent 31%);
  background-size: 60px 60px, 60px 60px;
  background-position: 0 0, 30px 30px;
  z-index: 0;
}

.left-cover  { left: 0;  border-radius: 8px 0 0 8px; }
.right-cover { right: 0; border-radius: 0 8px 8px 0; }

/* Each SHEET (a physical folio with a front-right and back-left) */
.sheet {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.2,.8,.2,1);
  z-index: 10;
  will-change: transform;
}

/* Pages inside a sheet */
.page {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  background: var(--paper);
  backface-visibility: hidden;
  border: 1px solid rgba(16, 15, 14, 0.08);
}

.page.right.front,
.page.left.back {
  background: linear-gradient(to right, #fff, #f8f8f8 98%);
}

.page.left.back {
  background: linear-gradient(to left, #fff, #f8f8f8 98%);
}

/* RIGHT page (front of sheet) */
.page.right {
  right: 0;
  transform-origin: left center;
  border-radius: 0 8px 8px 0;
  box-shadow:
    inset 8px 0 16px rgba(16,15,14,.06),
    0 2px 8px rgba(16,15,14,.08);
}

/* LEFT page (back of sheet) */
.page.left {
  left: 0;
  transform-origin: right center;
  border-radius: 8px 0 0 8px;
  box-shadow:
    inset -8px 0 16px rgba(16,15,14,.06),
    0 2px 8px rgba(16,15,14,.08);
  transform: rotateY(180deg);
}

.sheet.flipping .right.front {
  box-shadow: inset -40px 0 40px rgba(16,15,14,0.2);
}

.sheet.flipping .left.back {
  box-shadow: inset 40px 0 40px rgba(16,15,14,0.2);
}

/* Images fill page, keep proportion */
.page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 40% 5%;
}

/* FLIP state: rotate the entire sheet so its back-left shows */
.sheet.flipped {
  transform: rotateY(-180deg);
}

/* Add subtle hinge shadow while flipping */
.sheet:not(.flipped) .right.front::after,
.sheet.flipped .left.back::after {
  content: "";
  position: absolute; top: 0; bottom: 0; width: 14px;
  left: -14px;
  background: linear-gradient(to right, rgba(16,15,14,.14), rgba(16,15,14,0));
  pointer-events: none;
}

/* Nav buttons */
.nav {
  appearance: none;
  cursor: pointer;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.nav svg {
  display: block;
}

.nav:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  transform: scale(1.1);
}

.nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Smoother GPU compositing and no text/image selection while dragging */
.book, .sheet, .page, .page img {
  user-select: none;
  -webkit-user-select: none;
}

.page img {
  pointer-events: none;
}

/* Nice hand cursor */
.book {
  cursor: grab;
}

.book:active {
  cursor: grabbing;
}

/* Hint animation */
.page.hint {
  transform-origin: left center;
  animation: demoFlip 1.2s ease-in-out 1;
}

@keyframes demoFlip {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(-90deg); }
  100% { transform: rotateY(0deg); }
}

.page.hint.animate-flip {
  animation: demoFlip 1.2s ease-in-out 1;
}

/* Bottom back link, matching the rest of the site */
.bottom-link-wrapper {
  position: relative;
  margin-bottom: 40px;
  padding-top: 3rem;
  min-height: 60px;
  text-align: center;
}

.footer-back-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}

/* FOOTER - Match other projects */
.site-footer {
  text-align: center;
  padding: 45px 20px;
  font-size: 0.9rem;
  color: #8a8682;
  border-top: 1px solid #e8e5e1;
  background: rgba(250, 249, 247, 0.6);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .project4 {
    padding: 0 1.5rem;
  }

  .back-link {
    top: 20px;
    left: 1.5rem;
  }

  .back-link-arrow {
    width: 34px;
    height: 34px;
  }

  .back-link-arrow svg {
    width: 14px;
    height: 14px;
  }

  .p4-header {
    padding: 6.5rem 1.5rem 2.5rem;
  }

  .p4-header h1 {
    font-size: 2.5rem;
  }

  .p4-header .sub {
    font-size: 1rem;
  }

  .flipbook-wrap {
    gap: 10px;
    padding-bottom: 4rem;
  }

  .nav {
    width: 44px;
    height: 44px;
  }

  .book {
    width: min(85vw, 600px);
  }

  .bottom-link-wrapper {
    margin-bottom: 50px;
  }

  .site-footer {
    padding: 30px 20px;
  }
}

@media (max-width: 480px) {
  .p4-header h1 {
    font-size: 2rem;
  }

  .book {
    width: 90vw;
  }

  .nav {
    width: 40px;
    height: 40px;
  }
}