/* MOTION_R01 · OPTIC_SHOP_PREMIUM_MOTION_AND_INTERACTIVE_EXPERIENCE_R01
   Jedan sistem pokreta za ceo sajt. Pravila:
   - samo transform, opacity, clip-path i mask (bez animiranja layout svojstava);
   - pokret vezan za skrol ide kroz CSS scroll-driven animacije (animation-timeline), bez scroll slušaoca i bez otmice skrola;
   - bez podrške ili uz prefers-reduced-motion: sajt izgleda tačno kao pre ove runde (sve je završno stanje);
   - zaključana sekcija HOME_VISIT (.r5-visit) se ne dira.
   Tempo: mikro 160 ms · UI 280 ms · ulaz 900-1100 ms. Krive: --mx-out (izlaz, brz početak) i --mx-io (pomeranje na ekranu). */
:root {
  --mx-out: cubic-bezier(.16, 1, .3, 1);
  --mx-io: cubic-bezier(.65, 0, .35, 1);
  --mx-fast: 160ms;
  --mx-ui: 280ms;
}
.mx-lens__blur { display: none; }

/* ------------------------------------------------ 1 · mikro: dugmad i linkovi (osećaj pritiska, crtanje podvlake) */
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: transform var(--mx-fast) var(--mx-out), background-color var(--mx-ui) ease, color var(--mx-ui) ease, border-color var(--mx-ui) ease; }
  .btn:active { transform: scale(.97); }
  .r5-visit .btn:active { transform: none; }   /* HOME_VISIT: zaključano */
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .r5-btn--red:hover { transform: translateY(-2px); }
  .r5-visit .r5-btn--red:hover { transform: none; }
  .r6-gl__more, .r6-hub__go, .art__next { transition: color var(--mx-ui) ease; }
  .r6-gl__more { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1.5px no-repeat; transition: background-size .45s var(--mx-out); }
  .r6-gl__a:hover .r6-gl__more { background-size: 100% 1.5px; }
}

