/* Ekran przed logowaniem ("światło"), pierwszy kadr i pasek ładowania.
   Zasada: stan podstawowy każdego elementu to stan KOŃCOWY. Animacje startują z klatki "from",
   więc "animation: none" (ograniczony ruch, kolejne wejście w tej samej sesji) daje od razu gotowy ekran. */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --fest-ground: #1e1e1e; --fest-orange: #f76a0c; --fest-green: #6fb436; --fest-blue-d: #4f8fdb; /* niebieski z logo na ciemnym tle */
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- pierwszy kadr: ciemne tło i logo, zanim ruszy JS ---------- */
html.boot, html.boot body, :root:has(.login) { background: var(--fest-ground); }
.splash { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: var(--fest-ground); transition: opacity 180ms var(--ease-out); }
/* logo pojawia się dopiero po chwili: szybkie wczytanie pokazuje samo tło, bez mignięcia */
.splash img { width: min(42vw, 180px); height: auto; animation: splash-in 220ms ease-out 260ms both; }
.splash.is-out { opacity: 0; pointer-events: none; }
@keyframes splash-in { from { opacity: 0; } }

/* ---------- pasek ładowania (nawigacja i zapytania do API) ---------- */
.loadbar { position: fixed; left: 0; right: 0; top: env(safe-area-inset-top, 0px); height: 3px; z-index: 250; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 150ms var(--ease-out); }
.loadbar.on { opacity: 1; }
.loadbar i { display: block; width: 42%; height: 100%; background: linear-gradient(90deg, var(--fest-orange) 0 33.34%, var(--fest-green) 33.34% 66.67%, var(--fest-blue-d) 66.67%); transform: translateX(-100%); }
.loadbar.on i { animation: loadbar-run 1.15s linear infinite; }
@keyframes loadbar-run { from { transform: translateX(-100%); } to { transform: translateX(240%); } }

/* ---------- ekran logowania ---------- */
.login {
  position: relative; isolation: isolate; overflow: clip; min-height: 100vh; min-height: 100dvh;
  display: grid; align-content: center; justify-items: center; gap: 28px;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 20px calc(28px + env(safe-area-inset-bottom, 0px));
  background: var(--fest-ground); color: #fff;
}
.login-brand { display: grid; justify-items: center; gap: 14px; }
.login-lockup { position: relative; width: min(230px, 62vw); aspect-ratio: 720 / 748; }

/* poświata: trzy miękkie plamy światła za znakiem, ułożone jak jego ogniwa; ruszają się tylko przez transform */
.login-aura { position: absolute; z-index: -1; left: 50%; top: 30%; width: clamp(440px, 56vw, 760px); aspect-ratio: 1; translate: calc(-50% + var(--light-x, 0px)) calc(-50% + var(--light-y, 0px)); pointer-events: none; animation: aura-in 3200ms var(--ease-out) both; }
.login-aura i { position: absolute; width: 62%; aspect-ratio: 1; border-radius: 50%; will-change: transform; background: radial-gradient(closest-side, rgb(var(--c) / var(--a)), rgb(var(--c) / calc(var(--a) * .72)) 22%, rgb(var(--c) / calc(var(--a) * .42)) 46%, rgb(var(--c) / calc(var(--a) * .16)) 72%, transparent); }
.login-aura .a-o { --c: 247 106 12; --a: .2; left: 7%; top: 10%; animation: aura-o 19s ease-in-out infinite alternate; }
.login-aura .a-g { --c: 111 180 54; --a: .15; left: 31%; top: 7%; animation: aura-g 23s ease-in-out infinite alternate; }
.login-aura .a-b { --c: 79 143 219; --a: .22; left: 19%; top: 31%; animation: aura-b 21s ease-in-out infinite alternate; }
@keyframes aura-in { from { opacity: 0; } }
@keyframes aura-o { to { transform: translate(14%, 10%); } }
@keyframes aura-g { to { transform: translate(-12%, 13%); } }
@keyframes aura-b { to { transform: translate(9%, -13%); } }

/* napis "GRUPA FEST" z pionowego logo na ciemnym tle (dolna część pliku); lighten: tło pliku znika w poświacie, biel zostaje bielą */
.login-word { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(60% 0 0 0); mix-blend-mode: lighten; animation: login-fade 1400ms var(--ease-out) 1200ms both; }
/* znak nie wczytał się jako SVG: pokaż całe logo z pliku */
.login-lockup.no-sign .login-word { clip-path: none; animation-delay: 0ms; }

