/*
 * PDF reader layout.
 *
 * Kept in a dedicated, late-loaded file so cache layers and legacy PDF
 * plugins cannot leave the native MC Promo reader without its interface.
 */

.mcp-document-section .mcp-document-card {
  display: grid;
  grid-template-columns: minmax(250px, .32fr) minmax(0, .68fr);
  gap: clamp(20px, 3vw, 36px);
  align-items: stretch;
  overflow: hidden;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid color-mix(in oklch, var(--accent) 42%, var(--border));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 96% 4%, color-mix(in oklch, var(--accent) 18%, transparent), transparent 38%),
    linear-gradient(140deg, color-mix(in oklch, var(--surface) 94%, var(--accent) 3%), var(--surface));
  box-shadow: 0 34px 90px rgb(0 0 0 / 18%);
}

.mcp-document-section .mcp-document-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: clamp(12px, 2vw, 24px);
}

.mcp-document-section .mcp-document-card h2 {
  max-width: 520px;
}

.mcp-document-section .mcp-document-card .lead {
  max-width: 460px;
  margin-top: 16px;
}

.mcp-document-section .mcp-document-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
  margin-top: clamp(24px, 4vw, 40px);
}

.mcp-document-section .mcp-document-actions .btn {
  width: 100%;
  min-width: 0;
}

