/* Please Play 0.2.0
   Palette comes from the element as custom properties (see src/themes.ts).
   Fallbacks below match the "site" theme so unstyled markup still reads. */

please-play {
  display: block;
  font: inherit;
  color: var(--pp-ink, #3d3d6b);
  --pp-bg: #ffffff;
  --pp-ink: #3d3d6b;
  --pp-muted: #606098;
  --pp-line: #dcdcf4;
  --pp-accent: #7a5f9e;
  --pp-tint: #ccccff;
  --pp-bar-top: 0px;
  --pp-radius: 4px;
}

please-play:empty { display: none; }

please-play *,
.pp-dock * { box-sizing: border-box; }

/* ---- shared type ---- */

.pp-kicker {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pp-muted);
}

.pp-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--pp-ink);
}

.pp-artist {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--pp-muted);
}

.pp-note {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--pp-muted);
}

/* ---- shared controls ---- */

.pp-play,
.pp-dismiss,
.pp-note-toggle,
.pp-dock-close {
  flex: none;
  margin: 0;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--pp-line);
  border-radius: var(--pp-radius);
  background: transparent;
  color: var(--pp-ink);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
}

.pp-play:hover,
.pp-dismiss:hover,
.pp-note-toggle:hover,
.pp-dock-close:hover {
  background: var(--pp-tint);
}

.pp-play:focus-visible,
.pp-dismiss:focus-visible,
.pp-note-toggle:focus-visible,
.pp-dock-close:focus-visible,
.pp-disc:focus-visible {
  outline: 2px solid var(--pp-accent);
  outline-offset: 2px;
}

.pp-play[aria-pressed="true"],
.pp-note-toggle[aria-expanded="true"] {
  background: var(--pp-tint);
  border-color: var(--pp-tint);
}

.pp-play:disabled {
  opacity: 0.55;
  cursor: default;
}

.pp-dismiss,
.pp-dock-close {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

/* ---- equalizer: five bars, decorative ---- */

.pp-eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  width: 18px;
  height: 16px;
  flex: none;
}

.pp-eq i {
  display: block;
  flex: 1;
  height: 100%;
  background: var(--pp-accent);
  transform-origin: bottom;
  transform: scaleY(0.25);
}

.is-playing .pp-eq { display: inline-flex; }