/* ------------------------------------------------ 2 · HERO: režiran ulaz (vreme) + odlazak sa skrolom (scroll-driven) */
.mx-w { display: inline-block; overflow: clip; padding-block: .14em .1em; margin-block: -.14em -.1em; vertical-align: top; }
.mx-w > span { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .r5-hero__copy > .r5-hero__h { animation: none; }
  .mx-w > span { animation: mx-up 1.05s var(--mx-out) both; }
  .mx-w:nth-child(1) > span { animation-delay: .15s; }
  .mx-w:nth-child(2) > span { animation-delay: .23s; }
  .mx-w:nth-child(3) > span { animation-delay: .31s; }
  .mx-w:nth-child(4) > span { animation-delay: .39s; }
  .mx-w:nth-child(5) > span { animation-delay: .47s; }
  .r5-hero__copy > .r5-hero__lead { animation-delay: .62s; }
  .r5-hero__copy > .r5-hero__cta { animation-delay: .74s; }
  .r5-hero__film .hero__poster img, .r5-hero__film .hero__video { animation: mx-settle 2.2s var(--mx-out) both; }
  @keyframes mx-up { from { transform: translateY(108%); } }
  @keyframes mx-settle { from { transform: scale(1.09); } }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* hero: pozadina zaostaje, tekst odlazi brže (dubina bez otmice skrola) */
    .r5-hero { view-timeline: --mx-hero block; }
    .r5-hero__film { animation: mx-film linear both; animation-timeline: --mx-hero; animation-range: exit 0% exit 100%; }
    .r5-hero__copy { animation: mx-copy linear both; animation-timeline: --mx-hero; animation-range: exit 0% exit 75%; }
    @keyframes mx-film { to { transform: translateY(22%) scale(1.07); } }
    @keyframes mx-copy { to { transform: translateY(-10vh); } }
    @media (max-width: 959px) { .r5-hero__copy { animation: none; } }   /* telefon: tekst i dugmad hero-a ostaju puni dok su na ekranu */

    /* „Vračar": kompozicija ostaje nepomična (owner 27.10.: lik mora biti ceo, ne isečen) */

    /* ------------------------------------------------ 3 · naslovi: maskirani ulaz bloka (samo veliki naslovi sekcija) */
    .r5-paths__h, .r5-camp__h, .r5-proc .r5-h2, .r5-svc .r5-h2, .r6-cta__h, .r6-hub__q, .r9-rxs__h, .r6-faq__h {
      animation: mx-wipe linear both; animation-timeline: view(); animation-range: entry 5% cover 32%;
    }
    @keyframes mx-wipe { from { clip-path: inset(0 0 100% 0); transform: translateY(.4em); } to { clip-path: inset(-.2em 0 -.3em 0); transform: none; } }

    /* ------------------------------------------------ 4 · SIGNATURE: izoštravanje (kampanja na početnoj)
       Kadar ulazi van fokusa; dok se sekcija uvodi, zamućen sloj nestaje i lice postaje oštro, kao kad se sočivo namesti.
       Animira se samo opacity zamućenog sloja i blag zum oštrog kadra. Owner 27.10.: bez maske u obliku naočara. */
    .mx-lens { position: relative; view-timeline: --mx-lens block; overflow: clip; }
    .mx-lens__blur { display: block; position: absolute !important; inset: 0; z-index: 2; aspect-ratio: auto !important; min-height: 0 !important;
      height: 100%; pointer-events: none; animation: mx-focus linear both; animation-timeline: --mx-lens; animation-range: entry 35% cover 55%; }
    .mx-lens__blur img { filter: blur(22px) saturate(.6) brightness(.8); transform: scale(1.06); }
    .mx-lens > .r5-camp__fig:not(.mx-lens__blur) img { animation: mx-breathe linear both; animation-timeline: --mx-lens; animation-range: entry 35% cover 55%; }
    .r5-camp__copy { z-index: 3; }
    @keyframes mx-focus { 0%, 15% { opacity: 1; } 100% { opacity: 0; } }
    @keyframes mx-breathe { from { scale: 1.05; } to { scale: 1; } }

    /* ------------------------------------------------ 5 · kartice: slika se otkriva odozdo i smiruje (dodir i miš isto) */
    .r5-path__fig:not(.is-cutout), .r6-gl__fig, .r9-rxcard, .r8-hub__fig, .r6-pagefig, .r5-pagefig {
      animation: mx-card linear both; animation-timeline: view(); animation-range: entry 0% cover 35%;
    }
    @keyframes mx-card { from { clip-path: inset(18% 0 0 0); opacity: .35; } to { clip-path: inset(0); opacity: 1; } }
    .r5-path__fig:not(.is-cutout) img, .r6-gl__fig:not(.is-cutout) img, .r8-hub__fig img {
      animation: mx-cardimg linear both; animation-timeline: view(); animation-range: entry 0% exit 100%;
    }
    @keyframes mx-cardimg { from { translate: 0 -4%; scale: 1.08; } to { translate: 0 3%; scale: 1.02; } }

    /* ------------------------------------------------ 6 · završni poziv na podstranama: bordo/grafitni panel se otvara, podaci su sve vreme vidljivi */
    .r6-cta { animation: mx-open linear both; animation-timeline: view(); animation-range: entry 0% entry 85%; }
    @keyframes mx-open { from { clip-path: inset(5% 2.5% 0 2.5% round 6px); } to { clip-path: inset(0 round 0); } }
  }
}

/* kartice na mišu: svetlo + blag pomak (dodir dobija gornji scroll režim, hover nije jedini put do sadržaja) */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .r5-path::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
    background: radial-gradient(120% 70% at 50% 0%, rgb(255 255 255 / .14), transparent 60%); transition: opacity .5s var(--mx-out); }
  .r5-path:hover::before { opacity: 1; }
  .r5-path .slot.is-filled img { transition: transform .9s var(--mx-out); }
  .r5-path:hover .slot.is-filled img { transform: scale(1.05) translateY(-1.5%); }
  .r6-gl__fig img { transition: transform .9s var(--mx-out); }
  .r6-gl__a:hover .r6-gl__fig img { transform: scale(1.04); }
}

