/* =========================================================
   MatWeb — strona główna: napis-hero + 4 równorzędne wejścia
   ========================================================= */

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--pad);
  padding-top: max(var(--pad), env(safe-area-inset-top));
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page > .topbar {
  position: absolute;
  top: max(var(--pad), env(safe-area-inset-top));
  left: var(--pad);
  right: var(--pad);
  animation: up 800ms var(--ease-out) 900ms both;
}

/* Hero: napis + 4 opcje, wyśrodkowane na stronie */
.hero {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(56px, 8vh, 88px) 0;
}

/* Mateusz (11.11): mniejszy napis, większe pola — szerokość wyznaczają pola, nie napis */
.hero__inner {
  width: min(100%, 1180px);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(22px, 3.4vw, 44px);
}

/* ---------- Napis ---------- */
.mark {
  position: relative;
  align-self: center;
  width: fit-content;
  max-width: 100%;
  animation: mark-in 1300ms var(--ease-quint) 150ms both;
}

.word {
  display: block;
  font-weight: 700;
  font-size: clamp(44px, 10.5vw, 210px);
  line-height: .82;
  letter-spacing: -.012em;
  padding: .04em .02em .06em 0;
  white-space: nowrap;
  user-select: none;
}

/* Napis „spokojny” (Mateusz, 11.11 — wzorzec docelowy): jeden jasny kolor, litery stoją w miejscu.
   Bez przesuwanego wypełnienia i bez faktur. Warstwy .word--layer zostają w HTML,
   bo home.js liczy po nich produkty, ale nie są rysowane. */
.word--base { color: var(--fg); }
.word--layer { display: none !important; }

/* Warstwy produktu: tło przycięte do kształtu liter */
.word--layer {
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
}

.word--layer {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 900ms var(--ease-quint);
}
.word--layer.is-before { clip-path: inset(0 0 0 100%); }
.word--layer.is-active { clip-path: inset(0 0 0 0); }
.word--layer.no-anim { transition: none; }

/* Kolor liter: --w-xx ustawia panel (Agenci → Wygląd strony), domyślnie kolor produktu.
   Faktura (--fx-tex) i jej ruch (--texmove) też idą z panelu przez look.css. */
