/* =========================================================
   Space Lightplay — Frontend styles
   ========================================================= */

/* Reset default <figure> margins so the block doesn't inherit them from the
   browser user-agent stylesheet or themes. The doubled class raises the
   selector's specificity to (0,2,0) — enough to beat typical theme rules like
   `.entry-content figure` (0,1,1) — while still being overridable by the
   block's own inline style="" set from the editor's spacing controls (which
   has specificity 1,0,0,0). So Gutenberg margin/padding settings always win. */
.space-lightplay.space-lightplay {
  margin: 0;
  padding: 0;
}

.space-lightplay {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--lp-aspect, 16 / 9);
}

/* Default sizing: 100% of the parent container.
   We exclude alignwide/alignfull so the theme's own alignment rules can
   take over — otherwise our `width: 100%` and `max-width: 100%` would clamp
   the block to its content-column width and prevent wide/full stretching. */
.space-lightplay:not(.alignwide):not(.alignfull) {
  width: 100%;
  max-width: 100%;
}

.space-lightplay img,
.space-lightplay .space-lightplay-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter .25s ease;
}
.space-lightplay .space-lightplay-placeholder {
  background: center/cover no-repeat;
}

/* Subtle dim on hover. */
.space-lightplay:hover img,
.space-lightplay:hover .space-lightplay-placeholder {
  filter: brightness(0.7);
}

.space-lightplay-btn {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  appearance: none;
  outline: none;
}
.space-lightplay-btn:focus-visible .space-lightplay-icon {
  box-shadow: 0 0 0 3px #005fcc;
}

.space-lightplay-icon {
  width: var(--lp-btn-size, 80px);
  height: var(--lp-btn-size, 80px);
  aspect-ratio: 1;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: var(--lp-btn-radius, 50%);
  background: var(--lp-btn-bg, rgba(0,0,0,.55));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, color .2s ease, transform .2s ease;
  color: var(--lp-icon, #fff);
}

/* SVG triangle.
   Stroke grows the polygon outward (~0.32% of icon size per unit of stroke).
   We shrink the SVG container by exactly that amount so the triangle's
   visible size stays constant across all roundness values 0–20. */
.space-lightplay-icon svg {
  width: calc(38% - var(--lp-icon-corner-radius, 0) * 0.32%);
  height: calc(38% - var(--lp-icon-corner-radius, 0) * 0.32%);
  margin-left: 6%;
  display: block;
  overflow: visible;
}
[dir="rtl"] .space-lightplay-icon svg {
  margin-left: 0;
  margin-right: 6%;
  transform: scaleX(-1);
}
.space-lightplay-icon svg polygon {
  fill: currentColor;
  stroke: currentColor;
  /* Stroke renders behind fill so corners feel softer rather than ringed.
     Polygon points are inset within the viewBox (see render.php / edit.js)
     to leave room for the stroke — this keeps the triangle the same visible
     size regardless of corner roundness. */
  paint-order: stroke fill;
  stroke-width: var(--lp-icon-corner-radius, 0);
  stroke-linejoin: round;
  stroke-linecap: round;
}

.space-lightplay-btn:hover .space-lightplay-icon {
  background: var(--lp-btn-bg-hover, rgba(0,0,0,.7));
  color: var(--lp-icon-hover, #fff);
}

@media (prefers-reduced-motion: no-preference) {
  .space-lightplay[data-pulse="true"] .space-lightplay-btn:hover .space-lightplay-icon {
    animation: space-lightplay-pulse 1.2s infinite;
  }
}
@keyframes space-lightplay-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,0,0,.4); }
  70%  { box-shadow: 0 0 0 25px rgba(0,0,0,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

.space-lightplay-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}
.space-lightplay-iframe > iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  display: block !important;
  pointer-events: auto !important;
}

.space-lightplay.is-playing > img,
.space-lightplay.is-playing > .space-lightplay-placeholder {
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   Block style variations
   ========================================================= */

/* Minimal — smaller button, no pulse, low-contrast hover. */
.is-style-minimal .space-lightplay-icon {
  --lp-btn-size: 56px;
  --lp-btn-bg: rgba(0,0,0,.35);
  --lp-btn-bg-hover: rgba(0,0,0,.55);
}

/* Bold — big, high-contrast, scales on hover. */
.is-style-bold .space-lightplay-icon {
  --lp-btn-size: 104px;
  --lp-btn-bg: #000;
  --lp-btn-bg-hover: #000;
}
.is-style-bold .space-lightplay-btn:hover .space-lightplay-icon {
  transform: scale(1.06);
}

/* Glass — translucent with backdrop blur. */
.is-style-glass .space-lightplay-icon {
  --lp-btn-bg: rgba(255,255,255,.18);
  --lp-btn-bg-hover: rgba(255,255,255,.28);
  --lp-icon: #fff;
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  border: 1px solid rgba(255,255,255,.25);
}
