/* =========================================================================
   ABMSI ADD-ON — FLIPPING JOURNAL LOGO (animation only) + HOPPING PENCIL
   Append-only: paste at the very END of the ABMSI stylesheet.
   No border, no ring, no background and no colour changes: your logo picture
   is shown exactly as it is and only flips like a coin.

   TO SWITCH THE FLIPPING LOGO ON:
     1. Put your logo's web address in --abmsi-logo
     2. Change --abmsi-flip-on from 0 to 1
   The pencil needs no setup.
   ========================================================================= */
@keyframes abmsi-coin {
  0%, 74%  { transform: perspective(900px) rotateY(0deg);   opacity: 1; animation-timing-function: cubic-bezier(.55,0,.9,.6); }
  86%      { transform: perspective(900px) rotateY(88deg);  opacity: 0; }
  86.01%   { transform: perspective(900px) rotateY(-88deg); opacity: 0; animation-timing-function: cubic-bezier(.1,.4,.45,1); }
  100%     { transform: perspective(900px) rotateY(0deg);   opacity: 1; }
}
:root {
  --abmsi-flip-on: 0;                 /* 0 = off, 1 = on */
  --abmsi-logo: none;                 /* e.g. url("https://tufabmsi.com/public/journals/1/logo.png") */
  --abmsi-coin-speed: 4s;
  --abmsi-logo-size: clamp(118px, 9.8vw, 160px);
  --abmsi-logo-left: clamp(10px, 1vw, 20px);
  --abmsi-logo-bottom: 6px;
  --abspp-nav-fs: clamp(10px, calc((100vw - 230px - var(--abmsi-flip-on) * (var(--abmsi-logo-size) + 30px)) / 90), 15.5px);
}
@media (min-width: 992px) {
  html body .pkp_navigation_primary_row {
    padding-left: calc(var(--abmsi-flip-on) * (var(--abmsi-logo-size) + var(--abmsi-logo-left) + 12px) + 1.5vw) !important;
  }
  html body .pkp_structure_head::before {
    content: "";
    position: absolute;
    left: var(--abmsi-logo-left);
    bottom: var(--abmsi-logo-bottom);
    width: var(--abmsi-logo-size);
    height: var(--abmsi-logo-size);
    background: var(--abmsi-logo) center / contain no-repeat;   /* logo only: no border, ring or fill */
    border: 0;
    box-shadow: none;
    opacity: var(--abmsi-flip-on);
    z-index: 40;
    pointer-events: none;
    animation: abmsi-coin var(--abmsi-coin-speed) linear infinite;
  }
}
@media (max-width: 991px) {
  html body .pkp_structure_head::before { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  html body .pkp_structure_head::before { animation: none !important; }
}


/* =========================================================================
   ROTATING / HOPPING UNIVERSITY PENCIL (top-left corner)
   Append-only. The pencil (tower with clock) sits in the top-left corner
   of the banner, turns slowly around its own axis and floats gently. It never takes clicks.
   HOW TO ADJUST (change in :root):
     --isre-pen-h      pencil height
     --isre-pen-spin   seconds for one full animation cycle (bigger = calmer)
     --isre-pen-left / --isre-pen-top   move it from the top-left corner
   ========================================================================= */
:root {
  --isre-pen-h: clamp(96px, 8.4vw, 136px);
  --isre-pen-w: calc(var(--isre-pen-h) * 0.4175);
  --isre-pen-spin: 12s;
  --isre-pen-left: clamp(26px, 2.4vw, 46px);   /* distance from the left edge  */
  --isre-pen-top:  clamp(44px, 3.4vw, 58px);   /* distance from the top edge    */
  --isre-pen-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 124 297'%3E%3Cg stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M58.5 15v15' stroke='%233b1116' stroke-width='2.2' fill='none'/%3E%3Cg stroke='%233b1116' stroke-width='1.8' fill='none'%3E%3Cpath d='M18 50v92M99 50v92M18 65h12M88 65h11M18 92h12M88 92h11M18 119h12M88 119h11'/%3E%3C/g%3E%3Cpath d='M29.5 140V62C29.5 42 42 29.5 58.5 29.5S88 42 88 62v78z' fill='%23c04247' stroke='%234a1016' stroke-width='2'/%3E%3Crect x='29.5' y='66' width='58.5' height='50' fill='%23f6998c'/%3E%3Cpath d='M29.5 66h58.5M29.5 116h58.5' stroke='%234a1016' stroke-width='1.8' fill='none'/%3E%3Ccircle cx='59' cy='91' r='13.5' fill='none' stroke='%23fff4f1' stroke-width='3.4' stroke-dasharray='64 21' transform='rotate(120 59 91)'/%3E%3Cpath d='M52.5 90.5l6 5 7.5-8' fill='none' stroke='%23fff4f1' stroke-width='3'/%3E%3Cpath d='M5.5 146L58.7 128l53.3 18z' fill='%23fff' stroke='%234a1016' stroke-width='2'/%3E%3Crect x='5.5' y='147' width='106.5' height='14' fill='%23bd444c' stroke='%234a1016' stroke-width='2'/%3E%3Cpath d='M20 162h39v52l-39 10z' fill='%23c04247'/%3E%3Cpath d='M59 162h40v62l-40-10z' fill='%23f99b8b'/%3E%3Cpath d='M20 224V161h79v63M59 162v52' fill='none' stroke='%234a1016' stroke-width='2'/%3E%3Cpath d='M20 224l39-10 40 10' fill='none' stroke='%234a1016' stroke-width='2'/%3E%3Cpath d='M20 224l39-10v55l-11.500 0z' fill='%23d8d0e0'/%3E%3Cpath d='M59 214l40 10-29 45H59z' fill='%23fff'/%3E%3Cpath d='M47.500 269L58.700 287 70 269z' fill='%2316090b'/%3E%3Cpath d='M20 224l38.700 63L99 224' fill='none' stroke='%234a1016' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E");
}

/* Motion borrowed from the reference GIF: idle sway pivoting on the tip,
   squash, hop with a full spin, squashed landing, settle, pause. */
@keyframes isre-pen-turn {
  0%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(0deg) scale(1,1); }
  6%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(0deg) scale(1,1); }
  10%{ transform: perspective(700px) translateY(0px) rotate(6deg) rotateY(0deg) scale(1,1.03); }
  15%{ transform: perspective(700px) translateY(0px) rotate(-5deg) rotateY(0deg) scale(1,1.01); }
  20%{ transform: perspective(700px) translateY(0px) rotate(7deg) rotateY(0deg) scale(1,1.03); }
  26%{ transform: perspective(700px) translateY(0px) rotate(-4deg) rotateY(0deg) scale(1,1.01); }
  32%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(0deg) scale(1,1); }
  40%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(0deg) scale(1,1); }
  44%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(0deg) scale(1.08,0.9); }
  50%{ transform: perspective(700px) translateY(-26px) rotate(0deg) rotateY(0deg) scale(0.96,1.06); }
  58%{ transform: perspective(700px) translateY(-30px) rotate(-10deg) rotateY(180deg) scale(1,1); }
  66%{ transform: perspective(700px) translateY(-18px) rotate(8deg) rotateY(330deg) scale(1,1); }
  70%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(360deg) scale(1.1,0.88); }
  74%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(360deg) scale(0.97,1.04); }
  78%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(360deg) scale(1,1); }
  100%{ transform: perspective(700px) translateY(0px) rotate(0deg) rotateY(360deg) scale(1,1); }
}
@keyframes isre-pen-glow {
  0%, 100% { filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
  50%      { filter: drop-shadow(0 4px 6px rgba(0,0,0,.40)); }
}

@media (min-width: 992px) {
  html::after {
    content: "";
    position: absolute;
    display: block;
    top: var(--isre-pen-top);
    left: var(--isre-pen-left);
    width: var(--isre-pen-w);
    height: var(--isre-pen-h);
    background: var(--isre-pen-img) center / contain no-repeat;
    transform-origin: 50% 100%;     /* pivot on the pencil tip */
    z-index: 60;                    /* above the banner and the menu bar */
    pointer-events: none;
    will-change: transform;
    animation: isre-pen-turn var(--isre-pen-spin) ease-in-out infinite,
               isre-pen-glow 3.6s ease-in-out infinite;
  }
}
@media (max-width: 991px) {
  html::after { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  html::after { animation: none !important; }
}
