@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600;700&display=swap');

.font-handwriting {
  font-family: 'Dancing Script', cursive;
}

/* ===== SCROLL CONTAINER ===== */
.book-scroll-container {
  height: 400vh;
  width: 100%;
  position: relative;
  z-index: 20;
}

@media (max-width: 768px) {
  .book-scroll-container {
    height: 280vh;
  }
}

/* ===== STICKY VIEWPORT ===== */
.book-sticky-wrap {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 3rem;
  overflow: hidden;
}

@media (min-width: 768px) {
  .book-sticky-wrap {
    padding-bottom: 6rem;
  }
}

/* ===== TÍTULO ===== */
.book-title {
  position: absolute;
  top: 3rem;
  font-size: 1.5rem;
  color: #4a0d17;
  font-weight: 700;
  font-family: var(--font-serif, serif);
  z-index: 10;
  transition: opacity 0.2s;
}

@media (min-width: 768px) {
  .book-title {
    top: 6rem;
    font-size: 2.25rem;
  }
}

/* ===== PERSPECTIVE WRAPPER ===== */
.book-perspective-wrapper {
  position: relative;
  perspective: 2000px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2.5rem;
}

@media (min-width: 768px) {
  .book-perspective-wrapper {
    margin-top: 0;
  }
}

/* ===== MESA DE MADEIRA ===== */
.book-table {
  position: relative;
  transform-style: preserve-3d;

  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 12px solid #2c1308;
  border-right: 6px solid #2c1308;
  background-color: #3e1f13;
  background-image: url('https://images.unsplash.com/photo-1550684376-efcbd6e3f031?q=80&w=2000&auto=format&fit=crop');
  background-size: cover;
  background-position: center;
  will-change: transform;
  /* Dimensões base (JS anima o transform) */
  width: 95vw;
  max-width: 1100px;
  height: 50vh;
  max-height: 750px;
}

@media (min-width: 768px) {
  .book-table {
    height: 80vh;
    border-radius: 40px;
    border-bottom: 16px solid #2c1308;
    border-right: 8px solid #2c1308;
  }
}

.book-table-overlay-1 {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  border-radius: 15px;
  pointer-events: none;
  transform: translateZ(1px);
}

.book-table-overlay-2 {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 5%, rgba(0, 0, 0, 0.8) 100%);
  border-radius: 15px;
  pointer-events: none;
  transform: translateZ(2px);
}

@media (min-width: 768px) {

  .book-table-overlay-1,
  .book-table-overlay-2 {
    border-radius: 30px;
  }
}

/* ===== SOMBRA PROJETADA DO CADERNO ===== */
.book-table-shadow {
  display: none;
}

/* ===== CADERNO 3D ===== */
.book-3d-root {
  position: relative;
  width: 95%;
  max-width: 650px;
  aspect-ratio: 1.4 / 1;
  transform-style: preserve-3d;
  will-change: transform;
  transform: translateZ(30px) rotateY(-2deg);
}

@media (min-width: 640px) {
  .book-3d-root {
    width: 85%;
  }
}

@media (min-width: 768px) {
  .book-3d-root {
    aspect-ratio: 16 / 10;
  }
}

/* ===== LADO DIREITO (PÁGINAS) ===== */
.book-right-side {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 10;
  transform-style: preserve-3d;
}

.book-right-page {
  position: absolute;
  inset: 0;
  background-color: #f4ebd9;
  border-radius: 0 0.75rem 0.75rem 0;
  border: 1px solid #d8c39b;
  box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .book-right-page {
    border-radius: 0 1rem 1rem 0;
  }
}

.book-page-shadow {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.5rem;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.2), transparent);
  z-index: 0;
  pointer-events: none;
}

@media (min-width: 768px) {
  .book-page-shadow {
    width: 3rem;
  }
}

/* ===== GRID DE RESULTADOS ===== */
.book-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  position: relative;
  z-index: 10;
}