@media (prefers-reduced-motion: no-preference) {
  .is-playing .pp-eq i { animation: pp-eq 1.1s ease-in-out infinite alternate; }
  .is-playing .pp-eq i:nth-child(1) { animation-duration: 0.9s; animation-delay: -0.2s; }
  .is-playing .pp-eq i:nth-child(2) { animation-duration: 1.3s; animation-delay: -0.6s; }
  .is-playing .pp-eq i:nth-child(3) { animation-duration: 0.8s; animation-delay: -0.1s; }
  .is-playing .pp-eq i:nth-child(4) { animation-duration: 1.2s; animation-delay: -0.9s; }
  .is-playing .pp-eq i:nth-child(5) { animation-duration: 1.0s; animation-delay: -0.4s; }
  @keyframes pp-eq {
    from { transform: scaleY(0.15); }
    to { transform: scaleY(1); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-playing .pp-eq i:nth-child(odd) { transform: scaleY(0.6); }
  .is-playing .pp-eq i:nth-child(even) { transform: scaleY(0.9); }
}

/* ---- card: sidebar / footer ---- */

.pp--card {
  max-width: 28rem;
  border-top: 1px solid var(--pp-line);
  border-bottom: 1px solid var(--pp-line);
  padding: 1rem 0;
}

.pp--card .pp-kicker { margin-bottom: 0.35rem; }
.pp--card .pp-artist { margin-top: 0.15rem; }
.pp--card .pp-note { margin-top: 0.6rem; }

.pp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.pp-copy { min-width: 0; }

.pp-stage {
  display: none;
  margin-top: 0.85rem;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: var(--pp-radius);
  overflow: hidden;
}

.pp-stage:not([hidden]) { display: block; }

.pp-stage iframe,
.pp-dock-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- bar: sticky, one line, note on a second line when opened ---- */

please-play[layout="bar"] {
  position: sticky;
  top: var(--pp-bar-top);
  z-index: 900;
  background: var(--pp-bg);
  border-bottom: 1px solid var(--pp-line);
}

body.admin-bar please-play[layout="bar"] { --pp-bar-top: 32px; }
@media (max-width: 782px) {
  body.admin-bar please-play[layout="bar"] { --pp-bar-top: 46px; }
}

.pp--bar {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
}

.pp--bar .pp-row { align-items: center; gap: 0.6rem; }

.pp--bar .pp-copy {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.pp--bar .pp-kicker { flex: none; }
.pp--bar .pp-title,
.pp--bar .pp-artist { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pp--bar .pp-title { font-size: 0.95rem; }
.pp--bar .pp-artist { font-size: 0.85rem; }

.pp-note-row {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--pp-line);
  overflow: hidden;
}

.pp-note-row .pp-note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.pp-note-row.is-measuring .pp-note {
  display: inline-block;
  white-space: nowrap;
  visibility: hidden;
}

.pp-note-row.is-scrolling .pp-note {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
  animation: pp-marquee var(--pp-marquee-duration, 20s) linear infinite;
}

.pp-note-row.is-scrolling:hover .pp-note,
.pp-note-row.is-scrolling:focus-within .pp-note { animation-play-state: paused; }

@keyframes pp-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (max-width: 600px) {
  .pp--bar { padding: 0.45rem 0.75rem; }
  .pp--bar .pp-kicker,
  .pp--bar .pp-artist { display: none; }
  .pp--bar .pp-copy { display: block; }
}

/* ---- header: Genesis "Header Right". Mirrors the 320x100 logo: text, then a 100px disc. ---- */

please-play[layout="header"] {
  display: inline-block;
  vertical-align: top;
  max-width: 100%;
}

.pp--header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  height: 100px;
  max-width: 100%;
  text-align: right;
}

.pp--header .pp-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  max-width: 260px;
}

.pp--header .pp-title,
.pp--header .pp-artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pp--header .pp-title { font-size: 1.1rem; }
.pp--header .pp-artist { font-size: 0.9rem; }

.pp--header .pp-note {
  margin-top: 4px;
  font-size: 0.8rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.pp-disc {
  position: relative;
  flex: none;
  width: 100px;
  height: 100px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--pp-tint);
  color: var(--pp-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.pp-disc:hover { box-shadow: 0 0 0 4px var(--pp-line); }

/* Play triangle drawn with borders: no icon font, no SVG file. */
.pp-glyph {
  display: block;
  width: 0;
  height: 0;
  margin-left: 6px;
  border-style: solid;
  border-width: 16px 0 16px 28px;
  border-color: transparent transparent transparent currentColor;
}

.is-playing .pp-disc .pp-glyph { display: none; }

.pp-disc .pp-eq {
  width: 34px;
  height: 30px;
  gap: 3px;
}

@media (max-width: 1023px) {
  .pp--header { height: auto; justify-content: center; text-align: left; padding: 12px 0; }
  .pp--header .pp-copy { order: 2; }
  .pp--header .pp-disc { order: 1; width: 72px; height: 72px; }
  .pp--header .pp-disc .pp-glyph { border-width: 12px 0 12px 20px; margin-left: 4px; }
}

/* ---- dock: compliant mini player, bottom right ---- */

.pp-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 950;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--pp-bg, #fff);
  color: var(--pp-ink, #3d3d6b);
  border: 1px solid var(--pp-line, #dcdcf4);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  font: 14px/1.4 system-ui, sans-serif;
}

.pp-dock-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 6px 6px 6px 10px;
}

.pp-dock-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.pp-dock-frame {
  width: 100%;
  height: 200px;
  background: #000;
}

@media (max-width: 480px) {
  .pp-dock { right: 0; bottom: 0; width: 100%; max-width: 100%; border-radius: 0; border-width: 1px 0 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .pp-stage:not([hidden]),
  .pp-dock,
  .pp-note-row:not([hidden]) { animation: pp-reveal 180ms ease-out; }
  @keyframes pp-reveal { from { opacity: 0; transform: translateY(4px); } }
}
