/* Authored side ink stays intact; idle layers gradually close the centre. */
.shadow-vignette {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
  isolation: isolate;
}

.shadow-vignette::before,
.shadow-vignette::after {
  content: "";
  position: absolute;
  top: -6%;
  bottom: -6%;
  left: -18px;
  width: clamp(120px, 19vw, 300px);
  background: url('/effects/shadow-ink-1a.webp') center / 100% 100% no-repeat;
  opacity: .42;
  animation: shadow-edge-current 31s ease-in-out infinite alternate;
}

.shadow-vignette::after {
  left: auto;
  right: -20px;
  top: -13%;
  bottom: -2%;
  width: clamp(112px, 18vw, 280px);
  scale: -1 1;
  opacity: .36;
  animation-duration: 43s;
  animation-delay: -17s;
  animation-direction: alternate-reverse;
}

/* A slow current preserves the drawn strands without stretching or twitching. */
@keyframes shadow-edge-current {
  from { transform: translate(-3px, 1%); }
  to { transform: translate(2px, -1%); }
}

.shadow-idle-shade,
.shadow-idle-cover {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.shadow-idle-shade {
  inset: -25%;
  background: radial-gradient(ellipse, transparent 24%, #010301dc 59%, #010301 90%);
  transform: scale(1.3);
}

.shadow-idle-cover { inset: 0; background: #010301; }

html[data-shadow-idle] .shadow-idle-shade {
  opacity: .7;
  transform: scale(.92);
  transition: transform 35s ease-in-out, opacity 25s ease-in;
}

html:is([data-shadow-idle="pulse"], [data-shadow-idle="takeover"]) .shadow-idle-shade {
  transform: scale(.72);
  animation: shadow-idle-breath 9s ease-in-out infinite;
}

html[data-shadow-idle="takeover"] .shadow-idle-cover {
  opacity: 1;
  transition: opacity 24s ease-in-out;
}

.shadow-idle-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #d5dfbd;
  opacity: 0;
}

.shadow-idle-mark svg {
  width: clamp(140px, 30vmin, 280px);
  height: auto;
  filter: drop-shadow(0 0 9px #b4cf9066);
}

.shadow-idle-mark path { stroke-dasharray: 1; stroke-dashoffset: 1; }

html[data-shadow-idle="takeover"] .shadow-idle-mark {
  animation: shadow-emblem-arrive 1s ease-in 20s forwards;
}

html[data-shadow-idle="takeover"] .shadow-idle-mark path {
  animation: shadow-emblem-scrawl 14s cubic-bezier(.35, .1, .65, .9) 20s forwards;
}

html[data-shadow-idle="takeover"] .shadow-idle-mark path + path { animation-delay: 28s; animation-duration: 7s; }

html[data-shadow-idle="takeover"] .shadow-idle-mark svg {
  animation: shadow-emblem-breath 7s ease-in-out 35s infinite;
}

@keyframes shadow-idle-breath { 0%, 100% { opacity: .65; } 50% { opacity: .9; } }
@keyframes shadow-emblem-arrive { to { opacity: 1; } }
@keyframes shadow-emblem-scrawl { to { stroke-dashoffset: 0; } }
@keyframes shadow-emblem-breath { 0%, 100% { opacity: .55; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.025); } }

html:not([data-shadow-event="on"]) .shadow-vignette,
html[data-color-mode="contrast"] .shadow-vignette,
html[data-theme="contrast"] .shadow-vignette,
html:has(.app-shell[data-reader-atmosphere="opi-shadow"]) .shadow-vignette,
html:has([data-content-kind="record"]) .shadow-vignette,
html:has([data-world-page="opi"]) .shadow-vignette {
  display: none;
}

html[data-reader-motion="off"] .shadow-vignette::before,
html[data-reader-motion="off"] .shadow-vignette::after {
  animation: none;
}

html[data-reader-motion="off"] :is(.shadow-idle-shade, .shadow-idle-cover, .shadow-idle-mark),
html[data-reduce-motion="true"] :is(.shadow-idle-shade, .shadow-idle-cover, .shadow-idle-mark) { display: none; }

@media (prefers-reduced-motion: reduce) {
  .shadow-vignette::before,
  .shadow-vignette::after { animation: none; }
  .shadow-idle-shade, .shadow-idle-cover, .shadow-idle-mark { display: none; }
}

@media (max-width: 600px) {
  .shadow-vignette::before {
    left: -12px;
    width: clamp(76px, 22vw, 124px);
    opacity: .32;
  }
  .shadow-vignette::after {
    right: -14px;
    width: clamp(72px, 21vw, 118px);
    opacity: .28;
  }
}

/* The retained record keeps its own atmosphere when the timed event ends.
   These layers belong behind the card's copy and share the effects switch. */
:is(.opi-retained-file, [data-retained-observation])::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -15%;
  pointer-events: none;
  background: radial-gradient(ellipse at 0 15%, #0007, transparent 62%), radial-gradient(ellipse at 100% 85%, #0009, transparent 65%);
  animation: retained-shadow-current 31s ease-in-out infinite alternate;
}

:is(.opi-retained-file, [data-retained-observation])::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: url('/images/opi/retained-eye.svg') 95% 28% / 100px no-repeat, url('/images/opi/retained-eye.svg') 82% 90% / 56px no-repeat;
  opacity: .14;
  animation: retained-eye-shift 37s ease-in-out infinite alternate;
}

@keyframes retained-shadow-current {
  to { transform: translate(2%, -1%); }
}

@keyframes retained-eye-shift {
  to { transform: translate(-3px, 2px); }
}

html[data-shadow-effects="off"] :is(.opi-retained-file, [data-retained-observation])::before,
html[data-shadow-effects="off"] :is(.opi-retained-file, [data-retained-observation])::after,
html[data-color-mode="contrast"] :is(.opi-retained-file, [data-retained-observation])::before,
html[data-color-mode="contrast"] :is(.opi-retained-file, [data-retained-observation])::after {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  :is(.opi-retained-file, [data-retained-observation])::before,
  :is(.opi-retained-file, [data-retained-observation])::after { animation: none; }
}

/* The circulation notice shares the Office's worn paper and restrained brass. */
.shadow-effects-toggle {
  min-height: 44px;
  padding: 7px 11px;
  border: 1px solid var(--theme-border-strong, #51554a);
  border-radius: 3px;
  background: var(--theme-surface, #141914);
  color: var(--theme-text, #e5e1cd);
  font: 600 .65rem/1.3 var(--font-mono, monospace);
  white-space: nowrap;
  cursor: pointer;
}

.shadow-effects-toggle:focus-visible {
  outline: 2px solid var(--theme-accent, #ae9d69);
  outline-offset: 3px;
}

.shadow-notice {
  width: min(34rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  margin: auto;
  padding: clamp(24px, 6vw, 48px);
  border: 1px solid #767958;
  border-radius: 2px;
  color: #dddcc5;
  background: radial-gradient(ellipse at 100% 10%, #27312660, transparent 60%), #0c130f;
  box-shadow: 0 24px 100px #000c, inset -40px -35px 70px #000a;
  isolation: isolate;
}

.shadow-notice::backdrop {
  background: #010503a6;
  backdrop-filter: blur(3px);
}

.shadow-notice-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  color: #cfceb4;
  background: transparent;
  font: 1.7rem/1 serif;
  cursor: pointer;
}

.shadow-notice-seal {
  display: block;
  width: 64px;
  height: 64px;
  margin-bottom: 22px;
  background: url('/images/opi/retained-eye.svg') center / contain no-repeat;
  opacity: .6;
}

.shadow-notice-eyebrow {
  margin: 0 0 20px;
  font: 500 .65rem/1.7 monospace;
  letter-spacing: .15em;
  color: #a4aa8b;
}

.shadow-notice h2 {
  font: 400 clamp(1.7rem, 6vw, 2.6rem)/1.12 Georgia, serif;
  margin: 0 0 24px;
  color: #edebd4;
}

.shadow-notice h2 em {
  font-size: .75em;
  font-weight: 400;
}

.shadow-notice > p:not(.shadow-notice-eyebrow) {
  font: 400 1rem/1.6 Georgia, serif;
  color: #c0c4a9;
  margin: 0 0 28px;
}

.shadow-notice-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 15px;
  border: 1px solid #a1a777;
  background: #b6bb8e12;
  color: #e6e8c9;
  text-decoration: none;
  font: .9rem/1.5 monospace;
}

.shadow-notice-dismiss {
  display: block;
  min-height: 44px;
  margin: 10px 0 24px;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: #a9b296;
  font: .75rem/1.5 monospace;
  cursor: pointer;
}

.shadow-notice :is(a, button):focus-visible {
  outline: 2px solid #d8dea1;
  outline-offset: 4px;
}

.shadow-notice footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  border-top: 1px solid #727d4d5c;
  padding-top: 18px;
  font: .65rem/1.7 monospace;
  color: #929c80;
}

.shadow-notice output {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #d0d6b0;
}

html[data-color-mode="contrast"] .shadow-notice {
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: none;
}

html[data-color-mode="contrast"] .shadow-notice :is(p, h2, a, button, footer, output) {
  color: #fff;
  border-color: #fff;
}

@media (forced-colors: active) {
  .shadow-vignette,
  .shadow-notice-seal,
  :is(.opi-retained-file, [data-retained-observation])::before,
  :is(.opi-retained-file, [data-retained-observation])::after { display: none; }
  .shadow-notice { background: Canvas; color: CanvasText; box-shadow: none; }
  .shadow-notice::backdrop { backdrop-filter: none; }
}