.word--layer {
  /* Matowy kolor: kolor produktu zmieszany z jasnym grafitem (--mute = % koloru produktu) */
  --w-m: color-mix(in srgb, var(--w) calc(var(--mute, 58) * 1%), #B4B8C2);
  --w-hi: color-mix(in srgb, var(--w-m) 86%, #FFFFFF);
  --w-lo: var(--w-m); /* dół liter nie ciemnieje — kontrast ≥3:1 także na szarym tle z panelu */
  --tex-a: calc(.05 * var(--fx-tex, 1));
}

/* LeadList — linie listy płynące w dół */
.word--ll {
  --w: var(--w-ll, var(--ll));
  background-image:
    repeating-linear-gradient(180deg, rgb(255 255 255 / var(--tex-a)) 0 2px, transparent 2px 22px),
    linear-gradient(180deg, var(--w-hi) 0%, var(--w-m) 60%, var(--w-lo) 100%);
  background-size: 100% 22px, 100% 100%;
  animation: list-scroll 3.5s linear infinite;
  animation-play-state: var(--texmove, running);
}

/* WebiGames — kropki w powolnym dryfie */
.word--wg {
  --w: var(--w-wg, var(--wg));
  background-image:
    radial-gradient(rgb(255 255 255 / calc(var(--tex-a) * 1.4)) 1.8px, transparent 2.2px),
    linear-gradient(180deg, var(--w-hi) 0%, var(--w-m) 60%, var(--w-lo) 100%);
  background-size: 22px 22px, 100% 100%;
  animation: dots-drift 6s linear infinite;
  animation-play-state: var(--texmove, running);
}

/* CVix — kratka jak na kartce */
.word--cv {
  --w: var(--w-cv, var(--cv));
  background-image:
    repeating-linear-gradient(90deg, rgb(255 255 255 / var(--tex-a)) 0 1.5px, transparent 1.5px 26px),
    repeating-linear-gradient(180deg, rgb(255 255 255 / var(--tex-a)) 0 1.5px, transparent 1.5px 26px),
    linear-gradient(180deg, var(--w-hi) 0%, var(--w-m) 60%, var(--w-lo) 100%);
  background-size: 26px 26px, 26px 26px, 100% 100%;
  animation: grid-rise 5s linear infinite;
  animation-play-state: var(--texmove, running);
}

/* Matura — ukośne pasy */
.word--mt {
  --w: var(--w-mt, var(--mt));
  background-image:
    repeating-linear-gradient(135deg, rgb(255 255 255 / var(--tex-a)) 0 10px, transparent 10px 24px),
    linear-gradient(180deg, var(--w-hi) 0%, var(--w-m) 60%, var(--w-lo) 100%);
  background-size: 34px 34px, 100% 100%;
  animation: stripes-move 4s linear infinite;
  animation-play-state: var(--texmove, running);
}

/* ---------- Wejścia ---------- */
.segments {
  width: 0;
  min-width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(14px, 1.6vw, 24px);
}

.seg {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}
.seg__track, .seg__name {
  opacity: .6;
  transition: opacity 400ms ease;
}
.seg.is-active .seg__track, .seg.is-active .seg__name,
.seg:hover .seg__track, .seg:hover .seg__name { opacity: 1; }
.seg:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 6px;
  border-radius: 2px;
}

.seg__track {
  display: block;
  height: 2px;
  background: var(--track);
  overflow: hidden;
}
.seg__fill {
  display: block;
  height: 100%;
  background: var(--seg, #FFFFFF);
  transform: scaleX(0);
  transform-origin: left center;
}
.seg__meta {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .12em;
  color: #C4C8D1;
}
.seg__name {
  display: flex;
  align-items: center;
  gap: .3em;
  font-weight: 700;
  font-size: clamp(24px, 2.5vw, 38px);
  line-height: 1;
  letter-spacing: -.03em;
}
.seg__desc {
  font-size: 16px;
  line-height: 1.45;
  color: #CDD1D9;
  max-width: 30ch;
}
.seg__arrow {
  width: .62em;
  height: .62em;
  flex: none;
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity 300ms ease, transform 400ms var(--ease-out);
}
.seg.is-active .seg__arrow,
.seg:hover .seg__arrow,
.seg:focus-visible .seg__arrow {
  opacity: 1;
  transform: none;
}

/* Węższy ekran: pola 2 × 2 */
@media (max-width: 900px) {
  .segments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Telefon: pola jedno pod drugim */
@media (max-width: 560px) {
  .word { font-size: 16vw; }
  .segments { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .seg__name { font-size: 26px; }
  .seg__desc { font-size: 15px; max-width: none; }
}

/* ---------- Animacje ---------- */
@keyframes mark-in {
  from { clip-path: inset(100% 0 0 0); transform: translateY(8%); }
  to   { clip-path: inset(0 0 0 0); transform: none; }
}
@keyframes list-scroll  { from { background-position: 0 0, 0 0; } to { background-position: 0 22px, 0 0; } }
@keyframes dots-drift   { from { background-position: 0 0, 0 0; } to { background-position: 22px 22px, 0 0; } }
@keyframes grid-rise    { from { background-position: 0 0, 0 0, 0 0; } to { background-position: 0 -26px, 0 -26px, 0 0; } }
@keyframes stripes-move { from { background-position: 0 0, 0 0; } to { background-position: 34px 0, 0 0; } }

/* =========================================================
   Wygląd sterowany z panelu Agenci (MatWeb → „Wygląd strony”).
   Panel zapisuje public/assets/look.css z samymi zmiennymi :root —
   poniżej wartości domyślne (ciemny grafit), gdy look.css nie ma.
   Efekty to liczby 0/1 (--fx-*), więc wyłączenie efektu niczego nie przebudowuje.
   ========================================================= */
@property --act {
  syntax: '<color>';
  inherits: true;
  initial-value: #2BC383;
}

:root {
  --L: 30;
  --bg: hsl(225 8% calc(var(--L) * 1%));
  --bg-2: hsl(225 8% calc((var(--L) + 5) * 1%));
  --act: var(--ll);

  /* ton tekstu — look.css podmienia na jasny zestaw, gdy tło jest jasne */
  --fg: #EDEEF0;
  --muted: #A9AEB9;
  --dim: #8C919E;
  --track: rgb(237 238 240 / .18);
  --glass: rgb(255 255 255 / .06);
  --glass-line: rgb(255 255 255 / .10);
  --shadow-c: rgb(0 0 0 / .55);
  --noise-o: .07;
  --noise-filter: invert(1);
  color-scheme: dark;

  --fx-glow: 1;
  --fx-noise: 1;
  --fx-glass: 1;
  --fx-motion: 1;
  --fx-pulse: 1;
  --fx-tex: 1;
  --fx-shadow: 1;
  --fx-tilt: 1;
  --texmove: running;

  transition: --act 900ms ease;
}
html,
body {
  background: var(--bg);
  color: var(--fg);
}
.page { isolation: isolate; }
.mark__tilt { position: relative; }

/* ---------- Poświata w kolorze aktywnego produktu ---------- */
.page::before {
  content: '';
  position: fixed;
  inset: -15%;
  z-index: -2;
  pointer-events: none;
  opacity: calc(var(--fx-glow) * .5);
  background:
    radial-gradient(38% 32% at 50% 44%, color-mix(in srgb, var(--act) 30%, transparent), transparent 72%),
    radial-gradient(32% 30% at 12% 88%, color-mix(in srgb, var(--act) 16%, transparent), transparent 70%),
    radial-gradient(30% 28% at 90% 10%, rgb(255 255 255 / .10), transparent 70%);
  animation: glow-drift 22s ease-in-out infinite alternate;
  transition: opacity 400ms ease;
}

/* ---------- Cień / poblask pod literami (rzucają go bazowe litery pod warstwami) ---------- */
.word--base {
  text-shadow: 0 14px 36px color-mix(in srgb, var(--act) calc(12% * var(--fx-shadow)), transparent);
  transition: text-shadow 900ms ease;
}

/* ---------- Ziarno na tle ---------- */
.page::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: calc(var(--noise-o) * var(--fx-noise));
  filter: var(--noise-filter);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ---------- Szklane karty wejść (0 = goły tekst jak dawniej) ---------- */
.seg {
  --g: var(--fx-glass);
  padding: calc(24px * var(--g)) calc(26px * var(--g)) calc(28px * var(--g));
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--glass-line) calc(100% * var(--g)), transparent);
  background-color: color-mix(in srgb, var(--glass) calc(100% * var(--g)), transparent);
  box-shadow: 0 16px 38px -18px color-mix(in srgb, var(--shadow-c) calc(100% * var(--g)), transparent);
  -webkit-backdrop-filter: blur(calc(16px * var(--g))) saturate(calc(100% + 50% * var(--g)));
  backdrop-filter: blur(calc(16px * var(--g))) saturate(calc(100% + 50% * var(--g)));
  transition: transform 500ms var(--ease-out), box-shadow 400ms ease, border-color 400ms ease, background-color 400ms ease;
}
.seg.is-active {
  border-color: color-mix(in srgb, var(--seg) calc(55% * var(--g)), transparent);
  background-color: color-mix(in srgb, color-mix(in srgb, var(--seg) 10%, var(--glass)) calc(100% * var(--g)), transparent);
}
.seg:focus-visible { border-radius: 18px; }

/* ---------- Animacje wejścia i hover ---------- */
.seg {
  animation: seg-in 900ms var(--ease-out) both;
  animation-delay: calc(1150ms + var(--i, 0) * 120ms);
}
.seg:hover,
.seg:focus-visible { transform: translateY(calc(-5px * var(--fx-motion))); }
.mark__tilt {
  transform: perspective(1400px) rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg));
  transition: transform 700ms var(--ease-out);
}

