/*
 * pf-kit v1 — the behaviour layer for AI-built PassFactory sites.
 * Mechanics only (hidden/shown states, motion, overlays). The look — colours,
 * type, radii, spacing — belongs to the page's own stylesheet; the few visual
 * defaults here read CSS variables the page may set:
 *   --pf-accent        dots, focus rings, progress bar   (default: currentColor)
 *   --pf-modal-bg      dialog surface                    (default: #fff)
 *   --pf-modal-color   dialog text                       (default: #111)
 *   --pf-modal-radius  dialog corners                    (default: 16px)
 *   --pf-backdrop      dialog / lightbox backdrop        (default: rgba(0,0,0,.6))
 * Every hidden state is scoped under html.pf-kit, which pf-kit.js sets only on
 * a live page: without JS, and inside the website editor, everything shows.
 */

/* ---- Reveal on scroll: [data-pf-reveal="fade-up|fade|zoom|slide-left|slide-right|blur"] ---- */
html.pf-kit [data-pf-reveal] {
  opacity: 0;
  transition:
    opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1),
    filter 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: var(--pf-delay, 0ms);
  will-change: opacity, transform;
}
html.pf-kit [data-pf-reveal="fade-up"],
html.pf-kit [data-pf-reveal=""] { transform: translateY(28px); }
html.pf-kit [data-pf-reveal="fade-down"] { transform: translateY(-28px); }
html.pf-kit [data-pf-reveal="zoom"] { transform: scale(0.94); }
html.pf-kit [data-pf-reveal="slide-left"] { transform: translateX(48px); }
html.pf-kit [data-pf-reveal="slide-right"] { transform: translateX(-48px); }
html.pf-kit [data-pf-reveal="blur"] { filter: blur(12px); }
html.pf-kit [data-pf-reveal].pf-in {
  opacity: 1;
  transform: none;
  filter: none;
}

/* ---- Modals / popups: <dialog class="pf-modal" id="…"> + [data-pf-open="…"] ---- */
dialog.pf-modal {
  border: 0;
  padding: 0;
  max-width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  width: 100%;
  background: var(--pf-modal-bg, #fff);
  color: var(--pf-modal-color, #111);
  border-radius: var(--pf-modal-radius, 16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  overflow: auto;
}
dialog.pf-modal::backdrop {
  background: var(--pf-backdrop, rgba(0, 0, 0, 0.6));
  backdrop-filter: blur(4px);
}
dialog.pf-modal[open] { animation: pf-modal-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1); }
dialog.pf-modal[open]::backdrop { animation: pf-fade-in 0.35s ease-out; }
dialog.pf-modal.pf-modal--sheet {
  margin: auto auto 0;
  max-width: 100%;
  border-radius: var(--pf-modal-radius, 16px) var(--pf-modal-radius, 16px) 0 0;
}
dialog.pf-modal.pf-modal--sheet[open] { animation-name: pf-sheet-in; }
dialog.pf-modal.pf-modal--wide { max-width: min(960px, calc(100vw - 32px)); }
.pf-modal [data-pf-close] { cursor: pointer; }
.pf-modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
@keyframes pf-modal-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes pf-sheet-in { from { transform: translateY(100%); } }
@keyframes pf-fade-in { from { opacity: 0; } }

/* ---- Carousel: [data-pf-carousel] > .pf-track > slides ---- */
[data-pf-carousel] { position: relative; }
[data-pf-carousel] > .pf-track {
  display: flex;
  gap: var(--pf-gap, 16px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
[data-pf-carousel] > .pf-track::-webkit-scrollbar { display: none; }
[data-pf-carousel] > .pf-track > * {
  flex: 0 0 var(--pf-slide, 100%);
  scroll-snap-align: start;
  min-width: 0;
}
.pf-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-size: 20px;
  cursor: pointer;
}
.pf-carousel-btn[disabled] { opacity: 0.35; cursor: default; }
.pf-carousel-prev { left: 8px; }
.pf-carousel-next { right: 8px; }
.pf-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
.pf-carousel-dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.3;
  cursor: pointer;
  transition: width 0.3s, opacity 0.3s;
}
.pf-carousel-dots button[aria-current="true"] {
  width: 24px;
  opacity: 1;
  background: var(--pf-accent, currentColor);
}

/* ---- Tabs: [data-pf-tabs] with [data-pf-tab="x"] buttons and [data-pf-panel="x"] panels ---- */
html.pf-kit [data-pf-panel][hidden] { display: none; }
html.pf-kit [data-pf-panel].pf-panel-in { animation: pf-fade-up 0.4s ease-out; }
@keyframes pf-fade-up { from { opacity: 0; transform: translateY(8px); } }

/* ---- Marquee: [data-pf-marquee] (children scroll in an endless line) ---- */
[data-pf-marquee] {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.pf-marquee-track {
  display: flex;
  width: max-content;
  gap: var(--pf-gap, 48px);
  animation: pf-marquee var(--pf-marquee-duration, 30s) linear infinite;
}
[data-pf-marquee]:hover .pf-marquee-track { animation-play-state: paused; }
[data-pf-marquee="reverse"] .pf-marquee-track { animation-direction: reverse; }
@keyframes pf-marquee { to { transform: translateX(calc(-50% - var(--pf-gap, 48px) / 2)); } }

/* ---- Lightbox: [data-pf-lightbox] (click an image to view it large) ---- */
[data-pf-lightbox] img { cursor: zoom-in; }
.pf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pf-backdrop, rgba(0, 0, 0, 0.88));
  animation: pf-fade-in 0.25s ease-out;
}
.pf-lightbox img {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 120px);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.pf-lightbox button {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}
.pf-lightbox .pf-lb-close { top: 16px; right: 16px; }
.pf-lightbox .pf-lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.pf-lightbox .pf-lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.pf-lightbox .pf-lb-caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  opacity: 0.85;
}