.book-grid-line-h {
  grid-column: span 2;
  grid-row: span 1;
  border-bottom: 1px solid #e5d5b7;
  position: absolute;
  top: 50%;
  width: 100%;
}

.book-grid-line-v {
  grid-row: span 2;
  grid-column: span 1;
  border-right: 1px solid #e5d5b7;
  position: absolute;
  height: 100%;
  left: 50%;
}

.book-grid-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  position: relative;
  text-align: center;
}

@media (min-width: 768px) {
  .book-grid-cell {
    padding: 1rem;
  }
}

.book-val-wrap {
  position: relative;
  display: inline-block;
}

.book-val {
  display: block;
  color: #a88641;
  font-weight: 700;
  font-size: 1.5rem;
  white-space: nowrap;
  will-change: clip-path;
  font-family: 'Dancing Script', cursive;
}

@media (min-width: 640px) {
  .book-val {
    font-size: 1.875rem;
  }
}

@media (min-width: 768px) {
  .book-val {
    font-size: 3rem;
  }
}

.book-lbl {
  color: #6b3838;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
  text-transform: uppercase;
  text-align: center;
  transition: opacity 0.3s;
  opacity: 0;
  line-height: 1.2;
  padding: 0 4px;
}

@media (min-width: 640px) {
  .book-lbl {
    font-size: 9px;
    letter-spacing: 0.1em;
  }
}

@media (min-width: 768px) {
  .book-lbl {
    font-size: 0.75rem;
    margin-top: 0.5rem;
  }
}

/* ===== CAPA (LADO ESQUERDO) ===== */
.book-left-cover-wrap {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-origin: right center;
  transform-style: preserve-3d;
  z-index: 30;
  will-change: transform;
  transition: transform 0.1s ease-out;
}

.book-cover-exterior,
.book-cover-interior {
  position: absolute;
  inset: 0;
  border-radius: 0.75rem 0 0 0.75rem;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

@media (min-width: 768px) {

  .book-cover-exterior,
  .book-cover-interior {
    border-radius: 1rem 0 0 1rem;
  }
}

.book-cover-exterior {
  background: linear-gradient(to right, #4a0d17, #360812);
  border: 1px solid rgba(113, 63, 18, 0.5);
  box-shadow: 10px 0 20px rgba(0, 0, 0, 0.5);
  transform: rotateY(180deg) translateZ(1px);
}

.book-cover-spine-shadow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1rem;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.6), transparent);
  pointer-events: none;
}

@media (min-width: 768px) {
  .book-cover-spine-shadow {
    width: 2rem;
  }
}

.book-cover-content {
  text-align: center;
}

.book-cover-icon-wrap {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 0.5rem auto;
  border-radius: 9999px;
  border: 1px solid rgba(202, 138, 4, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #360812;
}

@media (min-width: 640px) {
  .book-cover-icon-wrap {
    width: 3rem;
    height: 3rem;
  }
}

@media (min-width: 768px) {
  .book-cover-icon-wrap {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
  }
}

.book-cover-content h3 {
  color: #eab308;
  font-family: var(--font-serif, serif);
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@media (min-width: 640px) {
  .book-cover-content h3 {
    font-size: 1.125rem;
  }
}

@media (min-width: 768px) {
  .book-cover-content h3 {
    font-size: 1.25rem;
  }
}

.book-cover-interior {
  background-color: #eeddb9;
  border: 1px solid #d8c39b;
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
  transform: rotateY(0deg) translateZ(1px);
}

.book-interior-spine-shadow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1.5rem;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.2), transparent);
  pointer-events: none;
}

@media (min-width: 768px) {
  .book-interior-spine-shadow {
    width: 3rem;
  }
}

.book-interior-border {
  width: 85%;
  height: 85%;
  border: 1px solid #d8c39b;
  border-radius: 0.25rem;
  opacity: 0.4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  padding: 0.5rem;
  text-align: center;
}