/* ---------- Pulsująca kropka statusu ---------- */
.topbar__label { display: inline-flex; align-items: center; gap: calc(10px * var(--fx-pulse)); }
.pulse {
  display: inline-block;
  flex: none;
  width: calc(8px * var(--fx-pulse));
  height: 8px;
  border-radius: 50%;
  background: var(--act);
  opacity: var(--fx-pulse);
  animation: pulse 1.8s ease-out infinite;
}
.seg.is-active .seg__meta::before {
  content: '';
  display: inline-block;
  width: calc(6px * var(--fx-pulse));
  height: 6px;
  margin-right: calc(8px * var(--fx-pulse));
  vertical-align: 1px;
  border-radius: 50%;
  background: var(--seg);
  opacity: var(--fx-pulse);
  animation: pulse-seg 1.8s ease-out infinite;
}

@keyframes glow-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.06); }
}
/* translate (nie transform) — po wejściu transform zostaje wolny dla hovera */
@keyframes seg-in {
  from { opacity: calc(1 - var(--fx-motion)); translate: 0 calc(18px * var(--fx-motion)); }
  to   { opacity: 1; translate: 0 0; }
}
@keyframes pulse {
  0%        { box-shadow: 0 0 0 0 color-mix(in srgb, var(--act) 60%, transparent); }
  80%, 100% { box-shadow: 0 0 0 9px transparent; }
}
@keyframes pulse-seg {
  0%        { box-shadow: 0 0 0 0 color-mix(in srgb, var(--seg) 60%, transparent); }
  80%, 100% { box-shadow: 0 0 0 7px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .mark__tilt { transform: none; }
}
