/* ==========================================================================
   cicija-motion.css — malo pokreta za cicija.bion.zone
   Ubaci NAKON postojećeg CSS-a:  <link rel="stylesheet" href="/cicija-motion.css">
   Radi na običnom semantičkom HTML-u (header, h1, h2, h3, p, ul, table, footer).
   Sve se gasi za korisnike s uključenim "smanji pokrete" (prefers-reduced-motion).
   ========================================================================== */

:root {
  /* Paleta Cicije */
  --cc-cream:  #FFF6E5;  /* pozadina */
  --cc-paper:  #FFFFFF;  /* kartice, tablice */
  --cc-ink:    #121826;  /* tekst, košarica */
  --cc-muted:  #3A4250;  /* sporedni tekst (kontrast 9:1 na kremi) */
  --cc-quiet:  #5B6472;  /* sitni natpisi, izvori (kontrast 5.6:1) */
  --cc-red:    #E8355A;  /* srce, glavni akcent, gumbi */
  --cc-yellow: #F2B544;  /* pleter, marker, istaknuta ušteda */
  --cc-gold:   #FFD23F;  /* Beg: kruna, kovanice (samo ukrasi) */
  --cc-brown:  #8A5A2B;  /* pleter, tanke linije */
  --cc-green:  #1F7A4D;  /* najjeftinije / ušteda u brojkama */
  --cc-line:   #E8DCC4;  /* razdjelnici */
  --cc-ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Boje (vrijede i bez animacija) ---------- */
body { background: var(--cc-cream); color: var(--cc-ink); }
h1, h2, h3 { color: var(--cc-ink); }
p, li { color: var(--cc-muted); }
footer, small, figcaption { color: var(--cc-quiet); }
a { color: var(--cc-ink); }
a:hover, a:focus-visible { color: var(--cc-red); }
::selection { background: var(--cc-yellow); color: var(--cc-ink); }
table { background: var(--cc-paper); border-radius: 12px; }
th { border-bottom: 2px solid var(--cc-ink); }
td { border-bottom: 1px solid var(--cc-line); }
.cc-cheapest, td.najjeftinije { color: var(--cc-green); font-weight: 700; }   /* najjeftinija trgovina */
.cc-promo { background: var(--cc-ink); color: #FFFFFF; border-radius: 24px; padding: 28px; }
.cc-promo p, .cc-promo b { color: #FFFFFF; }
.cc-promo a { color: var(--cc-yellow); }
button, .cc-btn { background: var(--cc-red); color: #FFFFFF; border: 0; border-radius: 999px; padding: .8em 1.4em; font-weight: 700; }

@media (prefers-reduced-motion: no-preference) {

  /* ---------- 1. Pozadina koja diše (dvije meke mrlje, crvena i žuta) ---------- */
  body { position: relative; isolation: isolate; }
  body::before,
  body::after {
    content: "";
    position: fixed;
    z-index: -1;
    width: 46vmax;
    height: 46vmax;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .16;
    pointer-events: none;
  }
  body::before {
    background: var(--cc-red);
    top: -18vmax; left: -14vmax;
    animation: cc-drift-a 22s ease-in-out infinite alternate;
  }
  body::after {
    background: var(--cc-yellow);
    bottom: -20vmax; right: -16vmax;
    opacity: .22;
    animation: cc-drift-b 26s ease-in-out infinite alternate;
  }
  @keyframes cc-drift-a { to { transform: translate(14vmax, 10vmax) scale(1.12); } }
  @keyframes cc-drift-b { to { transform: translate(-12vmax, -8vmax) scale(.92); } }

  /* ---------- 2. Ulaz zaglavlja i naslova (ta-pla-ta ritam: tri takta) ---------- */
  header        { animation: cc-rise .7s var(--cc-ease) both; }
  h1            { animation: cc-rise .8s var(--cc-ease) .12s both; }
  h1 + p,
  header + p    { animation: cc-rise .8s var(--cc-ease) .24s both; }

  @keyframes cc-rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }

  /* Naslov dobiva debelu žutu "marker" podcrtu koja se pojavi (radi i kad se naslov prelomi u više redaka) */
  h1 {
    text-decoration-line: underline;
    text-decoration-thickness: .22em;
    text-underline-offset: -.02em;
    text-decoration-skip-ink: none;
    text-decoration-color: transparent;
    animation: cc-rise .8s var(--cc-ease) .12s both,
               cc-marker .9s var(--cc-ease) .9s forwards;
  }
  @keyframes cc-marker { to { text-decoration-color: rgba(242, 181, 68, .85); } }

  /* ---------- 3. Sekcije se otkrivaju dok skrolaš (scroll-driven, bez JS-a) ---------- */
  @supports (animation-timeline: view()) {
    h2, h3, main p, main ul, main ol, table, blockquote, footer {
      animation: cc-reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 28%;
    }
    @keyframes cc-reveal {
      from { opacity: 0; transform: translateY(28px); }
      to   { opacity: 1; transform: none; }
    }
  }

  /* H2 dobiva malo srce koje "kucne" kad uđe u ekran */
  h2::before {
    content: "";
    display: inline-block;
    width: .55em; height: .5em;
    margin-right: .4em;
    vertical-align: .08em;
    background: var(--cc-red);
    clip-path: path("M5.5 10 C5.5 10 0 6.6 0 3.3 C0 1.5 1.3 .3 2.8 .3 C3.9 .3 4.9 1 5.5 2 C6.1 1 7.1 .3 8.2 .3 C9.7 .3 11 1.5 11 3.3 C11 6.6 5.5 10 5.5 10 Z");
    transform-origin: center;
    animation: cc-beat 1.6s ease-in-out infinite;
  }
  h2:nth-of-type(even)::before { background: var(--cc-yellow); animation-delay: .4s; }
  @keyframes cc-beat {
    0%, 60%, 100% { transform: scale(1); }
    10%           { transform: scale(1.25); }
    20%           { transform: scale(.95); }
    30%           { transform: scale(1.15); }
  }

  /* ---------- 4. Poveznice: podcrta koja klizne ---------- */
  a {
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 100% 1px;
    transition: background-size .35s var(--cc-ease), color .2s;
  }
  a:hover, a:focus-visible {
    background-size: 100% 3px;
    color: var(--cc-red);
  }

  /* ---------- 5. Tablice cijena: red se lagano istakne ---------- */
  table tr { transition: background-color .25s, transform .25s var(--cc-ease); }
  table tbody tr:hover {
    background-color: rgba(242, 181, 68, .18);
    transform: translateX(4px);
  }

  /* ---------- 6. Klase koje možeš dodati za još pokreta (opcionalno) ---------- */

  /* <p class="cc-loading">Učitavam današnje cjenike</p> → tri točke u ritmu ta-pla-ta */
  .cc-loading::after {
    content: "";
    display: inline-block;
    width: 1.6em;
    text-align: left;
    animation: cc-dots 1.2s steps(4, end) infinite;
  }
  @keyframes cc-dots {
    0%   { content: ""; }
    25%  { content: "·"; }
    50%  { content: "··"; }
    75%  { content: "···"; }
  }

  /* Wordmark: <span class="cc-word"><b>ci</b><i class="cc-h"></i><b>ci</b><i class="cc-h y"></i><b>ja</b></span>
     slogovi poskoče jedan za drugim, srca kucaju */
  .cc-word { display: inline-flex; align-items: center; gap: .18em; }
  .cc-word b { display: inline-block; animation: cc-hop 2.4s var(--cc-ease) infinite; }
  .cc-word b:nth-of-type(2) { animation-delay: .18s; }
  .cc-word b:nth-of-type(3) { animation-delay: .36s; }
  .cc-h {
    display: inline-block; width: .42em; height: .38em; background: var(--cc-red);
    clip-path: path("M5.5 10 C5.5 10 0 6.6 0 3.3 C0 1.5 1.3 .3 2.8 .3 C3.9 .3 4.9 1 5.5 2 C6.1 1 7.1 .3 8.2 .3 C9.7 .3 11 1.5 11 3.3 C11 6.6 5.5 10 5.5 10 Z");
    animation: cc-beat 1.6s ease-in-out infinite;
  }
  .cc-h.y { background: var(--cc-yellow); animation-delay: .4s; }
  @keyframes cc-hop {
    0%, 30%, 100% { transform: none; }
    12%           { transform: translateY(-.12em); }
  }

  /* Velika brojka uštede: <span class="cc-savings">…</span> → lagani "pulse" kad se pojavi */
  .cc-savings {
    display: inline-block;
    animation: cc-pop .6s var(--cc-ease) both, cc-glow 2.8s ease-in-out 1s infinite;
  }
  @keyframes cc-pop  { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes cc-glow { 50% { text-shadow: 0 0 .35em rgba(242, 181, 68, .55); } }

  /* "Cicija u džepu" blok: <div class="cc-promo">…</div> → kartica koja lebdi */
  .cc-promo {
    animation: cc-float 5s ease-in-out infinite;
    transition: transform .3s var(--cc-ease), box-shadow .3s;
  }
  .cc-promo:hover { box-shadow: 0 18px 40px rgba(18, 24, 38, .15); }
  @keyframes cc-float { 50% { transform: translateY(-6px); } }
}

/* ==========================================================================
   7. SCENA: Beg i Cicija (crtić u petlji)
   HTML je u cicija-scena.html; zalijepi ga gdje želiš.
   ========================================================================== */
.cc-scena {
  position: relative;
  height: 240px;
  margin: 40px 0;
  overflow: hidden;
  container-type: inline-size;
  border-radius: 24px;
  background: linear-gradient(#FFF6E5 0 78%, #F7E7C6 78%);
}
.cc-pod { z-index: 0; position: absolute; left: 0; right: 0; bottom: 52px; height: 2px; background: var(--cc-line); }
.cc-beg { z-index: 1; position: absolute; left: 0; bottom: 30px; width: 130px; height: 173px; }
.cc-beg-roll, .cc-beg-svg, .cc-cic-svg { display: block; width: 100%; height: 100%; }
.cc-cic { z-index: 2; position: absolute; bottom: 24px; left: 78%; width: 120px; height: 160px; }
.cc-coin { position: absolute; width: 26px; height: 26px; left: 50px; top: 10px; opacity: 0; }
.cc-coin svg { width: 100%; height: 100%; }
.cc-note { stroke: #121826; stroke-width: 3; stroke-linecap: round; fill: none; }

@media (prefers-reduced-motion: no-preference) {

  /* Beg se kotrlja s kraja na kraj, stane, pa natrag */
  .cc-beg { animation: cc-beg-path 12s cubic-bezier(.45, 0, .55, 1) infinite; }
  @keyframes cc-beg-path {
    0%       { transform: translateX(-10px); }
    42%, 50% { transform: translateX(calc(100cqw - 150px)); }
    92%,100% { transform: translateX(-10px); }
  }
  .cc-beg-roll {
    transform-origin: 52% 64%;
    animation: cc-beg-spin 12s cubic-bezier(.45, 0, .55, 1) infinite;
  }
  @keyframes cc-beg-spin {
    0%       { transform: rotate(0deg); }
    42%      { transform: rotate(1080deg); }
    44%      { transform: rotate(1070deg) translateY(-14px); }  /* poskoči od veselja */
    46%, 50% { transform: rotate(1080deg); }
    92%,100% { transform: rotate(0deg); }
  }
  /* Kovanice mu ispadaju dok se kotrlja (raskalašeno troši) */
  .cc-coin { animation: cc-coin-pop 1.5s ease-out infinite; }
  .cc-coin.c2 { left: 70px; animation-delay: .5s; }
  .cc-coin.c3 { left: 30px; animation-delay: 1s; }
  @keyframes cc-coin-pop {
    0%   { opacity: 0; transform: translate(0, 40px) scale(.6) rotate(0); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-30px, -50px) scale(1) rotate(-200deg); }
  }

  /* Cicija iskoči, promatra, zapisuje, nestane pa se pojavi na drugom mjestu */
  .cc-cic { animation: cc-cic-peek 12s ease-in-out infinite; }
  @keyframes cc-cic-peek {
    0%, 20%   { left: 6%;  transform: translateY(120%); }   /* Beg kreće udesno, Cicija čeka iza njega */
    25%, 46%  { left: 6%;  transform: translateY(0); }      /* iskoči lijevo, gleda kako Beg troši */
    51%, 64%  { left: 6%;  transform: translateY(120%); }
    65%       { left: 78%; transform: translateY(120%); }
    70%, 90%  { left: 78%; transform: translateY(0); }      /* Beg se kotrlja natrag, ona iskoči desno */
    95%, 100% { left: 78%; transform: translateY(120%); }
  }
  /* Oči prate Bega */
  .cc-eyes { animation: cc-look 12s ease-in-out infinite; }
  @keyframes cc-look {
    0%, 30%  { transform: translateX(3px); }
    40%, 48% { transform: translateX(4px); }
    70%, 80% { transform: translateX(-3px); }
    88%,100% { transform: translateX(-4px); }
  }
  /* Olovka škraba, retci se ispisuju jedan po jedan */
  .cc-pen { transform-box: fill-box; transform-origin: 0% 100%; animation: cc-scribble .35s ease-in-out infinite alternate; }
  @keyframes cc-scribble { from { transform: rotate(-6deg); } to { transform: rotate(8deg) translateX(3px); } }
  .cc-note { stroke-dasharray: 40; stroke-dashoffset: 40; animation: cc-write 6s linear infinite; }
  .cc-note.l2 { animation-delay: .6s; }
  .cc-note.l3 { animation-delay: 1.2s; }
  .cc-note.l4 { animation-delay: 1.8s; }
  @keyframes cc-write {
    0%       { stroke-dashoffset: 40; }
    12%, 80% { stroke-dashoffset: 0; }
    100%     { stroke-dashoffset: 40; }
  }
}
