/* ===== ytapis UI layer: animations, back navigation, mascots ===== */

@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50%      { transform: translateY(-14px) rotate(1.4deg); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-8deg); }
  75%      { transform: rotate(8deg); }
}
@keyframes sparkle {
  0%, 100% { opacity: .35; transform: scale(.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* Page enter + leave */
main { animation: pageIn .55s cubic-bezier(.2, .7, .2, 1) both; }
body.is-leaving main {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .22s ease, transform .22s ease;
}

/* Scroll progress bar */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 90;
  background: linear-gradient(90deg, #ff1a4d, #22d3ee, #a78bfa);
  box-shadow: 0 0 12px rgba(34, 211, 238, .55);
  pointer-events: none;
}

/* Back bar + breadcrumbs */
.back-bar { padding-top: 98px; position: relative; z-index: 2; }
.back-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .04);
  color: #f4f4f7; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.back-btn span { display: inline-block; transition: transform .25s ease; }
.back-btn:hover {
  background: rgba(255, 26, 77, .12); border-color: rgba(255, 26, 77, .45);
  transform: translateX(-3px); box-shadow: 0 8px 24px rgba(255, 26, 77, .15);
}
.back-btn:hover span { transform: translateX(-3px); }
.back-btn:active { transform: scale(.96); }
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: #6b7280; }
.crumbs a { color: #9ca3af; transition: color .2s ease; }
.crumbs a:hover { color: #fff; }
.crumbs [aria-current] { color: #fff; font-weight: 600; }
.back-bar + section.page-hero { padding-top: 28px; }

/* Hero mascots (cute anime characters) */
.page-hero > .container { position: relative; z-index: 2; }
.hero-mascot {
  position: absolute; right: clamp(0px, 4vw, 70px); bottom: -8px;
  width: clamp(150px, 19vw, 250px); height: auto; z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 60%, transparent 100%);
  filter: drop-shadow(0 18px 40px rgba(255, 26, 77, .25));
  animation: floaty 5.5s ease-in-out infinite;
  translate: var(--px, 0px) var(--py, 0px);
  transition: translate .4s ease-out;
}
.hero-mascot:hover { animation: wiggle .6s ease; }
/* Keep hero copy clear of the mascot on wide screens */
@media (min-width: 861px) {
  .page-hero .lead { max-width: 62ch; }
}
@media (max-width: 860px) {
  .hero-mascot { width: 120px; right: 0; bottom: -4px; top: auto; opacity: .7; }
}
/* Phones: the title and copy take the full width, so the mascot is hidden */
@media (max-width: 560px) {
  .hero-mascot { display: none; }
}

/* Cards and buttons */
.card { transition: transform .35s cubic-bezier(.2, .7, .2, 1), background .3s ease, border-color .3s ease, box-shadow .35s ease; }
.card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px -18px rgba(255, 26, 77, .35); }
.card img { transition: transform .6s ease; }
.card:hover img { transform: scale(1.03); }
.btn:active { transform: scale(.97); }

/* Keyboard focus that is visible on the dark theme */
:focus-visible { outline: 2px solid #22d3ee; outline-offset: 3px; border-radius: 6px; }

/* Back to top */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .12); color: #fff;
  background: rgba(10, 12, 20, .85); backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none;
  transition: opacity .3s ease, transform .3s ease, box-shadow .3s ease;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { box-shadow: 0 0 0 4px rgba(255, 26, 77, .2), 0 10px 30px rgba(0, 0, 0, .4); animation: wiggle .5s ease; }

/* Respect users who ask for less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* SEO/layout fix: keep wide code blocks inside their cards on every screen size */
.card.ep, .ep-grid > * { min-width: 0; }
.codebox-pre { max-width: 100%; overflow-x: auto; }
@media (min-width: 861px) {
  .ep-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Small-screen fixes: long words wrap, tables scroll inside their card */
.card { min-width: 0; }
.mono { overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; overflow-x: auto; }
@media (max-width: 860px) { .row { flex-wrap: wrap; } }
