/**
 * ============================================================
 *
 * @format
 */

/*  HISTORIETA HOJEABLE · "Origen del predial"                  */
/* ============================================================ */

.origin-predial-modal {
  --paper: #f6edd8;
  --paper-2: #fbf5e6;
  --ink: #16130f;
  --blue: #2f6fb0;
  --blue-deep: #1e3f63;
  --orange: #ff6b35;
  --red: #e0392b;
  --dot: rgba(22, 19, 15, 0.16);

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

.origin-predial-modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.origin-predial-modal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 35%,
    rgba(47, 111, 176, 0.45),
    rgba(8, 11, 16, 0.85) 70%
  );
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* contenedor */
.origin-predial-modal-content {
  position: relative;
  z-index: 2;
  width: min(860px, 96vw);
  transform: translateY(26px) scale(0.94);
  transition: transform 0.45s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.origin-predial-modal[aria-hidden="false"] .origin-predial-modal-content {
  transform: none;
}

.origin-predial-modal-close {
  position: absolute;
  top: -16px;
  right: -12px;
  z-index: 30;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  color: var(--paper);
  background: var(--red);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.origin-predial-modal-close:hover {
  transform: rotate(90deg) scale(1.05);
  box-shadow: 5px 5px 0 var(--ink);
}

/* ============ LIBRO 3D ============ */
.opc-book {
  position: relative;
  height: min(76vh, 600px);
  perspective: 2200px;
}

/* cada hoja */
.opc-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px 42px;
  overflow: auto;
  background:
    radial-gradient(var(--dot) 1.4px, transparent 1.5px) 0 0 / 16px 16px,
    var(--paper);
  border: 5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 12px 12px 0 rgba(22, 19, 15, 0.8);
  transform-origin: left center;
  transform: rotateY(0deg);
  transition:
    transform 0.85s cubic-bezier(0.55, 0.05, 0.25, 1),
    box-shadow 0.4s ease;
  backface-visibility: hidden;
}

/* lomo del libro (sombra interior izquierda) */
.opc-page::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 46px;
  z-index: 1;
  background: linear-gradient(90deg, rgba(22, 19, 15, 0.18), transparent);
  pointer-events: none;
  border-radius: 12px 0 0 12px;
}

/* sombra que crece al girar la hoja */
.opc-page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
  border-radius: 10px;
}

.opc-page.is-turning::after {
  opacity: 1;
}

/* ============ PORTADA ============ */
.opc-page--cover {
  text-align: center;
  align-items: center;
}

.opc-halftone {
  position: absolute;
  inset: -30px -30px auto;
  height: 210px;
  z-index: 0;
  background: radial-gradient(var(--blue) 22%, transparent 23%) 0 0/13px 13px;
  opacity: 0.16;
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 50% 0%, #000, transparent 72%);
}

.opc-kicker {
  position: relative;
  z-index: 3;
  display: inline-block;
  margin-bottom: 6px;
  padding: 7px 20px;
  background: var(--orange);
  color: var(--ink);
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-2deg);
}

.opc-title {
  position: relative;
  z-index: 3;
  margin: 8px 0 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 6.5vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(47, 111, 176, 0.28);
}

.opc-title strong {
  color: var(--blue);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 3px 0 var(--orange);
}

.opc-lead {
  position: relative;
  z-index: 3;
  max-width: 560px;
  margin: 12px auto 0;
  color: #4a4234;
  font-size: clamp(0.92rem, 1.5vw, 1.05rem);
  font-weight: 600;
  line-height: 1.55;
}

.opc-hero-char {
  position: relative;
  z-index: 3;
  margin-top: auto;
  height: 190px;
  width: 100%;
}

.opc-char {
  display: block;
}

.opc-char--run {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 200px;
  height: auto;
  transform: translateX(-50%);
  filter: drop-shadow(6px 8px 0 rgba(22, 19, 15, 0.22));
  animation: opcRun 1.1s ease-in-out infinite;
}

