/* Kraftrs Promotions — Offers Rail
 * A sticky edge tab (desktop: vertical text tab mid-screen; mobile: same tab,
 * panel becomes a bottom sheet) listing every active campaign opted in via
 * "Show in Offers Rail". Off by default (kp_offers_rail_enabled).
 *
 * Color customization: --kp-rail-color / --kp-rail-text-color are set inline
 * per-site (OffersRail::render_placeholder()) only when the merchant picked
 * a custom color; otherwise they fall through to the shared brand color
 * (--kp-primary) so the rail matches everything else out of the box.
 */

.kp-offers-rail-tab-wrap {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 999996;
}

.kp-offers-rail--right .kp-offers-rail-tab-wrap { right: 0; }
.kp-offers-rail--left .kp-offers-rail-tab-wrap { left: 0; }

.kp-offers-rail-tab {
  position: relative;
  z-index: 999996;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--kp-rail-color, var(--kp-primary, #f5a623));
  color: var(--kp-rail-text-color, #fff);
  font-family: var(--kp-font, inherit);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  writing-mode: vertical-rl;
  animation-duration: 2.4s;
  animation-timing-function: ease-in-out;
  animation-delay: 1s;
  animation-iteration-count: 2;
}

@media (prefers-reduced-motion: reduce) {
  .kp-offers-rail-tab {
    animation: none;
  }
}

.kp-offers-rail-tab:hover {
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
}

.kp-offers-rail--right .kp-offers-rail-tab {
  border-radius: 10px 0 0 10px;
}

.kp-offers-rail--right .kp-offers-rail-tab:hover {
  transform: translateX(-4px);
}

.kp-offers-rail--left .kp-offers-rail-tab {
  border-radius: 0 10px 10px 0;
}

.kp-offers-rail--left .kp-offers-rail-tab:hover {
  transform: translateX(4px);
}

.kp-offers-rail--right .kp-offers-rail-tab { animation-name: kp-rail-tab-attract-right; }
.kp-offers-rail--left .kp-offers-rail-tab { animation-name: kp-rail-tab-attract-left; }

@keyframes kp-rail-tab-attract-right {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-3px); }
}

@keyframes kp-rail-tab-attract-left {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

/* ── Hide button — small × overlapping the tab's outer top corner. Separate
   sibling button (not nested inside .kp-offers-rail-tab — a <button> can't
   validly contain another <button>), absolutely positioned against the
   shared wrapper. Click hides the whole rail (tab included) for the rest
   of the browser session — previously there was no way to get rid of the
   tab itself at all, only close the panel once opened. ── */
.kp-offers-rail-tab-hide {
  position: absolute;
  top: -6px;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--kp-text-light, #6b7280);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease, transform 0.15s ease;
  z-index: 999997;
}

.kp-offers-rail-tab-hide:hover {
  background: var(--kp-danger, #ef4444);
  transform: scale(1.1);
}

.kp-offers-rail--right .kp-offers-rail-tab-hide { right: -6px; }
.kp-offers-rail--left .kp-offers-rail-tab-hide { left: -6px; }

.kp-offers-rail--dismissed {
  display: none !important;
}

/* ── Sizes — tab footprint + panel width ── */
.kp-offers-rail--size-small .kp-offers-rail-tab {
  padding: 8px 6px;
  font-size: 0.68rem;
}

.kp-offers-rail--size-small .kp-offers-rail-tab-icon {
  font-size: 14px;
}

.kp-offers-rail--size-medium .kp-offers-rail-tab {
  padding: 12px 10px;
  font-size: 0.8rem;
}

.kp-offers-rail--size-large .kp-offers-rail-tab {
  padding: 16px 13px;
  font-size: 0.92rem;
}

.kp-offers-rail--size-large .kp-offers-rail-tab-icon {
  font-size: 20px;
}

.kp-offers-rail--size-small .kp-offers-rail-panel { width: 280px; }
.kp-offers-rail--size-medium .kp-offers-rail-panel { width: 320px; }
.kp-offers-rail--size-large .kp-offers-rail-panel { width: 380px; }

/* ── Backdrop — click outside to close, same pattern as the cart drawer ── */
.kp-offers-rail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 999997;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.kp-offers-rail.active .kp-offers-rail-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ── Panel ── */
.kp-offers-rail-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  max-width: 88vw;
  background: #fff;
  color-scheme: light;
  z-index: 999998;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--kp-font, inherit);
}

.kp-offers-rail--right .kp-offers-rail-panel {
  right: 0;
  transform: translateX(100%);
}

.kp-offers-rail--left .kp-offers-rail-panel {
  left: 0;
  transform: translateX(-100%);
}

.kp-offers-rail.active .kp-offers-rail-panel {
  transform: translateX(0);
}

.kp-offers-rail.active .kp-offers-rail-tab {
  box-shadow: none;
  animation: none;
}

.kp-offers-rail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--kp-border, #e5e7eb);
  font-weight: 800;
  font-size: 1rem;
  color: var(--kp-text, #1f2937);
}

.kp-offers-rail-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--kp-text-light, #6b7280);
  padding: 2px 4px;
  transition: color 0.15s ease, transform 0.15s ease;
}

.kp-offers-rail-close:hover {
  color: var(--kp-danger, #ef4444);
  transform: rotate(90deg);
}

.kp-offers-rail-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kp-offers-rail-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--kp-border, #e5e7eb);
  border-radius: 10px;
  background: var(--kp-bg, #f9fafb);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.kp-offers-rail-item:hover {
  border-color: var(--kp-rail-color, var(--kp-primary, #f5a623));
  transform: translateY(-1px);
}

.kp-offers-rail-item-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1.3;
}

.kp-offers-rail-item-body {
  min-width: 0;
}

.kp-offers-rail-item-name {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--kp-text, #1f2937);
}

.kp-offers-rail-item-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--kp-text-light, #6b7280);
  line-height: 1.4;
}

/* ── Mobile: panel becomes a bottom sheet, tab stays a compact edge pill ── */
@media (max-width: 600px) {
  .kp-offers-rail-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .kp-offers-rail--right .kp-offers-rail-panel,
  .kp-offers-rail--left .kp-offers-rail-panel {
    transform: translateY(100%);
  }

  .kp-offers-rail.active .kp-offers-rail-panel {
    transform: translateY(0);
  }

  .kp-offers-rail--size-small .kp-offers-rail-tab { padding: 8px 6px; font-size: 0.64rem; }
  .kp-offers-rail--size-medium .kp-offers-rail-tab { padding: 10px 8px; font-size: 0.72rem; }
  .kp-offers-rail--size-large .kp-offers-rail-tab { padding: 12px 10px; font-size: 0.8rem; }

  .kp-offers-rail-list {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .kp-offers-rail-close {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Intentionally no @media (prefers-color-scheme: dark) block — kept
   consistent with cart-drawer.css/toast.css, same plugin-wide decision:
   always render the light palette regardless of system theme, rather than
   risk a partially-dark-moded panel. */
