/* The same two faces stay in the button's layout through both rotations. */
button .niva-copy-icon {
  display: inline-block;
  position: relative;
  width: 1em;
  height: 1em;
  min-width: 1em;
  flex: none;
  vertical-align: -.125em;
  font-size: 16px;
  line-height: 1;
  transform-style: preserve-3d;
  transform: perspective(110px) rotateY(0deg);
  transition: transform 180ms ease-in-out;
}
button[data-niva-copied] .niva-copy-icon {
  transform: perspective(110px) rotateY(180deg);
}
button .niva-copy-icon::before, button .niva-copy-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  -webkit-mask: var(--niva-icon) center / contain no-repeat;
  mask: var(--niva-icon) center / contain no-repeat;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.niva-copy-icon::before {
  --niva-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Crect x='8' y='8' width='13' height='13' rx='2'/%3E%3Cpath d='M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3'/%3E%3C/svg%3E");
}
.niva-copy-icon::after {
  --niva-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 12 5 5L20 6'/%3E%3C/svg%3E");
  transform: rotateY(180deg);
}
button.embed-copy-btn:has(.niva-copy-icon),
button.v2-btn:has(.niva-copy-icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35em;
}
.niva-copy-tip {
  position: fixed;
  z-index: 2147483646;
  pointer-events: none;
  white-space: nowrap;
  border-radius: 6px;
  padding: 4px 8px;
  background: #232831;
  color: #fff;
  box-shadow: 0 2px 8px #0002;
  font: 500 12px/1.4 system-ui, sans-serif;
  opacity: 0;
  transform: translate(-50%, 3px);
  transition: opacity 180ms ease, transform 180ms ease;
}
:root.dark .niva-copy-tip { background: #e8edf3; color: #1b2027; }
.niva-copy-tip[data-visible] { opacity: 1; transform: translate(-50%, 0); }

.theme-btn, .app-header .icon-btn, .niva-theme-option {
  -webkit-tap-highlight-color: transparent;
}
:root > .niva-theme-anchor {
  all: initial;
  position: fixed;
  width: 1px;
  height: 1px;
  pointer-events: none;
  view-transition-name: niva-theme-anchor;
}
:root [data-niva-capture-header] {
  position: relative !important;
  top: var(--niva-capture-top, 0px) !important;
}
:root[data-niva-reveal] {
  --niva-reveal-center: 50% 50%;
  --niva-reveal-radius: 200vmax;
}
:root[data-niva-reveal]::view-transition-group(niva-theme-anchor) {
  animation: none;
  visibility: hidden;
}
:root[data-niva-reveal], :root[data-niva-reveal] *,
:root[data-niva-reveal] *::before, :root[data-niva-reveal] *::after {
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}
@property --niva-light-hole {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
:root[data-niva-reveal]::view-transition {
  pointer-events: none;
  background-color: var(--niva-reveal-base);
}
:root[data-niva-reveal]::view-transition-group(root),
:root[data-niva-reveal]::view-transition-image-pair(root) { animation: none; }
:root[data-niva-reveal]::view-transition-image-pair(root) { isolation: isolate; }
:root[data-niva-reveal]::view-transition-old(root),
:root[data-niva-reveal]::view-transition-new(root) {
  height: calc(100% + var(--niva-capture-extra, 0px));
  opacity: 1;
  transform: translateZ(0);
  mix-blend-mode: normal;
  animation: none;
}
/* Keep the outgoing image intact until the incoming image covers it. */
:root[data-niva-reveal]::view-transition-old(root) {
  z-index: 0;
  background-color: var(--niva-reveal-base);
}
:root[data-niva-reveal]::view-transition-new(root) {
  z-index: 1;
  background-color: var(--bg-deep);
}
:root[data-niva-reveal="dark"]::view-transition-new(root) {
  clip-path: circle(0px at var(--niva-reveal-center));
  animation: niva-theme-dark 500ms cubic-bezier(.45, 0, .55, 1) both paused;
}
:root[data-niva-reveal="light"]::view-transition-new(root) {
  --niva-light-hole: var(--niva-reveal-radius);
  --niva-light-mask: radial-gradient(circle at var(--niva-reveal-center),
    transparent var(--niva-light-hole), black calc(var(--niva-light-hole) + 0.75px));
  -webkit-mask-image: var(--niva-light-mask);
  mask-image: var(--niva-light-mask);
  animation: niva-theme-light 500ms cubic-bezier(.45, 0, .55, 1) both paused;
}
:root[data-niva-reveal][data-niva-reveal-running]::view-transition-new(root) {
  animation-play-state: running;
}
@keyframes niva-theme-dark {
  from { clip-path: circle(0px at var(--niva-reveal-center)); }
  to { clip-path: circle(var(--niva-reveal-radius) at var(--niva-reveal-center)); }
}
@keyframes niva-theme-light {
  from { --niva-light-hole: var(--niva-reveal-radius); }
  to { --niva-light-hole: -1px; }
}
@media (prefers-reduced-motion: reduce) {
  button .niva-copy-icon, .niva-copy-tip { transition: none; }
}
button.niva-theme-option {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  line-height: inherit;
}