.opc-speed {
  position: absolute;
  bottom: 64px;
  right: calc(50% + 92px);
  width: 58px;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--blue));
  opacity: 0;
  animation: opcSpeed 1.1s linear infinite;
}

.opc-speed--2 {
  bottom: 104px;
  width: 40px;
  animation-delay: 0.18s;
  background: linear-gradient(90deg, transparent, var(--orange));
}

.opc-speed--3 {
  bottom: 32px;
  width: 48px;
  animation-delay: 0.36s;
}

.opc-hint {
  position: absolute;
  bottom: 14px;
  right: 20px;
  z-index: 3;
  font-weight: 800;
  font-size: 13px;
  color: var(--blue-deep);
  animation: opcWiggle 1.4s ease-in-out infinite;
}

/* ============ VIÑETAS ============ */
.opc-page--story {
  align-items: flex-start;
}

.opc-num {
  position: absolute;
  top: 18px;
  right: 30px;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 5rem;
  line-height: 1;
  color: var(--blue);
  -webkit-text-stroke: 2.5px var(--ink);
  text-shadow: 3px 3px 0 var(--orange);
}

.opc-scene {
  width: 86px;
  height: 86px;
  margin-bottom: 18px;
  position: relative;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background:
    radial-gradient(var(--dot) 1.3px, transparent 1.4px) 0 0/9px 9px,
    #fff;
  box-shadow: 4px 4px 0 var(--ink);
}

.opc-scene--a {
  background-color: #ffe9d6;
}

.opc-scene--b {
  background-color: #dcebf7;
}

.opc-scene--c {
  background-color: #dff3e3;
}

.opc-emoji {
  font-size: 40px;
  line-height: 1;
  animation: opcBob 3s ease-in-out infinite;
}

.opc-emoji--sm {
  position: absolute;
  right: -10px;
  bottom: -10px;
  font-size: 20px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 50%;
  animation-delay: 0.5s;
}

.opc-h {
  margin: 0 0 12px;
  padding-right: 90px;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-weight: 400;
  letter-spacing: 0.02em;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1;
  color: var(--ink);
}

.opc-p {
  margin: 0;
  max-width: 600px;
  color: #4a4234;
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  font-weight: 600;
  line-height: 1.6;
}

/* contenido aparece cuando la página está activa */
.opc-page--story .opc-scene,
.opc-page--story .opc-h,
.opc-page--story .opc-p,
.opc-page--story .opc-bubble {
  opacity: 0;
  transform: translateY(16px);
}

.opc-page--story.is-active .opc-scene {
  animation: opcRise 0.5s ease forwards 0.15s;
}

.opc-page--story.is-active .opc-h {
  animation: opcRise 0.5s ease forwards 0.28s;
}

.opc-page--story.is-active .opc-p {
  animation: opcRise 0.5s ease forwards 0.4s;
}

.opc-page--story.is-active .opc-bubble {
  animation: opcPop 0.5s cubic-bezier(0.22, 1.6, 0.36, 1) forwards 0.55s;
}

/* bocadillos */
.opc-bubble {
  display: inline-block;
  margin-top: 22px;
  padding: 11px 18px;
  max-width: 340px;
  background: var(--paper-2);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px;
  font-weight: 800;
  font-size: 15px;
  line-height: 1.3;
  box-shadow: 3px 3px 0 var(--ink);
  position: relative;
}

.opc-bubble::after {
  content: "";
  position: absolute;
  bottom: -15px;
  left: 34px;
  border-width: 14px 12px 0 0;
  border-style: solid;
  border-color: var(--ink) transparent transparent transparent;
}

.opc-bubble::before {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 37px;
  z-index: 1;
  border-width: 9px 8px 0 0;
  border-style: solid;
  border-color: var(--paper-2) transparent transparent transparent;
}

.opc-bubble--hero {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-150px) rotate(-3deg);
  margin: 0;
  opacity: 0;
  animation: opcPop 0.5s cubic-bezier(0.22, 1.6, 0.36, 1) 0.55s forwards;
}

