/* The logo and the Dynamic Island share one spot: the centre of the header.
   Idle: the AlterWords logo, with the ghost moving inside the "o" and the horned A blinking now and then.
   Something to show (a new post, a message, a notice): the logo fades and shrinks away, and the island grows
   out of the same spot, shows it, then closes and the logo comes back (the ghost peeks back in).
   Colours follow the theme: a black island in light mode, a white one in dark mode. */

.aw-slot {
  position: relative;
  height: 44px;
  width: min(360px, calc(100vw - 140px));
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
}

.aw-logo-layer {
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--x-text-primary, #0b0b0b);
  pointer-events: auto;
  transition: opacity 0.26s ease, transform 0.36s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.26s ease;
}

.aw-logo-layer .aw-logo {
  height: 20px;
  width: auto;
  display: block;
}

.aw-slot.open .aw-logo-layer {
  opacity: 0;
  transform: scale(0.72) translateY(-2px);
  filter: blur(5px);
  pointer-events: none;
}

.aw-island {
  --isl-bg: #0b0b0b;
  --isl-fg: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  height: 28px;
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--isl-bg);
  color: var(--isl-fg);
  overflow: hidden;
  pointer-events: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  transition:
    width 0.55s cubic-bezier(0.32, 1.42, 0.5, 1),
    height 0.55s cubic-bezier(0.32, 1.42, 0.5, 1),
    border-radius 0.45s ease,
    opacity 0.22s ease,
    transform 0.5s cubic-bezier(0.32, 1.42, 0.5, 1);
}

body.dark-mode .aw-island {
  --isl-bg: #f4f4f2;
  --isl-fg: #0b0b0b;
}

.aw-slot.open .aw-island {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.aw-island.big {
  border-radius: 24px;
}

.aw-isl-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 8px;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  filter: blur(3px);
  transition: opacity 0.22s ease, transform 0.3s ease, filter 0.22s ease;
  white-space: nowrap;
}

.aw-island.show .aw-isl-content {
  opacity: 1;
  transform: none;
  filter: none;
  transition-delay: 0.16s;
}

.aw-island.big .aw-isl-content {
  align-items: flex-start;
  padding: 12px 14px;
  white-space: normal;
}

.aw-isl-av {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--isl-fg);
  color: var(--isl-bg);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  overflow: hidden;
}

.aw-isl-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.aw-isl-txt {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.aw-isl-txt b {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-isl-txt span {
  font-size: 12px;
  opacity: 0.72;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-island.big .aw-isl-txt span {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.aw-isl-kind {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.6;
  align-self: center;
}

/* ---------- logo motion ---------- */
.aw-logo .wm-eyes {
  transform-box: fill-box;
  animation: aw-fly 9s cubic-bezier(0.45, 0.05, 0.35, 1) infinite;
}

.aw-logo .blink {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: aw-blink 4.6s infinite;
}

.aw-logo .wm-a-lids .blink {
  transform-origin: 50% 0;
  transform: scaleY(0);
  animation: aw-lid 5.8s 1.2s infinite;
}

.aw-logo .wm-a-wrap {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: aw-twitch 7s 2s infinite;
}

.aw-logo .wm-o-wrap {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: aw-bob 9s cubic-bezier(0.45, 0.05, 0.35, 1) infinite;
}

.aw-slot.return .aw-logo .wm-eyes {
  animation: aw-peek 0.7s cubic-bezier(0.3, 1.5, 0.5, 1);
}

@keyframes aw-fly {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  12%, 24% { transform: translate(-12px, -34px) rotate(-6deg); }
  38% { transform: translate(13px, 30px) rotate(5deg); }
  50% { transform: translate(11px, 92px) rotate(3deg); }
  62% { transform: translate(-11px, 64px) rotate(-4deg); }
  76% { transform: translate(2px, 8px) rotate(0); }
}

@keyframes aw-blink {
  0%, 44%, 48%, 90%, 94%, 100% { transform: scaleY(1); }
  46%, 92% { transform: scaleY(0.08); }
}

@keyframes aw-lid {
  0%, 40%, 50%, 100% { transform: scaleY(0); }
  44%, 46% { transform: scaleY(1); }
}

@keyframes aw-twitch {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-3deg); }
  88% { transform: rotate(2.2deg); }
  92% { transform: rotate(-1deg); }
}

@keyframes aw-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  48% { transform: translateY(0) scale(1.015, 0.985); }
  52% { transform: translateY(-6px) scale(0.99, 1.01); }
}

@keyframes aw-peek {
  0% { transform: translate(0, 110px); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .aw-logo .wm-eyes,
  .aw-logo .blink,
  .aw-logo .wm-a-wrap,
  .aw-logo .wm-o-wrap,
  .aw-slot.return .aw-logo .wm-eyes {
    animation: none !important;
  }

  .aw-island,
  .aw-logo-layer,
  .aw-isl-content {
    transition: opacity 0.2s linear !important;
    filter: none !important;
  }

  .aw-logo-layer,
  .aw-isl-content {
    transform: none !important;
  }
}

/* The footer and sidebar wordmark: still, one colour. */
.aw-wordmark-static {
  display: inline-block;
  color: currentColor;
  line-height: 0;
}

.aw-wordmark-static svg {
  height: 16px;
  width: auto;
}

.aw-wordmark-static .wm-eyes,
.aw-wordmark-static .blink,
.aw-wordmark-static .wm-a-wrap,
.aw-wordmark-static .wm-o-wrap {
  animation: none;
}