.book-interior-border span {
  color: #a88641;
  font-family: var(--font-serif, serif);
  font-size: 10px;
  letter-spacing: 0.1em;
  font-style: italic;
  margin-bottom: 0.25rem;
}

@media (min-width: 640px) {
  .book-interior-border span {
    font-size: 12px;
  }
}

@media (min-width: 768px) {
  .book-interior-border span {
    font-size: 14px;
    margin-bottom: 0.5rem;
  }
}

.book-interior-line {
  width: 2rem;
  height: 1px;
  background-color: #a88641;
}

@media (min-width: 768px) {
  .book-interior-line {
    width: 3rem;
  }
}

/* ===== LOMBADA ===== */
.book-spine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, #8f6d33, #e3c78d, #8f6d33);
  z-index: 20;
  transform: translateX(-50%);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@media (min-width: 768px) {
  .book-spine {
    width: 6px;
  }
}

/* ===== CANETA ===== */
.book-pen-container {
  position: absolute;
  z-index: 30;
  transition: all 75ms ease-out;
  pointer-events: none;
  opacity: 0;
}

.book-pen-wrapper {
  position: relative;
  width: 3rem;
  height: 3rem;
}

@media (min-width: 640px) {
  .book-pen-wrapper {
    width: 4rem;
    height: 4rem;
  }
}

@media (min-width: 768px) {
  .book-pen-wrapper {
    width: 5rem;
    height: 5rem;
  }
}

.book-pen-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 25px 25px rgba(0, 0, 0, 0.15));
  position: relative;
  z-index: 10;
  overflow: visible;
}

.book-pen-glitter {
  position: absolute;
  top: 8%;
  right: 8%;
  z-index: 0;
  pointer-events: none;
  display: none;
}

.pen-particle {
  position: absolute;
  border-radius: 9999px;
  box-shadow: 0 0 6px rgba(253, 224, 71, 0.9);
}

/* ===== ANIMAÇÕES ===== */
@keyframes cursive-writing {
  0% {
    transform: translate(0px, 0px) rotate(0deg);
  }

  15% {
    transform: translate(2px, -6px) rotate(-3deg);
  }

  30% {
    transform: translate(5px, 2px) rotate(3deg);
  }

  45% {
    transform: translate(1px, -4px) rotate(-1deg);
  }

  60% {
    transform: translate(4px, 3px) rotate(4deg);
  }

  80% {
    transform: translate(2px, -5px) rotate(-2deg);
  }

  100% {
    transform: translate(0px, 0px) rotate(0deg);
  }
}

.animate-cursive-writing {
  animation: cursive-writing 0.6s ease-in-out infinite;
}

@keyframes pen-glitter-fall {
  0% {
    transform: translate(0px, 0px) scale(1) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translate(var(--tx), var(--ty)) scale(0) rotate(180deg);
    opacity: 0;
  }
}

.animate-pen-glitter {
  animation: pen-glitter-fall var(--dur) ease-in infinite;
  animation-delay: var(--del);
}

/* ==========================================================================
   TIMELINE SECTION (BLOQUE 04)
   ========================================================================== */
.timeline-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Lines */
.timeline-line-bg {
  position: absolute;
  left: 32px;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: rgba(229, 213, 183, 0.5);
  /* #e5d5b7 */
  transform: translateX(-50%);
}

.timeline-line-active {
  position: absolute;
  left: 32px;
  top: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom, #bd9a55, #7a5c2b);
  transform-origin: top center;
  transform: translateX(-50%) scaleY(0) translateZ(0);
  will-change: transform;
}

@media (min-width: 768px) {

  .timeline-line-bg,
  .timeline-line-active {
    left: 50%;
  }
}

