/* ==========================================================================
   ZLOTY DOM · TikTok LIVE – pływający odtwarzacz transmisji
   --------------------------------------------------------------------------
   Paleta dziedziczy po skórze szablonu (css/zlotydom.css):
     --zloto, --zloto-jasne, --zloto-ciemne, --atrament, --wegiel, --krem
   Własne tokeny (--sgtl-*) mają wartości domyślne i można je nadpisać
   wyżej w arkuszu, jeśli sklep zmieni paletę.
   ========================================================================== */

.sgtl {
  /* --- paleta z motywu szablonu (fallback, gdyby skóra nie była wczytana) --- */
  --sgtl-accent: var(--zloto, #c6a15b);
  --sgtl-accent-ink: var(--wegiel, #221c15);
  --sgtl-live: var(--czerwien, #b3202c);
  --sgtl-bg: var(--atrament, #171310);
  --sgtl-surface: rgba(34, 28, 21, 0.94);
  --sgtl-ink: #fffdf7;
  --sgtl-muted: rgba(255, 253, 247, 0.74);
  --sgtl-border: rgba(198, 161, 91, 0.28);
  --sgtl-radius: 18px;
  --sgtl-radius-sm: 12px;
  --sgtl-width: 360px;      /* nadpisywane z panelu (style na kontenerze) */
  --sgtl-width-mobile: 0px;  /* 0 = auto (calc(100vw - 32px)) */
  --sgtl-offset-x: 20px;    /* odstęp od krawędzi poziomej */
  --sgtl-offset-y: 20px;    /* odstęp od krawędzi pionowej */
  --sgtl-shadow: 0 24px 60px -24px rgba(60, 45, 15, 0.55);
  --sgtl-z: 9999;
  --sgtl-font: 'DM Sans', system-ui, -apple-system, sans-serif;

  position: fixed;
  z-index: var(--sgtl-z);
  /* pozycja domyślna: prawy dolny róg; nadpisywana atrybutem data-sgtl-pos */
  inset-block-end: var(--sgtl-offset-y);
  inset-inline-end: var(--sgtl-offset-x);
  width: min(var(--sgtl-width), calc(100vw - 32px));
  font-family: var(--sgtl-font);
  color: var(--sgtl-ink);
  font-size: 14px;
  line-height: 1.45;
}

/* stan: brak transmisji → całkowicie znika */
.sgtl[hidden] {
  display: none !important;
}

/* --------------------------------------------------------- polozenie --- */
/* Pozycja wybierana w panelu (data-sgtl-pos na kontenerze .sgtl-mount). */
.sgtl[data-sgtl-pos="bl"] {
  inset-block-end: var(--sgtl-offset-y);
  inset-inline-end: auto;
  inset-inline-start: var(--sgtl-offset-x);
}

.sgtl[data-sgtl-pos="tr"] {
  inset-block-end: auto;
  inset-inline-end: var(--sgtl-offset-x);
  inset-block-start: var(--sgtl-offset-y);
}

.sgtl[data-sgtl-pos="tl"] {
  inset-block-end: auto;
  inset-inline-end: auto;
  inset-inline-start: var(--sgtl-offset-x);
  inset-block-start: var(--sgtl-offset-y);
}

/* Ukrycie na ekranach telefonu (przełącznik w panelu). */
@media (max-width: 759px) {
  .sgtl[data-sgtl-mobile="off"],
  .sgtl-mount[data-sgtl-mobile="off"] {
    display: none !important;
  }
}

.sgtl *,
.sgtl *::before,
.sgtl *::after {
  box-sizing: border-box;
}

/* ---------------------------------------------------------- player box --- */

.sgtl__stage {
  position: relative;
  border-radius: var(--sgtl-radius);
  overflow: hidden;
  background: var(--sgtl-bg);
  box-shadow: var(--sgtl-shadow);
  aspect-ratio: 9 / 12;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.25s ease, opacity 0.25s ease;
  transform-origin: bottom right;
}

.sgtl__video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: var(--sgtl-bg);
}

/* delikatne przyciemnienie góry i dołu dla czytelności overlayi */
.sgtl__stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0%,
    transparent 28%,
    transparent 58%,
    rgba(0, 0, 0, 0.72) 100%
  );
  opacity: 1;
  transition: opacity 0.25s ease;
}

.sgtl:hover .sgtl__stage {
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.55);
}

