/* ==========================================================================
   XHYPHER TECH — SITE WIDGETS
   Cookie consent (banner + preferences modal) and the floating
   social/community panel. Markup for both is injected by js/widgets.js so
   it can be shared across index.html and pretty-md.html without duplicating
   large blocks of HTML. Uses only the site's existing design tokens
   (colors, radius, easing) defined in css/styles.css.
   ========================================================================== */

/* --- Shared toggle switch (used in the cookie preferences modal) --- */
.xh-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.xh-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.xh-switch-track {
  position: absolute;
  inset: 0;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease);
}
.xh-switch-track::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform var(--dur-fast) var(--ease);
}
.xh-switch input:checked ~ .xh-switch-track { background: var(--blue); }
.xh-switch input:checked ~ .xh-switch-track::before { transform: translateX(18px); }
.xh-switch input:disabled ~ .xh-switch-track { opacity: 0.7; cursor: not-allowed; }
.xh-switch input:focus-visible ~ .xh-switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ==========================================================================
   COOKIE BANNER
   ========================================================================== */
.xh-cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 980;
  max-width: 620px;
  margin: 0 auto;
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  transform: translateY(140%);
  opacity: 0;
  transition: transform 0.5s var(--ease), opacity 0.5s var(--ease);
}
.xh-cookie-banner.is-visible { transform: translateY(0); opacity: 1; }

.xh-cookie-banner-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.xh-cookie-banner-head svg { width: 18px; height: 18px; stroke: var(--blue); flex-shrink: 0; }
.xh-cookie-banner-head strong {
  font-family: var(--font-display);
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.xh-cookie-banner p {
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.55;
  margin: 0 0 16px;
}
.xh-cookie-banner p button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--blue);
  text-decoration: underline;
  cursor: pointer;
}

.xh-cookie-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.xh-cookie-actions .btn { flex: 1 1 auto; justify-content: center; }

/* ==========================================================================
   COOKIE PREFERENCES MODAL
   ========================================================================== */
.xh-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 995;
  background: rgba(4, 5, 7, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
.xh-modal-overlay.is-visible { opacity: 1; pointer-events: auto; }

.xh-modal {
  width: 100%;
  max-width: 480px;
  max-height: min(640px, 88vh);
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.45);
  transform: translateY(24px) scale(0.98);
  transition: transform 0.35s var(--ease);
}
.xh-modal-overlay.is-visible .xh-modal { transform: translateY(0) scale(1); }

.xh-modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
  z-index: 1;
}
.xh-modal-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.xh-modal-head-title svg { width: 20px; height: 20px; stroke: var(--blue); flex-shrink: 0; }
.xh-modal-head h3 {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--ink);
}

.xh-modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.xh-modal-close:hover { border-color: var(--ink); color: var(--ink); }
.xh-modal-close svg { width: 15px; height: 15px; }

.xh-modal-body { padding: 20px 22px 4px; }
.xh-modal-intro {
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.6;
  margin: 0 0 20px;
}

.xh-cookie-category {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.xh-cookie-category:first-of-type { border-top: none; padding-top: 0; }

.xh-cookie-category-text h4 {
  font-size: 14.5px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.xh-cookie-category-text h4 .xh-always-on {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  border: 1px solid var(--green);
  background: var(--green-dim);
  border-radius: 999px;
  padding: 2px 8px;
}
.xh-cookie-category-text p {
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.5;
  margin: 0;
}

.xh-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px 22px 22px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.xh-modal-footer .btn { flex: 1 1 auto; justify-content: center; }

/* ==========================================================================
   FLOATING SOCIAL / COMMUNITY BUTTON + PANEL
   ========================================================================== */
.xh-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 960;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: linear-gradient(160deg, var(--blue) 0%, color-mix(in srgb, var(--blue) 55%, var(--ink)) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  transition: transform var(--dur-fast) var(--ease);
}
.xh-fab:hover { transform: translateY(-3px); }
.xh-fab svg { width: 24px; height: 24px; }

.xh-fab-dot {
  position: absolute;
  top: -1px; right: -1px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px var(--green);
}

.xh-social-panel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 960;
  width: min(300px, calc(100vw - 32px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
  padding: 8px;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: transform 0.28s var(--ease), opacity 0.28s var(--ease);
}
.xh-social-panel.is-visible { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

.xh-social-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue);
}
.xh-social-panel-head svg { width: 15px; height: 15px; }

.xh-social-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease);
}
.xh-social-item:hover,
.xh-social-item:focus-visible { background: var(--surface); }
.xh-social-item.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.xh-social-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.xh-social-icon svg { width: 18px; height: 18px; }
.xh-social-icon.xh-c-whatsapp { background: #25d366; }
.xh-social-icon.xh-c-telegram { background: #29a9eb; }
.xh-social-icon.xh-c-instagram { background: radial-gradient(circle at 30% 110%, #ffd521 0%, #f50000 30%, #b900b4 60%, #405de6 90%); }
.xh-social-icon.xh-c-facebook { background: #1877f2; }
.xh-social-icon.xh-c-tiktok { background: #010101; }
.xh-social-icon.xh-c-youtube { background: #ff0000; }

.xh-social-item-name { font-size: 13.5px; font-weight: 600; }
.xh-social-item-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 480px) {
  .xh-cookie-banner { left: 10px; right: 10px; bottom: 10px; padding: 16px 16px; }
  .xh-cookie-actions { flex-direction: column; }
  .xh-cookie-actions .btn { width: 100%; }

  .xh-modal { border-radius: 14px; }
  .xh-modal-head, .xh-modal-body, .xh-modal-footer { padding-left: 16px; padding-right: 16px; }
  .xh-modal-footer { flex-direction: column; }

  .xh-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; }
  .xh-social-panel { right: 14px; bottom: 78px; width: min(280px, calc(100vw - 24px)); }
}