/* znak: prawdziwe ścieżki z brand/znak.svg, ułożone dokładnie tam, gdzie znak w pionowym logo */
.login-sign { position: absolute; left: 16.79%; top: -3.72%; width: 72.63%; aspect-ratio: 153.12 / 142.12; }
/* znak zawsze w oryginalnych kolorach; poświata to tylko dodatek: słaba, rozmyta kopia ogniwa POD ostrym kształtem */
.sign-layer, .sign-glow { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; transition: opacity 600ms var(--ease-out); }
/* poświata to aureola WOKÓŁ ogniw: mocno rozmyta, więc wychodzi poza kształt i nie brudzi koloru; pulsuje wyraźnie, ostre ogniwo na wierzchu się nie zmienia */
.sign-glow { filter: blur(13px) saturate(1.5); opacity: .7; animation: neon-breathe 2.8s ease-in-out infinite alternate; }
.sign-glow.lk-g { animation-delay: -.9s; } .sign-glow.lk-b { animation-delay: -1.8s; }
.sign-glow.lk-b path, .sign-layer.lk-b path { fill: var(--fest-blue-d); }
@keyframes neon-breathe { from { opacity: .08; } to { opacity: .8; } }
/* kucie znaku przy pierwszym wejściu: płótno jest większe od znaku, żeby iskry miały miejsce */
.sign-forge { position: absolute; left: -42%; top: -42%; width: 184%; height: 184%; pointer-events: none; transition: opacity 600ms var(--ease-out); }
.sign-forge.is-out { opacity: 0; }
.is-forging .sign-layer, .is-forging .sign-glow { opacity: 0; animation: none; }