/* Markers */
.timeline-start-marker {
  position: absolute;
  left: 32px;
  top: 0;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background-color: #fcfbf8;
  border: 2px solid #bd9a55;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 0 0 15px rgba(189, 154, 85, 0.3);
}

@media (min-width: 768px) {
  .timeline-start-marker {
    left: 50%;
  }
}

.timeline-start-marker svg {
  width: 22px;
  height: 22px;
  color: #521c22;
  overflow: visible;
}

.house-path-1,
.house-path-2,
.house-path-3 {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: draw-house 3s ease-in-out infinite alternate;
}

.house-path-1 {
  animation-delay: 0s;
}

.house-path-2 {
  animation-delay: 0.5s;
}

.house-path-3 {
  animation-delay: 1s;
}

@keyframes draw-house {
  0% {
    stroke-dashoffset: 100;
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

.timeline-moving-marker {
  position: absolute;
  left: 32px;
  top: 0;
  transform: translate(-50%, -24px) translateZ(0);
  z-index: 30;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

@media (min-width: 768px) {
  .timeline-moving-marker {
    left: 50%;
  }
}

@keyframes ping-soft {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }

  75%,
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.timeline-marker-pulse {
  position: absolute;
  inset: 0;
  background-color: #bd9a55;
  border-radius: 50%;
  animation: ping-soft 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  width: 100%;
  height: 100%;
}

.timeline-marker-inner {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #7a1528, #2a050b);
  border: 2px solid #fcf6ba;
  border-radius: 50%;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.timeline-marker-inner svg {
  width: 24px;
  height: 24px;
  color: white;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

/* Cards & 3D Container */
.timeline-container {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.timeline-cards {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6rem;
  padding-top: 4rem;
  padding-bottom: 6rem;
  z-index: 10;
}

@media (min-width: 768px) {
  .timeline-cards {
    gap: 14rem;
  }
}

.timeline-row {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  /* Mobile: all cards right */
  position: relative;
}

@media (min-width: 768px) {
  .timeline-row.left {
    justify-content: flex-start;
  }
}

/* Base Card Styles */
.timeline-card {
  position: relative;
  width: 82%;
  background: white;
  border-radius: 0.75rem;
  overflow: hidden;
  z-index: 10;
  transform-origin: center center;
  transition: all 1200ms cubic-bezier(0.23, 1, 0.32, 1);
  /* Hidden state */
  opacity: 0;
  border: 1px solid transparent;
}

@media (min-width: 768px) {
  .timeline-card {
    width: 42%;
  }
}

/* Directional Hidden States */
.timeline-row.left .timeline-card {
  transform: translateX(3rem) rotateY(20deg) translateZ(-100px);
}

.timeline-row.right .timeline-card {
  transform: translateX(-3rem) rotateY(-20deg) translateZ(-100px);
}

/* Visible (but not current/past) */
.timeline-row.visible .timeline-card {
  opacity: 0.5;
  transform: scale(0.95);
  border-color: #e5d5b7;
}

/* Current */
.timeline-row.is-current .timeline-card {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 25px 50px rgba(82, 28, 34, 0.15);
  border: 1.5px solid #bd9a55;
  z-index: 20;
}

/* Past */
.timeline-row.is-past .timeline-card {
  opacity: 0.6;
  transform: scale(0.95);
  filter: grayscale(30%) blur(0.5px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  border: 1px solid #e5d5b7;
}

/* Connector (Desktop) */
.timeline-connector {
  display: none;
  position: absolute;
  top: 50%;
  width: 4rem;
  height: 2px;
  background: linear-gradient(to right, transparent, #bd9a55);
  transition: all 700ms ease-out;
  opacity: 0;
  transform: scaleX(0);
  z-index: 0;
}

@media (min-width: 768px) {
  .timeline-connector {
    display: block;
  }
}

.timeline-row.left .timeline-connector {
  right: calc(50% + 2px);
  transform-origin: right;
}

.timeline-row.right .timeline-connector {
  background: linear-gradient(to left, transparent, #bd9a55);
  left: calc(50% + 2px);
  transform-origin: left;
}

.timeline-row.visible .timeline-connector,
.timeline-row.is-current .timeline-connector,
.timeline-row.is-past .timeline-connector {
  opacity: 1;
  transform: scaleX(1);
}

.timeline-connector-pulse {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #fcf6ba;
  box-shadow: 0 0 8px #fcf6ba;
  animation: pulse-soft 2s infinite;
}

@keyframes pulse-soft {
  0% {
    transform: translateY(-50%) scale(0.9);
    opacity: 0.7;
  }

  50% {
    transform: translateY(-50%) scale(1.1);
    opacity: 1;
  }

  100% {
    transform: translateY(-50%) scale(0.9);
    opacity: 0.7;
  }
}

.timeline-row.left .timeline-connector-pulse {
  left: 0;
}

.timeline-row.right .timeline-connector-pulse {
  right: 0;
}

/* Text & Highlight Transitions */
.timeline-card-content {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  transition: all 1000ms;
}

@media (min-width: 768px) {
  .timeline-card-content {
    gap: 1.5rem;
    padding: 2rem;
  }
}

.timeline-num {
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.125rem;
  font-weight: bold;
  flex-shrink: 0;
  transition: color 1000ms;
  color: #d8c39b;
}

@media (min-width: 768px) {
  .timeline-num {
    font-size: 1.25rem;
  }
}

.timeline-row.is-current .timeline-num {
  color: #bd9a55;
}

.timeline-text {
  font-size: 0.875rem;
  line-height: 1.625;
  transition: color 1000ms;
  color: #777;
  margin: 0;
}

@media (min-width: 768px) {
  .timeline-text {
    font-size: 1rem;
  }
}

.timeline-row.is-current .timeline-text {
  color: #333;
}

.timeline-text strong {
  transition: color 1000ms;
  color: #555;
  font-weight: 700;
}

.timeline-row.is-current .timeline-text strong {
  color: #521c22;
}

/* Watermark */
.timeline-card-watermark {
  position: absolute;
  right: -1rem;
  top: -2rem;
  font-size: 9rem;
  font-family: var(--font-serif, Georgia, serif);
  color: #bd9a55;
  opacity: 0.05;
  pointer-events: none;
  user-select: none;
}

/* Highlight Border */
.timeline-card-highlight {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.25rem;
  background: linear-gradient(to right, #bd9a55, #fcf6ba);
  opacity: 0;
  transition: opacity 1000ms;
}

.timeline-row.is-current .timeline-card-highlight {
  opacity: 1;
}

/* ===== MOBILE FIXES ===== */
@media (max-width: 480px) {
  .book-table {
    width: 92vw;
    height: 45vh;
    border-radius: 14px;
    border-bottom: 8px solid #2c1308;
    border-right: 4px solid #2c1308;
  }

  .book-table-overlay-1,
  .book-table-overlay-2 {
    border-radius: 10px;
  }

  .book-3d-root {
    width: 92%;
  }

  .book-val {
    font-size: 1.3rem;
  }

  .book-lbl {
    font-size: 7px;
    letter-spacing: 0.03em;
    padding: 0 2px;
  }

  .book-grid-cell {
    padding: 0.25rem;
  }

  .book-title {
    top: 2rem;
    font-size: 1.2rem;
  }

  .book-perspective-wrapper {
    margin-top: 1.5rem;
  }

  .timeline-cards {
    gap: 4rem;
    padding-top: 3rem;
    padding-bottom: 4rem;
  }

  .timeline-card {
    width: 78%;
  }

  .timeline-card-content {
    padding: 1rem;
    gap: 0.75rem;
  }

  .timeline-text {
    font-size: 0.8rem;
    line-height: 1.5;
  }

  .timeline-card-watermark {
    font-size: 5rem;
  }
}