/* ------------------------------------------------ 7 · USLUGE: sekvenca okvir → staklo → završni detalj (desktop; sklapa motion.js) */
@media (min-width: 960px) {
  .mx-seq { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: clamp(40px, 5vw, 96px);
    padding: clamp(40px, 5vw, 88px) var(--edge); background: var(--bone); }
  .mx-seq__stage { position: sticky; top: calc(var(--hdr) + 24px); height: calc(100svh - var(--hdr) - 48px); align-self: start;
    overflow: clip; background: var(--graphite); border-radius: 4px; }
  .mx-seq__stage > figure { position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; aspect-ratio: auto !important; min-height: 0 !important;
    clip-path: inset(100% 0 0 0); animation: none !important; opacity: 1; }
  .mx-seq__stage > figure picture { display: block; height: 100%; }
  .mx-seq__stage > figure img { width: 100%; height: 100%; object-fit: cover; animation: none !important; translate: none; scale: none; }
  .mx-seq__stage > figure.is-on { clip-path: inset(0); z-index: 2; }
  .mx-seq__stage > figure.was-on { clip-path: inset(0); z-index: 1; }
  .mx-seq__cap { position: absolute; z-index: 3; left: 28px; right: 28px; bottom: 24px; display: flex; align-items: end; justify-content: space-between;
    color: var(--on-dark); font: var(--h-wght) clamp(1.5rem, 1rem + 1vw, 2.25rem)/1 var(--display); font-stretch: var(--h-stretch); text-shadow: 0 1px 18px rgb(0 0 0 / .45); }
  .mx-seq__ticks { display: flex; gap: 8px; }
  .mx-seq__ticks i { display: block; width: 28px; height: 3px; border-radius: 2px; background: rgb(244 242 239 / .35); }
  .mx-seq__ticks i.is-on { background: var(--red); }
  .mx-seq__rows { display: grid; }
  .mx-seq .r6-hub__row { min-height: 74svh; display: flex !important; flex-direction: column; justify-content: center;
    padding: 6vh 0 !important; margin: 0 !important; background: none !important; color: var(--ink) !important; border-top: 1px solid var(--line); }
  .mx-seq .r6-hub__row:first-child { border-top: 0; }
  .mx-seq .r6-hub__row > * { grid-area: auto !important; width: auto !important; max-width: 36rem; }
  .mx-seq .r6-hub__q { font-size: clamp(2.25rem, 1rem + 2.6vw, 4rem); }
  .mx-seq .r6-hub__row:not(.is-on) { opacity: .72; }
  @media (prefers-reduced-motion: no-preference) {
    .mx-seq__stage > figure { transition: clip-path .95s var(--mx-io); }
    .mx-seq__stage > figure img { transform: scale(1.1); transition: transform 1.6s var(--mx-out); }
    .mx-seq__stage > figure.is-on img { transform: none; }
    .mx-seq__ticks i { transition: background-color var(--mx-ui) ease; }
    .mx-seq .r6-hub__row { transition: opacity .5s var(--mx-out); }
    .mx-seq__cap span { display: inline-block; animation: mx-cap .7s var(--mx-out) both; }
    @keyframes mx-cap { from { opacity: 0; transform: translateY(12px); } }
  }
}

/* ------------------------------------------------ 8 · prelaz između strana (View Transitions; bez podrške = običan klik) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: mx-vt-out .2s var(--mx-io) both; }
  ::view-transition-new(root) { animation: mx-vt-in .42s var(--mx-out) both; }
  @keyframes mx-vt-out { to { opacity: 0; } }
  @keyframes mx-vt-in { from { opacity: 0; transform: translateY(12px); } }
}