/* ---- Scroll progress: [data-pf-progress] (a bar that fills as the page scrolls) ---- */
[data-pf-progress] {
  transform-origin: 0 50%;
  transform: scaleX(var(--pf-progress, 0));
  background: var(--pf-accent, currentColor);
}

/* ---- Sticky header: [data-pf-sticky] gets .is-scrolled once the page moves ---- */
[data-pf-sticky] { transition: background-color 0.3s, box-shadow 0.3s, padding 0.3s, backdrop-filter 0.3s; }

/* ---- Focus + reduced motion ---- */
.pf-carousel-btn:focus-visible,
.pf-carousel-dots button:focus-visible,
.pf-lightbox button:focus-visible,
.pf-modal-x:focus-visible {
  outline: 2px solid var(--pf-accent, currentColor);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  html.pf-kit [data-pf-reveal] { transition: none; opacity: 1; transform: none; filter: none; }
  .pf-marquee-track { animation-duration: calc(var(--pf-marquee-duration, 30s) * 4); }
  dialog.pf-modal[open],
  dialog.pf-modal[open]::backdrop { animation: none; }
}

/* ---- 1.1: dropdowns, choosers, tooltips ---- */
details[data-pf-dropdown] { position: relative; display: inline-block; }
details[data-pf-dropdown] > summary { list-style: none; cursor: pointer; }
details[data-pf-dropdown] > summary::-webkit-details-marker { display: none; }
details[data-pf-dropdown] > summary::after { content: ""; display: inline-block; width: .45em; height: .45em; margin-left: .5em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-.15em) rotate(45deg); transition: transform .2s; }
details[data-pf-dropdown][open] > summary::after { transform: translateY(.1em) rotate(-135deg); }
details[data-pf-dropdown] > :not(summary) { position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; min-width: 220px; }
html.pf-kit details[data-pf-dropdown][open] > :not(summary) { animation: pf-dd-in .18s ease-out; }
@keyframes pf-dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

[data-pf-filter-item][hidden] { display: none !important; }
html.pf-kit .pf-filter-in { animation: pf-dd-in .25s ease-out; }

[data-pf-tip] { position: relative; }
[data-pf-tip]::after { content: attr(data-pf-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px); padding: 6px 10px; border-radius: 8px; background: #111; color: #fff; font-size: 12.5px; line-height: 1.3; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s, transform .15s; z-index: 50; }
[data-pf-tip]:hover::after, [data-pf-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { html.pf-kit details[data-pf-dropdown][open] > :not(summary), html.pf-kit .pf-filter-in { animation: none; } }
/* Ready-made choice buttons from the editor: [data-pf-chip] shows which one is chosen. */
[data-pf-chip].is-active { background: var(--pf-chip-on, var(--color-accent, #111)) !important; border-color: var(--pf-chip-on, var(--color-accent, #111)) !important; color: var(--pf-chip-on-text, var(--color-btn-text, #fff)) !important; }
