/* Abertay dashboard motion: load alongside the existing redesign, never instead of it. */
html { --at-motion-css: 1; }
body > #at-motion-layer { display: none; }

/* A compact in-flow toolbar, so controls never cover dashboard links. */
@media screen {
  html[data-at-motion-dashboard='true'] #at-motion-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
  }
  html[data-at-motion-dashboard='true'] #at-motion-controls button {
    box-sizing: border-box;
    min-height: 44px;
    max-width: 100%;
    padding: 9px 14px;
    border: 1px solid #a8d6bd;
    border-radius: 11px;
    background: #f8fffb;
    color: #0a6049;
    box-shadow: 0 4px 16px rgba(17, 75, 51, .13);
    font: 700 .8rem/1.3 system-ui, sans-serif;
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  html[data-at-motion-dashboard='true'] #at-motion-controls button:hover:not(:disabled) { background: #e6f7ed; border-color: #69b78e; }
  html[data-at-motion-dashboard='true'] #at-motion-controls button:focus-visible { outline: 3px solid #15966c; outline-offset: 3px; }
  html[data-at-motion-dashboard='true'] #at-motion-controls button:disabled { background: #f4f7f5; color: #51665c; cursor: default; opacity: 1; }
  @media (max-width: 560px) {
    html[data-at-motion-dashboard='true'] #at-motion-controls { gap: 6px; }
    html[data-at-motion-dashboard='true'] #at-motion-controls button { font-size: .75rem; padding: 8px 10px; }
  }
}

/* Masks exist only during a measured overlay. The original text remains in the
   accessibility tree and is never wrapped, replaced, labelled or rewritten. */
@media screen and (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-mask='true'] {
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    text-shadow: none !important;
  }
  /* The redesign's eyebrow is generated by ::before, not the heading's text. */
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root h1[data-at-motion-mask='true']::before {
    -webkit-text-fill-color: currentColor;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root h1[data-at-motion-eyebrow-mask='true']::before {
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] body > #at-motion-layer {
    position: fixed;
    inset: 0;
    z-index: 3;
    display: block;
    overflow: visible;
    pointer-events: none;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #at-motion-layer * { pointer-events: none; }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #at-motion-layer :is(.at-motion-glyph, .at-motion-fixed-word, .at-motion-count, .at-motion-eyebrow) {
    position: fixed;
    display: inline-block;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    white-space: pre;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #at-motion-layer .at-motion-eyebrow { display: block; white-space: normal; }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #at-motion-layer .at-motion-glyph {
    transform-origin: 50% 100%;
    animation: at-motion-letter 560ms cubic-bezier(.22, .75, .3, 1) var(--at-motion-delay, 80ms) backwards;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #at-motion-layer .at-motion-word {
    display: inline-block;
    animation: at-motion-word var(--at-motion-duration, 650ms) cubic-bezier(.22, 1, .36, 1) var(--at-motion-delay, 0ms) backwards;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-card] {
    animation: at-motion-card 460ms cubic-bezier(.16, 1, .3, 1) var(--at-motion-card-delay, 0ms) backwards;
  }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-card='1'] { --at-motion-card-delay: 35ms; }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-card='2'] { --at-motion-card-delay: 70ms; }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-card='3'] { --at-motion-card-delay: 105ms; }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-card='4'] { --at-motion-card-delay: 140ms; }
  html:not([data-at-effects-paused='true'])[data-at-motion-dashboard='true'] #root [data-at-motion-card='5'] { --at-motion-card-delay: 175ms; }
}
@keyframes at-motion-letter {
  from { opacity: 0; transform: perspective(500px) translateY(.65em) scaleY(.35) rotateX(-65deg); }
  45% { opacity: .82; }
  to { opacity: 1; transform: perspective(500px) translateY(0) scaleY(1) rotateX(0deg); }
}
@keyframes at-motion-word {
  from { opacity: .18; transform: translate3d(0, .58em, 0) rotate(2deg); }
  to { opacity: 1; transform: none; }
}
@keyframes at-motion-card {
  from { opacity: .72; transform: translate3d(0, 9px, 0); }
  to { opacity: 1; transform: none; }
}
@media (forced-colors: active) {
  html[data-at-motion-dashboard='true'] #at-motion-controls button { border: 1px solid ButtonText; color: ButtonText; background: ButtonFace; }
  #at-motion-layer { display: none !important; }
}
@media print {
  #at-motion-layer, #at-motion-controls { display: none !important; }
}