/* żywe tło: siatka punktów odsłaniana światłem, które idzie za kursorem lub palcem (pozycja w --px / --py z app.js) */
.login-grid, .login-spot { position: absolute; inset: 0; pointer-events: none; }
.login-grid { z-index: -3; background-image: radial-gradient(rgb(255 255 255 / .34) 1px, transparent 1.6px); background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(340px circle at var(--px, 50%) var(--py, 34%), #000 0, rgb(0 0 0 / .35) 45%, transparent 75%); mask-image: radial-gradient(340px circle at var(--px, 50%) var(--py, 34%), #000 0, rgb(0 0 0 / .35) 45%, transparent 75%); animation: login-fade 2400ms var(--ease-out) 600ms both; }
.login-spot { z-index: -2; background: radial-gradient(420px circle at var(--px, 50%) var(--py, 34%), rgb(79 143 219 / .24), rgb(111 180 54 / .1) 38%, rgb(247 106 12 / .07) 58%, transparent 76%); animation: login-fade 2400ms var(--ease-out) 300ms both; }
.login-desc { margin: 0; color: #c3c7cd; font-size: .95rem; letter-spacing: .01em; text-align: center; text-wrap: balance; animation: login-fade 1200ms var(--ease-out) 2000ms both; }
@keyframes login-fade { from { opacity: 0; } }

/* karta: ciemna tafla, po której krawędzi powoli obiega światło w trzech kolorach marki */
.login-card {
  position: relative; isolation: isolate; overflow: hidden; width: min(420px, 100%); padding: 1px; border-radius: 20px; background: rgb(255 255 255 / .09);
  box-shadow: 0 1px 2px rgb(0 0 0 / .3), 0 16px 40px rgb(0 0 0 / .36), 0 40px 96px rgb(0 0 0 / .3);
  animation: login-rise 900ms var(--ease-out) both;
}
.card-beam { position: absolute; z-index: 0; left: 50%; top: 50%; width: 180%; aspect-ratio: 1; translate: -50% -50%;
  background: conic-gradient(from 0deg, transparent 0 58%, var(--fest-orange) 68%, var(--fest-green) 79%, var(--fest-blue-d) 90%, transparent 100%); animation: card-beam 9s linear infinite; }
.card-bg { position: absolute; z-index: 1; inset: 1px; border-radius: 19px; background: linear-gradient(180deg, #2b2b2b, #202020 60%); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); }
.card-in { position: relative; z-index: 2; padding: 30px 26px 24px; }
@keyframes card-beam { to { rotate: 1turn; } }
.login-eyebrow { display: flex; align-items: center; gap: 5px; margin: 0 0 12px; font-size: .74rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #aab0b8; }
.login-eyebrow i { width: 7px; height: 7px; border-radius: 50%; background: var(--fest-orange); }
.login-eyebrow i:nth-child(2) { background: var(--fest-green); } .login-eyebrow i:nth-child(3) { background: var(--fest-blue-d); margin-right: 6px; }
.login-sub { margin: -12px 0 22px; color: #aab0b8; font-size: .95rem; }
.in-wrap { position: relative; display: block; }
.in-ico { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; fill: none; stroke: #8f959d; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; transition: stroke 160ms var(--ease-out); }
.in-wrap:focus-within .in-ico { stroke: var(--fest-orange); }
.login .in-wrap input { width: 100%; padding-left: 44px; }
.login .in-wrap input::placeholder { color: #7d838b; }
.login .in-eye { position: absolute; right: 6px; top: 50%; translate: 0 -50%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: #c3c7cd; font-size: .82rem; font-weight: 600; }
.login .in-wrap:has(.in-eye) input { padding-right: 70px; }
.login-caps { color: #ffcf8a; font-size: .85rem; margin-top: -8px; }
.login-caps[hidden] { display: none; }
.login-help { margin: 6px 0 0; text-align: center; color: #9aa0a8; font-size: .84rem; line-height: 1.45; }
.login button.primary .in-ico { position: static; translate: none; stroke: currentColor; stroke-width: 2.2; width: 18px; height: 18px; transition: transform 200ms var(--ease-out); }
.login button.primary[aria-busy=true] .in-ico { display: none; }
@keyframes login-rise { from { opacity: 0; transform: translateY(14px); } }

.login h1 { margin: 0 0 20px; font-size: 1.7rem; line-height: 1.1; letter-spacing: -.02em; color: #fff; }
.login form { display: grid; gap: 16px; }
.login label.f { gap: 7px; font-size: .88rem; color: #e6e8eb; }
.login input { min-height: 52px; padding: 11px 14px; font-size: 16px; color: #fff; background: rgb(0 0 0 / .34); border: 1px solid #6d737b; border-radius: 12px; caret-color: var(--fest-orange); transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out); }
.login input:focus { outline: none; }
.login input:focus-visible { outline: none; border-color: var(--fest-orange); background: rgb(0 0 0 / .46); box-shadow: 0 0 0 3px rgb(247 106 12 / .28); }
.login input:-webkit-autofill { -webkit-text-fill-color: #fff; box-shadow: 0 0 0 100px #1a1a1a inset; caret-color: #fff; }
.login form.is-bad input { border-color: #ff9c92; }

.login-err { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border-radius: 10px; background: rgb(214 48 40 / .16); border: 1px solid #ff9c92; color: #ffd2cc; font-size: .92rem; line-height: 1.4; }
.login-err[hidden] { display: none; }
.login-err::before { content: "!"; flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; background: #ff9c92; color: #3b0d09; font-weight: 800; font-size: .85rem; line-height: 1; }

.login button.primary { position: relative; overflow: hidden; min-height: 54px; margin-top: 4px; border-radius: 12px; font-weight: 700; font-size: 1.05rem; gap: 10px; background: linear-gradient(180deg, #ff7d1f, #f25f00); box-shadow: 0 1px 0 rgb(255 255 255 / .3) inset, 0 10px 28px rgb(247 106 12 / .28); transition: transform 140ms var(--ease-out), background-color 160ms var(--ease-out); }
.login button.primary:active { transform: scale(.98); }
.login button:focus-visible { outline: 3px solid var(--fest-blue-d); outline-offset: 3px; }
.login button.primary:disabled { cursor: progress; opacity: 1; box-shadow: none; }
.login button.primary:disabled:active { transform: none; }
.login-spin { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgb(30 30 30 / .3); border-top-color: #1e1e1e; animation: login-spin .7s linear infinite; }
.login button[aria-busy=true] .login-spin { display: block; }
@keyframes login-spin { to { transform: rotate(1turn); } }
@media (hover: hover) and (pointer: fine) {
  .login input:hover { border-color: #b3b8bf; }
  .login button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ff8e3a, #f76a0c); }
  .login button.primary:hover:not(:disabled) .in-ico { transform: translateX(4px); }
  .login .in-eye:hover { background: rgb(255 255 255 / .08); color: #fff; }
}
@media (hover: none) { .login button.primary:hover { background: var(--accent); } }

@media (min-width: 900px) {
  .login { grid-template-columns: minmax(0, 460px) minmax(0, 420px); justify-content: center; align-items: center; gap: 88px; padding-inline: 40px; }
  .login-lockup { width: 400px; }
  .login-brand { gap: 26px; }
  .login-desc { font-size: 1.05rem; }
  .card-in { padding: 38px 34px 30px; }
}
@media (max-height: 620px) and (max-width: 899px) { .login { align-content: start; gap: 18px; } .login-lockup { width: 140px; } }

/* kolejne wejście na ekran w tej samej sesji: bez intro */
.login-still :is(.login-word, .login-desc, .login-card, .login-aura, .login-grid, .login-spot) { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .login :is(.login-word, .login-desc, .login-card, .login-aura, .login-aura i, .login-spin, .sign-glow, .login-grid, .login-spot, .card-beam) { animation: none; }
  .login input, .login button.primary { transition: none; }
  .login button.primary:active { transform: none; }
  /* pasek zostaje widoczny, ale stoi: pełna trójkolorowa kreska */
  .loadbar i, .loadbar.on i { width: 100%; transform: none; animation: none; }
}

/* logowanie technika: logo FEST Serwis (inne proporcje pliku, ten sam kształt znaku w kolorach serwisu) */
.login-lockup.is-serwis { aspect-ratio: 720 / 784; }
.is-serwis .login-word { clip-path: inset(58.5% 0 0 0); }
.is-serwis .login-sign { left: 16.18%; top: 2.14%; width: 67.6%; }
.is-serwis .lk-b path { fill: #fff; }