/* w stanie zminimalizowanym stage znika */
.sgtl[data-state="minimized"] .sgtl__stage {
  display: none;
}

/* -------------------------------------------------------------- top bar --- */

.sgtl__top {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 14px;
}

.sgtl__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: var(--sgtl-live);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px -4px rgba(179, 32, 44, 0.55);
}

.sgtl__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: sgtl-pulse 1.4s ease-in-out infinite;
}

@keyframes sgtl-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

.sgtl__viewers {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 600;
  color: var(--sgtl-muted);
  font-variant-numeric: tabular-nums;
}

.sgtl__viewers[hidden] {
  display: none;
}

/* --------------------------------------------------------- controlki ----- */

.sgtl__controls {
  position: absolute;
  inset-block-end: 10px;
  inset-inline-end: 10px;
  z-index: 4;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* kontrolki po najechaniu (myszą lub klawiaturą) */
.sgtl__stage:hover .sgtl__controls,
.sgtl__stage:focus-within .sgtl__controls,
.sgtl__controls.is-pinned {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.sgtl__btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--sgtl-border);
  border-radius: 50%;
  background: rgba(10, 10, 14, 0.66);
  backdrop-filter: blur(10px);
  color: var(--sgtl-ink);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.sgtl__btn:hover {
  background: rgba(30, 30, 40, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.sgtl__btn:active {
  transform: translateY(0) scale(0.94);
}

.sgtl__btn:focus-visible {
  outline: 2px solid var(--sgtl-accent);
  outline-offset: 2px;
}

.sgtl__btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sgtl__btn--close:hover {
  background: var(--sgtl-live);
  border-color: var(--sgtl-live);
}

.sgtl__btn--off {
  color: rgba(255, 255, 255, 0.45);
}

/* --------------------------------------------------------------- chat --- */

.sgtl__chat {
  position: absolute;
  inset-block-end: 52px;
  inset-inline: 10px;
  z-index: 2;
  max-height: 38%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  border-radius: var(--sgtl-radius-sm);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.28));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12.5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;

  /* chat pojawia się dopiero po najechaniu na player */
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.sgtl__stage:hover .sgtl__chat,
.sgtl__stage:focus-within .sgtl__chat,
.sgtl__chat.is-open {
  opacity: 1;
  transform: translateY(0);
}

.sgtl__chat:empty {
  display: none;
}

.sgtl__msg {
  margin: 0 0 5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  word-break: break-word;
}

.sgtl__msg:last-child {
  margin-bottom: 0;
}

.sgtl__msg b {
  color: var(--sgtl-accent);
  font-weight: 700;
  margin-inline-end: 5px;
}

.sgtl__msg--system {
  color: var(--sgtl-muted);
  font-style: italic;
}

/* ------------------------------------------------------------- prompt --- */

.sgtl__prompt {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px 20px;
  text-align: center;
  background: radial-gradient(
      120% 90% at 50% 20%,
      rgba(198, 161, 91, 0.16),
      transparent 60%
    ),
    rgba(8, 8, 12, 0.86);
  backdrop-filter: blur(8px);
  animation: sgtl-fade 0.35s ease both;
}

.sgtl__prompt[hidden] {
  display: none !important;
}

@keyframes sgtl-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sgtl__prompt h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sgtl__prompt p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--sgtl-muted);
}

.sgtl__prompt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.sgtl__btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--sgtl-accent), var(--zloto-ciemne, #8a6d2b));
  color: var(--sgtl-accent-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px -8px rgba(138, 109, 43, 0.55);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.sgtl__btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 12px 28px -8px rgba(138, 109, 43, 0.7);
}

.sgtl__btn-primary:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.sgtl__btn-ghost {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--sgtl-border);
  border-radius: 50%;
  background: transparent;
  color: var(--sgtl-muted);
  font: inherit;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.sgtl__btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--sgtl-ink);
}

