/* =========================================================================
   Hero Atmospheric Track Invite + Apple Dynamic Island Morphing Player
   ========================================================================= */

/* 1. Hero Invite Pill (positioned right below "beauty and brains") */
.hero-music-invite {
  position: absolute;
  left: 50%;
  top: clamp(64%, 68vh, 72%);
  transform: translate3d(-50%, 0, 0);
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
  border-radius: 999px;
  background: rgba(8, 8, 12, 0.74);
  border: 1px solid rgba(235, 193, 194, 0.34);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.68),
    0 0 32px rgba(235, 193, 194, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #faf5f6;
  max-width: min(calc(100vw - 28px), 430px);
  transition:
    opacity 0.34s cubic-bezier(0.32, 0.72, 0, 1),
    transform 0.44s cubic-bezier(0.32, 0.72, 0, 1),
    border-color 0.22s ease,
    box-shadow 0.28s ease;
}
.hero-music-invite:hover {
  border-color: rgba(255, 226, 227, 0.62);
  box-shadow:
    0 22px 54px rgba(0, 0, 0, 0.76),
    0 0 42px rgba(235, 193, 194, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translate3d(-50%, -2px, 0);
}
.hero-music-invite.is-docked {
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, -28px, 0) scale(0.84);
}
.hero-music-invite.is-hidden {
  display: none !important;
}

.hero-music-invite__disc {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 50% 50%, #ffe2e3 0 4px, #121018 4.5px 7px, #1f1926 7.5px 100%);
  border: 1px solid rgba(255, 226, 227, 0.35);
  box-shadow: 0 0 18px rgba(235, 193, 194, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-music-invite__disc::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 226, 227, 0.24);
  animation: hm-spin 9s linear infinite;
}
.hero.is-offscreen .hero-music-invite__disc::after {
  animation-play-state: paused;
}