.opc-char--peek {
  position: absolute;
  right: 18px;
  bottom: -8px;
  width: 170px;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(4px 5px 0 rgba(22, 19, 15, 0.18));
  animation: opcBob 2.6s ease-in-out infinite;
}

/* ============ CIERRE ============ */
.opc-page--end {
  text-align: center;
  align-items: center;
  background-color: #eaf1f8;
}

.opc-halftone--end {
  background-image: radial-gradient(var(--orange) 22%, transparent 23%);
  opacity: 0.14;
}

.opc-char--end {
  width: 140px;
  height: auto;
  margin: auto auto 6px;
  filter: drop-shadow(5px 6px 0 rgba(22, 19, 15, 0.28));
  animation: opcBob 2.2s ease-in-out infinite;
}

.opc-end-title {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-weight: 400;
  font-size: 2.2rem;
  color: var(--ink);
}

.opc-end-text {
  max-width: 520px;
  margin: 10px auto 0;
  color: #3c4654;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.6;
}

.opc-end-text strong {
  color: var(--blue-deep);
}

.opc-the-end {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 18px;
  background: var(--orange);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.03em;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-2deg);
}

.opc-restart {
  margin: 18px auto 0;
  padding: 11px 22px;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.2s ease;
}

.opc-restart:hover {
  transform: translateY(-3px);
}

/* ============ CONTROLES ============ */
.opc-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
}

.opc-nav {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 24px;
  font-weight: 900;
  color: var(--ink);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 4px 4px 0 var(--ink);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.2s;
}

.opc-nav:hover {
  transform: translateY(-3px);
  box-shadow: 6px 6px 0 var(--ink);
  background: var(--orange);
}

.opc-nav:active {
  transform: translateY(0);
  box-shadow: 2px 2px 0 var(--ink);
}

.opc-nav[disabled] {
  opacity: 0.35;
  pointer-events: none;
}

.opc-counter {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 1.5rem;
  color: var(--paper);
  letter-spacing: 0.06em;
  min-width: 78px;
  text-align: center;
}

.opc-counter b {
  color: var(--orange);
}

.opc-dots {
  display: flex;
  gap: 9px;
}

.opc-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid var(--ink);
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
}

.opc-dots i.on {
  background: var(--orange);
  transform: scale(1.25);
}

/* ============ KEYFRAMES ============ */
@keyframes opcRun {
  0%,
  100% {
    transform: translateX(-50%) translateY(0) rotate(-2deg);
  }

  50% {
    transform: translateX(-50%) translateY(-12px) rotate(2deg);
  }
}

@keyframes opcSpeed {
  0% {
    opacity: 0;
    transform: translateX(20px);
  }

  35% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translateX(-60px);
  }
}

@keyframes opcBob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes opcRise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes opcPop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-3deg);
  }

  to {
    opacity: 1;
  }
}

@keyframes opcWiggle {
  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .origin-predial-modal * {
    animation: none !important;
    transition: opacity 0.2s !important;
  }

  .opc-page--story .opc-scene,
  .opc-page--story .opc-h,
  .opc-page--story .opc-p,
  .opc-page--story .opc-bubble {
    opacity: 1;
    transform: none;
  }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 720px) {
  .origin-predial-modal {
    padding: 12px;
  }

  .opc-book {
    height: min(74vh, 560px);
    perspective: 1400px;
  }

  .opc-page {
    padding: 28px 22px;
    box-shadow: 8px 8px 0 rgba(22, 19, 15, 0.8);
  }

  .opc-num {
    font-size: 3.6rem;
    top: 14px;
    right: 20px;
  }

  .opc-h {
    padding-right: 64px;
  }

  .opc-char--run {
    width: 160px;
  }

  .opc-bubble--hero {
    transform: translateX(-120px) rotate(-3deg);
    font-size: 12.5px;
    max-width: 200px;
  }

  .opc-char--peek {
    width: 118px;
    opacity: 0.55;
  }

  .opc-char--end {
    width: 108px;
  }

  .opc-nav {
    width: 48px;
    height: 48px;
    font-size: 21px;
  }

  .opc-controls {
    gap: 12px;
  }
}