.sgtl__btn-ghost svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ------------------------------------------------------- mini (pasek) --- */

.sgtl__mini {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--zloto, #c6a15b), var(--zloto-ciemne, #8a6d2b));
  color: #fffdf7;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
  box-shadow: 0 14px 34px -12px rgba(138, 109, 43, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: sgtl-rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.sgtl__mini:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -12px rgba(138, 109, 43, 0.75);
}

.sgtl__mini:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.sgtl__mini-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sgtl__mini-count {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sgtl[data-state="minimized"] .sgtl__mini {
  display: flex;
}

@keyframes sgtl-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------- pauza --- */

.sgtl__paused {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  font-size: 13px;
  color: var(--sgtl-muted);
}

.sgtl[data-paused="true"] .sgtl__paused {
  display: grid;
}

.sgtl__paused span {
  font-size: 26px;
}

/* ------------------------------------------------------------ mobile --- */

@media (max-width: 640px) {
  .sgtl {
    inset-block-end: max(12px, calc(var(--sgtl-offset-y) * 0.6));
    inset-inline: 12px;
    /* width_mobile z panelu; 0 = dopasuj do ekranu */
    width: calc(100vw - 24px);
  }

  /* Gdy panel ustawił konkretną szerokość mobilną – używamy jej. */
  .sgtl-mount[style*="--sgtl-width-mobile"] .sgtl {
    width: min(var(--sgtl-width-mobile), calc(100vw - 24px));
    inset-inline: auto;
    inset-inline-end: 12px;
  }

  .sgtl[data-sgtl-pos="bl"],
  .sgtl[data-sgtl-pos="tl"] {
    inset-inline: 12px;
    inset-inline-end: 12px;
  }

  .sgtl__stage {
    aspect-ratio: 16 / 10;
  }

  .sgtl__chat {
    max-height: 30%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sgtl *,
  .sgtl *::before,
  .sgtl *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------- noscript --- */
/* Wersja bez JavaScriptu: zwykły link do profilu, bez pływającego okna. */
.sgtl-noscript {
  position: fixed;
  z-index: 9999;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  padding: 12px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--zloto, #c6a15b), var(--zloto-ciemne, #8a6d2b));
  box-shadow: 0 14px 34px -12px rgba(138, 109, 43, 0.6);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.sgtl-noscript a {
  color: #fffdf7;
  text-decoration: none;
}

.sgtl-noscript a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .sgtl-noscript {
    inset-block-end: 12px;
    inset-inline: 12px;
    text-align: center;
  }
}

/* Przycisk dziala bez JavaScriptu i bez serwisu API. */
.sgtl-profile-link{position:fixed;z-index:9999;right:var(--sgtl-offset-x,20px);bottom:var(--sgtl-offset-y,20px);max-width:calc(100vw - 40px);box-sizing:border-box;padding:12px 20px;border:1px solid #c6a15b;border-radius:14px;background:#221c15;color:#fffdf7;text-decoration:none;font:600 14px/1.4 system-ui,sans-serif;box-shadow:0 6px 24px #0003}
.sgtl-profile-link:hover{background:#3a2f1c;color:#fffdf7}
.sgtl-profile-link:focus-visible{outline:3px solid #c6a15b;outline-offset:4px}
.sgtl-profile-link__hint{display:block;font-size:10px;font-weight:400;color:#ded4c1}
.sgtl-profile-link[data-sgtl-pos="bl"],.sgtl-profile-link[data-sgtl-pos="tl"]{right:auto;left:var(--sgtl-offset-x,20px)}
.sgtl-profile-link[data-sgtl-pos="tr"],.sgtl-profile-link[data-sgtl-pos="tl"]{bottom:auto;top:var(--sgtl-offset-y,20px)}
@media(max-width:759px){.sgtl-profile-link[data-sgtl-mobile="off"]{display:none}}