.hero-music-invite__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-right: 4px;
}
.hero-music-invite__prompt {
  font-family: "Caveat", cursive;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.05;
  color: #ffe2e3;
  text-shadow: 0 0 14px rgba(235, 193, 194, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-music-invite__track {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(250, 245, 246, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-music-invite__play {
  appearance: none;
  border: 1px solid rgba(255, 226, 227, 0.65);
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  line-height: 0;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(145deg, #ffe2e3, #e6b2b5);
  color: #07060a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(235, 193, 194, 0.45);
  transition: transform 0.22s cubic-bezier(0.22, 1.25, 0.36, 1), box-shadow 0.22s ease;
}
.hero-music-invite__play svg {
  width: 18px;
  height: 18px;
  display: block;
}
.hero-music-invite__play:hover {
  transform: scale(1.08);
  box-shadow: 0 0 30px rgba(255, 226, 227, 0.72);
}
.hero-music-invite__play:active {
  transform: scale(0.95);
}

/* 2. Apple Dynamic Island Docked Black Pill */
.apple-island-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 165;
  pointer-events: none;
  transition: top 0.3s ease;
}
body.is-admin-builder .apple-island-wrap {
  top: 62px;
}
body.is-reader-open .apple-island-wrap {
  top: 14px;
}

.apple-island {
  pointer-events: auto;
  position: relative;
  box-sizing: border-box;
  width: 204px;
  height: 38px;
  border-radius: 999px;
  background: #050507;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.82),
    0 0 0 0.5px rgba(255, 255, 255, 0.08) inset,
    0 0 26px rgba(235, 193, 194, 0.12);
  color: #f7f2f4;
  overflow: hidden;
  opacity: 0;
  transform: translate3d(0, -18px, 0) scale(0.7);
  visibility: hidden;
  will-change: transform, width, height, border-radius, opacity;
  transition:
    width 0.46s cubic-bezier(0.22, 1.16, 0.36, 1),
    height 0.46s cubic-bezier(0.22, 1.16, 0.36, 1),
    border-radius 0.46s cubic-bezier(0.22, 1.16, 0.36, 1),
    box-shadow 0.36s ease,
    border-color 0.28s ease,
    opacity 0.32s ease,
    transform 0.52s cubic-bezier(0.22, 1.16, 0.36, 1);
}

.apple-island.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0) scale(1);
}

/* Expanded Dynamic Island — tap-toggled (.is-expanded) on ALL devices; hover ONLY on fine pointer desktop! */
.apple-island.is-visible.is-expanded {
  width: min(calc(100vw - 24px), 376px);
  height: 162px;
  border-radius: 28px;
  border-color: rgba(235, 193, 194, 0.32);
  box-shadow:
    0 24px 66px rgba(0, 0, 0, 0.92),
    0 0 38px rgba(235, 193, 194, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Compact Pill Bar (Visible when collapsed) */
.apple-island__compact {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 0 10px;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.2s ease, transform 0.26s ease;
}
.apple-island.is-expanded .apple-island__compact {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.apple-island__mini-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.apple-island__dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 35% 35%, #ffe2e3, #c45c72 60%, #1a1118 100%);
  box-shadow: 0 0 10px rgba(235, 193, 194, 0.55);
  animation: hm-spin 5s linear infinite;
}
.apple-island:not(.is-playing) .apple-island__dot {
  animation-play-state: paused;
  opacity: 0.6;
}

.apple-island__mini-title {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Live 4-bar Apple Waveform Equalizer */
.apple-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 14px;
  flex-shrink: 0;
}
.apple-eq i {
  display: block;
  width: 2.5px;
  height: 4px;
  border-radius: 99px;
  background: #ffe2e3;
  box-shadow: 0 0 6px rgba(235, 193, 194, 0.6);
  transition: height 0.2s ease;
}
.apple-island.is-playing .apple-eq i:nth-child(1) { animation: eq-bar 0.72s ease-in-out infinite alternate; }
.apple-island.is-playing .apple-eq i:nth-child(2) { animation: eq-bar 0.54s ease-in-out 0.14s infinite alternate; }
.apple-island.is-playing .apple-eq i:nth-child(3) { animation: eq-bar 0.82s ease-in-out 0.28s infinite alternate; }
.apple-island.is-playing .apple-eq i:nth-child(4) { animation: eq-bar 0.62s ease-in-out 0.08s infinite alternate; }

@keyframes eq-bar {
  0%   { height: 3px; opacity: 0.65; }
  100% { height: 14px; opacity: 1; }
}
@keyframes hm-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Expanded Controls Layer */
.apple-island__full {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: opacity 0.22s ease 0.08s, transform 0.34s cubic-bezier(0.22, 1.15, 0.36, 1) 0.04s;
}
.apple-island.is-expanded .apple-island__full {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* Desktop mouse hover expansion ONLY on devices with true hover (prevents touch flicker on mobile!) */
@media (hover: hover) and (pointer: fine) {
  .apple-island.is-visible:hover {
    width: min(calc(100vw - 24px), 376px);
    height: 162px;
    border-radius: 28px;
    border-color: rgba(235, 193, 194, 0.32);
    box-shadow:
      0 24px 66px rgba(0, 0, 0, 0.92),
      0 0 38px rgba(235, 193, 194, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
  .apple-island.is-visible:hover .apple-island__compact {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
  }
  .apple-island.is-visible:hover .apple-island__full {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
  }
}

.apple-island__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.apple-island__art {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 226, 227, 0.92), rgba(206, 28, 52, 0.78) 48%, #150a10 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Caveat", cursive;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.apple-island__meta {
  flex: 1;
  min-width: 0;
}
.apple-island__title {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apple-island__artist {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255, 226, 227, 0.68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Progress scrubber */
.apple-island__progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.56);
}
.apple-island__time {
  flex-shrink: 0;
  min-width: 30px;
  font-variant-numeric: tabular-nums;
}
.apple-island__time--end {
  text-align: right;
}

.apple-island__range {
  --pct: 0%;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    #ffe2e3 0%,
    #ffe2e3 var(--pct),
    rgba(255, 255, 255, 0.20) var(--pct),
    rgba(255, 255, 255, 0.20) 100%
  );
  outline: none;
  cursor: pointer;
}
.apple-island__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 226, 227, 0.65);
  transition: transform 0.14s ease;
}
.apple-island__range:hover::-webkit-slider-thumb {
  transform: scale(1.16);
}
.apple-island__range::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 226, 227, 0.65);
}

/* Controls row */
.apple-island__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
}
.apple-island__btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.apple-ctrl-btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  line-height: 0;
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.92);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease, color 0.16s ease;
}
.apple-ctrl-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}
.apple-ctrl-btn:hover {
  background: rgba(255, 226, 227, 0.22);
  color: #ffffff;
  transform: scale(1.06);
}
.apple-ctrl-btn:active {
  transform: scale(0.94);
}

.apple-ctrl-btn--play {
  width: 38px;
  height: 38px;
  background: #ffe2e3;
  color: #07060a;
  box-shadow: 0 4px 16px rgba(255, 226, 227, 0.28);
}
.apple-ctrl-btn--play svg {
  width: 18px;
  height: 18px;
}
.apple-ctrl-btn--play:hover {
  background: #ffffff;
  color: #07060a;
}

.apple-ctrl-btn--sm {
  width: 28px;
  height: 28px;
}
.apple-ctrl-btn--sm svg {
  width: 14px;
  height: 14px;
}

.apple-ctrl-btn--vol {
  width: 28px;
  height: 28px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
}
.apple-ctrl-btn--vol svg {
  width: 16px;
  height: 16px;
}
.apple-ctrl-btn--vol:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #ffe2e3;
}

/* Volume mixer — strictly bounded inside the island view */
.apple-island__vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  max-width: 148px;
  min-width: 92px;
}
.apple-island__vol-track {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}
.apple-island__vol .apple-island__range {
  height: 4px;
}

@media (max-width: 768px) {
  .apple-island-wrap {
    top: 66px;
  }
  body.is-admin-builder .apple-island-wrap {
    top: 108px;
  }
  body.is-reader-open .apple-island-wrap {
    top: 56px;
  }
  .hero-music-invite {
    top: auto;
    bottom: clamp(138px, 16vh, 174px);
    padding: 8px 10px 8px 12px;
    gap: 10px;
  }
  .hero-music-invite__prompt { font-size: 16px; }
  .hero-music-invite__disc { width: 32px; height: 32px; }
  .hero-music-invite__play { width: 36px; height: 36px; }
  .hero-music-invite__play svg { width: 16px; height: 16px; }
}