.mcp-document-section .mcp-pdf-viewer {
  position: relative;
  overflow: hidden;
  min-width: 0;
  height: min(82vh, 920px);
  min-height: 720px;
  border: 1px solid color-mix(in oklch, var(--accent) 28%, var(--border));
  border-radius: calc(var(--radius-lg) - 8px);
  background:
    radial-gradient(circle at 50% 34%, rgb(255 255 255 / 9%), transparent 40%),
    linear-gradient(155deg, #24272d, #101216 72%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 8%),
    0 28px 70px rgb(0 0 0 / 30%);
}

.mcp-document-section .mcp-pdf-reader,
.mcp-document-section .mcp-pdf-book {
  width: 100%;
  height: 100%;
}

.mcp-document-section .mcp-pdf-reader {
  position: relative;
  isolation: isolate;
}

.mcp-document-section .mcp-pdf-reader [hidden] {
  display: none !important;
}

.mcp-document-section .mcp-pdf-loading {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  color: #f6f2e8;
  text-align: center;
  background:
    radial-gradient(circle at 50% 38%, rgb(222 171 58 / 16%), transparent 33%),
    linear-gradient(155deg, #24272d, #101216 72%);
}

.mcp-document-section .mcp-pdf-spinner {
  width: 42px;
  height: 42px;
  border: 2px solid rgb(255 255 255 / 18%);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: mcpPdfSpin 820ms linear infinite;
}

.mcp-document-section .mcp-pdf-book {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.mcp-document-section .mcp-pdf-stage {
  position: relative;
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  place-items: center;
  overflow: hidden;
  padding: 34px 64px 22px;
  outline: none;
  perspective: 2200px;
  touch-action: pan-y;
}

.mcp-document-section .mcp-pdf-stage:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in oklch, var(--accent) 72%, transparent);
}

.mcp-document-section .mcp-pdf-paper {
  position: relative;
  width: 0;
  height: 0;
  max-width: 100%;
  max-height: 100%;
  transform-style: preserve-3d;
  filter: drop-shadow(0 28px 34px rgb(0 0 0 / 42%));
  transition:
    width 300ms var(--ease),
    height 300ms var(--ease);
}

.mcp-document-section .mcp-pdf-paper::after {
  position: absolute;
  z-index: 4;
  inset: 0;
  border: 1px solid rgb(255 255 255 / 18%);
  content: "";
  pointer-events: none;
  box-shadow:
    inset -1px 0 0 rgb(0 0 0 / 7%),
    inset 0 -1px 0 rgb(0 0 0 / 7%);
}

.mcp-document-section .mcp-pdf-page {
  position: absolute;
  inset: 0;
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.mcp-document-section .mcp-pdf-page-current {
  z-index: 2;
}

.mcp-document-section .mcp-pdf-page-incoming {
  z-index: 1;
  opacity: 0;
  transition: opacity 140ms ease;
}

.mcp-document-section .mcp-pdf-page-incoming.is-ready {
  opacity: 1;
}

.mcp-document-section .mcp-pdf-page-sheen {
  position: absolute;
  z-index: 3;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 38%, rgb(255 255 255 / 44%) 63%, rgb(0 0 0 / 22%));
  mix-blend-mode: soft-light;
}

.mcp-document-section .mcp-pdf-reader.is-turning-forward .mcp-pdf-page-current {
  transform-origin: 0 50%;
  animation: mcpPdfTurnForward 620ms cubic-bezier(.22, .74, .22, 1) both;
}

.mcp-document-section .mcp-pdf-reader.is-turning-backward .mcp-pdf-page-current {
  transform-origin: 100% 50%;
  animation: mcpPdfTurnBackward 620ms cubic-bezier(.22, .74, .22, 1) both;
}

.mcp-document-section .mcp-pdf-reader.is-turning-forward .mcp-pdf-page-sheen {
  animation: mcpPdfSheenForward 620ms ease both;
}

.mcp-document-section .mcp-pdf-reader.is-turning-backward .mcp-pdf-page-sheen {
  animation: mcpPdfSheenBackward 620ms ease both;
}

.mcp-document-section .mcp-pdf-edge {
  position: absolute;
  z-index: 6;
  top: 50%;
  display: grid;
  width: 48px;
  height: 64px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 16px;
  color: #fff;
  background: rgb(10 12 15 / 66%);
  box-shadow: 0 12px 30px rgb(0 0 0 / 24%);
  cursor: pointer;
  transform: translateY(-50%);
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease,
    opacity 180ms ease;
  backdrop-filter: blur(12px);
}

.mcp-document-section .mcp-pdf-edge span {
  font-size: 2rem;
  line-height: 1;
}

.mcp-document-section .mcp-pdf-edge:hover:not(:disabled) {
  border-color: color-mix(in oklch, var(--accent) 72%, transparent);
  background: color-mix(in oklch, var(--accent) 30%, #111318);
  transform: translateY(-50%) scale(1.04);
}

.mcp-document-section .mcp-pdf-edge:focus-visible,
.mcp-document-section .mcp-pdf-control:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

.mcp-document-section .mcp-pdf-edge:disabled,
.mcp-document-section .mcp-pdf-control:disabled {
  opacity: .28;
  cursor: default;
}

.mcp-document-section .mcp-pdf-edge-prev {
  left: 14px;
}

.mcp-document-section .mcp-pdf-edge-next {
  right: 14px;
}

.mcp-document-section .mcp-pdf-toolbar {
  position: relative;
  z-index: 6;
  display: flex;
  min-height: 70px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid rgb(255 255 255 / 10%);
  color: #fff;
  background: rgb(10 12 15 / 74%);
  backdrop-filter: blur(16px);
}

.mcp-document-section .mcp-pdf-control {
  display: inline-flex;
  min-width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 12px;
  color: inherit;
  background: rgb(255 255 255 / 5%);
  cursor: pointer;
  transition:
    color 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.mcp-document-section .mcp-pdf-control:hover:not(:disabled) {
  border-color: color-mix(in oklch, var(--accent) 65%, transparent);
  color: var(--accent);
  background: rgb(255 255 255 / 9%);
  transform: translateY(-1px);
}

.mcp-document-section .mcp-pdf-counter {
  display: flex;
  min-width: 126px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  color: rgb(255 255 255 / 70%);
  font-size: .84rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.mcp-document-section .mcp-pdf-counter strong {
  color: #fff;
  font-size: .98rem;
}

.mcp-document-section .mcp-pdf-fullscreen {
  position: absolute;
  right: 18px;
}

.mcp-document-section .mcp-pdf-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 720px;
  border: 0;
  background: #17191d;
}

.mcp-document-section .mcp-pdf-reader:fullscreen {
  padding: 18px;
  background: #0d0f12;
}

.mcp-document-section .mcp-pdf-reader:fullscreen .mcp-pdf-book {
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 18px;
}

.mcp-document-section .mcp-pdf-reader.is-loading-page .mcp-pdf-toolbar::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 36%;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
  animation: mcpPdfProgress 900ms ease-in-out infinite alternate;
}

.mcp-document-section .mcp-pdf-help {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: .88rem;
}

@keyframes mcpPdfSpin {
  to { transform: rotate(360deg); }
}

@keyframes mcpPdfProgress {
  from { transform: translateX(-20%); }
  to { transform: translateX(240%); }
}

@keyframes mcpPdfTurnForward {
  0% {
    opacity: 1;
    transform: translateZ(0) rotateY(0deg);
    filter: brightness(1);
  }

  48% {
    opacity: .86;
    transform: translateX(-1.5%) translateZ(18px) rotateY(-46deg) scale(.985);
    filter: brightness(.86);
  }

  100% {
    opacity: 0;
    transform: translateX(-4%) translateZ(0) rotateY(-102deg) scale(.97);
    filter: brightness(.68);
  }
}

@keyframes mcpPdfTurnBackward {
  0% {
    opacity: 1;
    transform: translateZ(0) rotateY(0deg);
    filter: brightness(1);
  }

  48% {
    opacity: .86;
    transform: translateX(1.5%) translateZ(18px) rotateY(46deg) scale(.985);
    filter: brightness(.86);
  }

  100% {
    opacity: 0;
    transform: translateX(4%) translateZ(0) rotateY(102deg) scale(.97);
    filter: brightness(.68);
  }
}

@keyframes mcpPdfSheenForward {
  0%,
  100% {
    opacity: 0;
    transform: translateX(-34%);
  }

  45% {
    opacity: .78;
    transform: translateX(9%);
  }
}

@keyframes mcpPdfSheenBackward {
  0%,
  100% {
    opacity: 0;
    transform: translateX(34%) scaleX(-1);
  }

  45% {
    opacity: .78;
    transform: translateX(-9%) scaleX(-1);
  }
}

@media (max-width: 1080px) {
  .mcp-document-section .mcp-document-card {
    grid-template-columns: minmax(230px, .36fr) minmax(0, .64fr);
  }
}

@media (max-width: 920px) {
  .mcp-document-section .mcp-document-card {
    grid-template-columns: 1fr;
  }

  .mcp-document-section .mcp-document-content {
    padding: 16px 12px 6px;
  }

  .mcp-document-section .mcp-document-actions {
    max-width: 560px;
    flex-direction: row;
  }

  .mcp-document-section .mcp-document-actions .btn {
    width: auto;
    min-width: 190px;
  }

  .mcp-document-section .mcp-pdf-viewer {
    height: min(78vh, 820px);
    min-height: 640px;
  }

  .mcp-document-section .mcp-pdf-frame {
    min-height: 640px;
  }
}

@media (max-width: 640px) {
  .mcp-document-section .mcp-document-actions {
    flex-direction: column;
  }

  .mcp-document-section .mcp-document-actions .btn {
    width: 100%;
  }

  .mcp-document-section .mcp-pdf-viewer {
    height: 72vh;
    min-height: 520px;
  }

  .mcp-document-section .mcp-pdf-frame {
    min-height: 520px;
  }

  .mcp-document-section .mcp-pdf-stage {
    padding: 24px 46px 16px;
  }

  .mcp-document-section .mcp-pdf-edge {
    width: 38px;
    height: 54px;
    border-radius: 12px;
  }

  .mcp-document-section .mcp-pdf-edge-prev {
    left: 6px;
  }

  .mcp-document-section .mcp-pdf-edge-next {
    right: 6px;
  }

  .mcp-document-section .mcp-pdf-fullscreen {
    position: static;
  }

  .mcp-document-section .mcp-pdf-fullscreen span:last-child {
    display: none;
  }
}

@media (max-width: 430px) {
  .mcp-document-section .mcp-document-card {
    padding: 12px;
  }

  .mcp-document-section .mcp-pdf-viewer {
    min-height: 480px;
    border-radius: 14px;
  }

  .mcp-document-section .mcp-pdf-frame {
    min-height: 480px;
  }

  .mcp-document-section .mcp-pdf-toolbar {
    min-height: 62px;
    gap: 6px;
    padding-inline: 8px;
  }

  .mcp-document-section .mcp-pdf-control {
    min-width: 40px;
    height: 40px;
    padding-inline: 11px;
  }

  .mcp-document-section .mcp-pdf-counter {
    min-width: 104px;
    font-size: .74rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mcp-document-section .mcp-pdf-spinner,
  .mcp-document-section .mcp-pdf-reader.is-loading-page .mcp-pdf-toolbar::before {
    animation-duration: 1.8s;
  }

  .mcp-document-section .mcp-pdf-reader.is-turning-forward .mcp-pdf-page-current,
  .mcp-document-section .mcp-pdf-reader.is-turning-backward .mcp-pdf-page-current,
  .mcp-document-section .mcp-pdf-reader.is-turning-forward .mcp-pdf-page-sheen,
  .mcp-document-section .mcp-pdf-reader.is-turning-backward .mcp-pdf-page-sheen {
    animation: none;
  }
}
