/* ============================================================
   lukaszstocki.pl — microinteractions & UX polish
   All motion respects prefers-reduced-motion.
   Depends on design tokens (CSS vars) defined in index.html.
   ============================================================ */

/* ---------- 1. Global reduced-motion guard ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 2. Smooth scroll ---------- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* sticky header offset */
}
@media (max-width: 767px) {
  html { scroll-padding-top: 64px; }
}

/* ---------- 3. Focus states (a11y + tokens) ---------- */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- 6. Cursor / pointer states ---------- */
button, a, [role="button"], summary { cursor: pointer; }
input, textarea, select { cursor: text; }
input[type="checkbox"], input[type="radio"] { cursor: pointer; }
[disabled], [aria-disabled="true"] { cursor: not-allowed; }

/* ============================================================
   Header polish
   ============================================================ */
.site-header.is-scrolled {
  box-shadow: 0 1px 0 rgba(15, 27, 36, 0.06);
}
.wordmark { transition: color .18s ease; }
.wordmark:hover { color: var(--accent); }

/* ============================================================
   5. Scroll-triggered reveal
   .js-anim is added by JS, so no-JS users never see opacity:0.
   ============================================================ */
.js-anim .reveal-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 600ms ease,
    transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js-anim .reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Hero load sequence
   ============================================================ */
.js-anim .hero-anim {
  opacity: 0;
  transform: translateY(16px);
}
.js-anim .hero-anim.is-in {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--hero-delay, 0ms);
}
.js-anim .hero-photo.hero-anim {
  transform: scale(0.96);
}
.js-anim .hero-photo.hero-anim.is-in {
  transform: scale(1);
}

/* ============================================================
   Problem card — icon micro-twist on card hover
   ============================================================ */
.problem .problem-icon {
  transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), color .2s ease;
}
.problem:hover .problem-icon {
  transform: rotate(-8deg) translateY(-2px);
}

/* ============================================================
   Buttons — press feedback + arrow already in base CSS
   ============================================================ */
.btn-primary:active { transform: translateY(0) scale(0.985); }
.btn-secondary:active { transform: scale(0.99); }

/* ============================================================
   Case study — image zoom on card hover
   ============================================================ */
.case-media {
  overflow: hidden;
}
.case-media picture,
.case-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
}
.case-card:hover .case-media img {
  transform: scale(1.04);
}

/* ============================================================
   Process timeline
   ============================================================ */
/* Connecting line draws in on first view */
.js-anim .process-grid::before {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}
.js-anim .process-grid.is-drawn::before {
  transform: scaleX(1);
}
@media (max-width: 959px) {
  .js-anim .process-grid::before {
    transform: scaleY(0);
    transform-origin: top center;
  }
  .js-anim .process-grid.is-drawn::before {
    transform: scaleY(1);
  }
}

/* Step enters with stagger (JS sets --reveal-delay) */
.js-anim .step.reveal-on-scroll { transition-delay: var(--reveal-delay, 0ms); }

/* Number badge grows on step hover */
.step-num { transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .25s ease; }
.step:hover .step-num { transform: scale(1.08); }

/* ============================================================
   FAQ — opacity fade synced with max-height
   (max-height handled by existing inline JS; chevron in base CSS)
   ============================================================ */
.faq-a {
  opacity: 0;
  transition:
    max-height .28s cubic-bezier(0.4, 0, 0.2, 1),
    opacity .28s cubic-bezier(0.4, 0, 0.2, 1);
}
.faq-q[aria-expanded="true"] + .faq-a { opacity: 1; }

/* ============================================================
   Contact form
   ============================================================ */
.contact-form .field input,
.contact-form .field textarea {
  transition:
    border-color .15s ease,
    box-shadow .15s ease,
    background-color .15s ease;
}
.contact-form .field input:focus-visible,
.contact-form .field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* Inline validation error */
.contact-form .field.has-error input,
.contact-form .field.has-error textarea {
  border-color: #E0795F;
}
.contact-form .field.has-error input:focus-visible,
.contact-form .field.has-error textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(224, 121, 95, 0.22);
}
.field-error {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: #F0A892;
  opacity: 0;
  animation: fieldErrIn 200ms ease forwards;
}
.consent.has-error label { color: #F0A892; }
@keyframes fieldErrIn { to { opacity: 1; } }

/* Shake on invalid */
.shake { animation: shake 300ms ease; }
@keyframes shake {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-3px); }
  50%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

/* Loading state on submit button */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}
.btn .spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(250, 250, 247, 0.4);
  border-top-color: var(--bg-base);
  display: inline-block;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Success message */
.form-success {
  display: none;
  flex-direction: column;
  gap: 14px;
  background: #15212B;
  border: 1px solid #2A3742;
  border-radius: var(--radius-hero);
  padding: 40px;
  opacity: 0;
}
.form-success.is-shown {
  display: flex;
  animation: fadeUp 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.contact-form.is-hidden {
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
}
.form-success .check-badge {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.form-success .check-badge svg { width: 26px; height: 26px; color: var(--bg-base); }
.form-success h3 {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-on-dark);
  margin: 0;
}
.form-success p {
  font-size: 15px;
  line-height: 1.6;
  color: #B0B8C2;
  margin: 0;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Sticky bottom CTA (mobile only)
   ============================================================ */
.sticky-cta {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 45;
  display: none;
  transform: translateY(140%);
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sticky-cta.is-shown { transform: translateY(0); }
.sticky-cta .btn {
  width: 100%;
  box-shadow: 0 6px 24px rgba(15, 27, 36, 0.22);
}
@media (max-width: 767px) {
  .sticky-cta { display: block; }
}
