/* ============================================================
   Kortelo · Premium effects layer (Faza C2)
   - Custom cursor (mix-blend-mode: difference)
   - 3D card tilt
   - Animated SVG paths
   - Marquee scroll
   - Page transitions
   - Cookie banner
   ============================================================ */

/* ===== Custom cursor ===== */
.cursor-dot,
.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: difference;
    will-change: transform;
}
.cursor-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffffff;
    transform: translate3d(-50%, -50%, 0);
    transition: width 0.18s ease, height 0.18s ease, background 0.18s ease;
}
.cursor-ring {
    width: 40px;
    height: 40px;
    border: 1px solid #ffffff;
    border-radius: 50%;
    transform: translate3d(-50%, -50%, 0);
    transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.25s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.18s ease,
                border-radius 0.18s ease,
                background 0.18s ease;
}
.cursor-ring.is-text   { width: 60px; height: 60px; }
.cursor-ring.is-link   { width: 56px; height: 56px; background: #ffffff; }
.cursor-dot.is-link    { width: 12px; height: 12px; }
.cursor-ring.is-input  { width: 4px;  height: 28px; border-radius: 2px; }
.cursor-ring.is-click  { width: 28px; height: 28px; }

@media (max-width: 1023px) {
    .cursor-dot, .cursor-ring { display: none !important; }
}
.cursor-active body {
    cursor: none;
}
.cursor-active a,
.cursor-active button,
.cursor-active label,
.cursor-active input,
.cursor-active textarea,
.cursor-active select,
.cursor-active [role="button"] {
    cursor: none;
}

/* ===== 3D card tilt ===== */
.tilt-card {
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.tilt-card.is-tilting {
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

/* ============================================================
   Module mockups — self-contained (no JS-computed dasharray)
   Trigger: parent gets .is-visible via IntersectionObserver
   ============================================================ */

/* Generic stroke-draw helper using fixed dash budget (works without JS
   measurement of getTotalLength). 600 is enough for our small viewports. */
.mockup .draw {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}
.mockup.is-visible .draw {
    animation: mockup-draw 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes mockup-draw { to { stroke-dashoffset: 0; } }

.mockup.is-visible .draw-d-1 { animation-delay: 0.05s; }
.mockup.is-visible .draw-d-2 { animation-delay: 0.25s; }
.mockup.is-visible .draw-d-3 { animation-delay: 0.45s; }
.mockup.is-visible .draw-d-4 { animation-delay: 0.65s; }
.mockup.is-visible .draw-d-5 { animation-delay: 0.85s; }

/* End-dot pulse on chart */
.mockup .end-dot { transform-origin: center; opacity: 0; }
.mockup.is-visible .end-dot {
    animation: end-dot-in 0.4s 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards,
               end-dot-pulse 1.8s 1.8s ease-in-out infinite;
}
@keyframes end-dot-in    { to { opacity: 1; } }
@keyframes end-dot-pulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%      { transform: scale(1.5); opacity: 0.6; }
}

/* Network nodes — pop in one by one */
.mockup .node {
    opacity: 0;
    transform-origin: center;
    transform: scale(0);
}
.mockup.is-visible .node {
    animation: node-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mockup.is-visible .node-1 { animation-delay: 0.0s; }
.mockup.is-visible .node-2 { animation-delay: 0.15s; }
.mockup.is-visible .node-3 { animation-delay: 0.30s; }
.mockup.is-visible .node-4 { animation-delay: 0.45s; }
.mockup.is-visible .node-5 { animation-delay: 0.60s; }
@keyframes node-pop { to { opacity: 1; transform: scale(1); } }

.mockup .net-line { stroke-dasharray: 200; stroke-dashoffset: 200; }
.mockup.is-visible .net-line {
    animation: mockup-draw 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mockup.is-visible .net-line-1 { animation-delay: 0.7s; }
.mockup.is-visible .net-line-2 { animation-delay: 0.8s; }
.mockup.is-visible .net-line-3 { animation-delay: 0.9s; }
.mockup.is-visible .net-line-4 { animation-delay: 1.0s; }
.mockup.is-visible .node-1 { animation: node-pop 0.5s forwards, hub-pulse 2s 1.5s ease-in-out infinite; }
@keyframes hub-pulse {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(10,10,10,0)); }
    50%      { filter: drop-shadow(0 0 6px rgba(10,10,10,0.5)); }
}

/* Chat mockup — message bubbles fade in sequentially */
.mockup .chat-msg { opacity: 0; transform: translateY(8px); }
.mockup.is-visible .chat-msg {
    animation: chat-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mockup.is-visible .chat-msg-1 { animation-delay: 0.1s; }
.mockup.is-visible .chat-msg-2 { animation-delay: 0.6s; }
.mockup.is-visible .chat-msg-3 { animation-delay: 1.6s; }
@keyframes chat-in { to { opacity: 1; transform: translateY(0); } }

/* Hide chat-msg-3 until typing finishes */
.mockup .chat-msg-3 { display: none; }
.mockup.is-visible .chat-msg-3 { display: flex; }
.mockup.is-visible .chat-typing { animation: chat-typing-fade 0.4s 1.5s forwards; }
@keyframes chat-typing-fade { to { opacity: 0; height: 0; padding: 0; margin: 0; overflow: hidden; } }

/* KSeF process — 4 steps appear sequentially with status chips */
.mockup .ksef-step {
    opacity: 0;
    transform: translateY(6px);
}
.mockup.is-visible .ksef-step {
    animation: ksef-step-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mockup.is-visible .ksef-step-1 { animation-delay: 0.0s; }
.mockup.is-visible .ksef-step-2 { animation-delay: 0.8s; }
.mockup.is-visible .ksef-step-3 { animation-delay: 1.6s; }
.mockup.is-visible .ksef-step-4 { animation-delay: 2.4s; }
@keyframes ksef-step-in { to { opacity: 1; transform: translateY(0); } }

.mockup .ksef-status {
    opacity: 0.4;
    transition: opacity 0.4s ease;
}
.mockup.is-visible .ksef-step-1 .ksef-status,
.mockup.is-visible .ksef-step-2 .ksef-status,
.mockup.is-visible .ksef-step-3 .ksef-status,
.mockup.is-visible .ksef-step-4 .ksef-status { opacity: 1; }

.mockup.is-visible .ksef-pulse {
    animation: ksef-pulse 2s 3.2s ease-in-out infinite;
}
@keyframes ksef-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(10,10,10,0.45); }
    50%      { box-shadow: 0 0 0 6px rgba(10,10,10,0); }
}

/* Stock bars — fill from bottom + arrow drift */
.mockup .bar-fill {
    transform: scaleY(0);
    transform-origin: bottom;
}
.mockup.is-visible .bar-fill {
    animation: bar-grow 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mockup.is-visible .bar-fill:nth-child(1) { animation-delay: 0.05s; }
.mockup.is-visible .bar-fill:nth-child(2) { animation-delay: 0.10s; }
.mockup.is-visible .bar-fill:nth-child(3) { animation-delay: 0.15s; }
.mockup.is-visible .bar-fill:nth-child(4) { animation-delay: 0.20s; }
.mockup.is-visible .bar-fill:nth-child(5) { animation-delay: 0.25s; }
.mockup.is-visible .bar-fill:nth-child(6) { animation-delay: 0.30s; }
.mockup.is-visible .bar-fill:nth-child(7) { animation-delay: 0.35s; }
.mockup.is-visible .bar-fill:nth-child(8) { animation-delay: 0.40s; }
@keyframes bar-grow { to { transform: scaleY(1); } }

.mockup .trend-arrow {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}
.mockup.is-visible .trend-arrow {
    animation: mockup-draw 1.0s 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Puzzle pieces — snap into place */
.mockup .puzzle-piece {
    opacity: 0;
    transform-origin: center;
}
.mockup.is-visible .puzzle-piece {
    animation: puzzle-snap 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mockup.is-visible .puzzle-piece-1 { animation-delay: 0.0s; }
.mockup.is-visible .puzzle-piece-2 { animation-delay: 0.15s; }
.mockup.is-visible .puzzle-piece-3 { animation-delay: 0.30s; }
.mockup.is-visible .puzzle-piece-4 { animation-delay: 0.45s; }
@keyframes puzzle-snap {
    0%   { opacity: 0; transform: translate(var(--px, 0), var(--py, 0)) scale(0.6); }
    60%  { opacity: 1; transform: translate(0, 0) scale(1.06); }
    100% { opacity: 1; transform: translate(0, 0) scale(1); }
}
.mockup.is-visible .puzzle-glow {
    animation: puzzle-glow 1.5s 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes puzzle-glow {
    0%   { box-shadow: 0 0 0 0 rgba(10,10,10,0); }
    50%  { box-shadow: 0 0 30px 6px rgba(10,10,10,0.18); }
    100% { box-shadow: 0 0 0 0 rgba(10,10,10,0); }
}

/* ===== Marquee — single-row infinite scroll left ===== */
.marquee {
    overflow: hidden;
    background: #ffffff;
    color: #0a0a0a;
    border-top: 1px solid #f5f5f5;
    border-bottom: 1px solid #f5f5f5;
}
.marquee-track {
    display: flex;
    white-space: nowrap;
    will-change: transform;
    animation: marquee-left 60s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }

.marquee-item {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    padding: 1.5rem 0;
    flex-shrink: 0;
    color: #404040;
}
.marquee-sep {
    flex-shrink: 0;
    padding: 1.5rem 1.25rem;
    color: #d4d4d4;
}

@keyframes marquee-left {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ===== Page transitions ===== */
@keyframes page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
main#main {
    animation: page-enter 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* View Transitions API (Chrome 111+, Safari 18+) */
@view-transition {
    navigation: auto;
}
::view-transition-old(root) {
    animation: 200ms cubic-bezier(0.22, 1, 0.36, 1) both fade-out;
}
::view-transition-new(root) {
    animation: 300ms cubic-bezier(0.22, 1, 0.36, 1) both fade-in-up;
}
@keyframes fade-out {
    to { opacity: 0; }
}
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Cookie banner ===== */
.cookie-banner {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    max-width: 400px;
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 1rem;
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.18);
    z-index: 80;
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.4s ease;
    font-size: 0.875rem;
    line-height: 1.55;
    color: #404040;
}
.cookie-banner.is-visible {
    transform: translateY(0);
    opacity: 1;
}
.cookie-banner.is-dismissing {
    transform: translateY(120%);
    opacity: 0;
}
.cookie-banner a {
    text-decoration: underline;
    color: #0a0a0a;
}
.cookie-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.cookie-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.cookie-btn-accept {
    background: #0a0a0a;
    color: #ffffff;
    border: 1px solid #0a0a0a;
}
.cookie-btn-accept:hover { background: #262626; }
.cookie-btn-reject {
    background: transparent;
    color: #0a0a0a;
    border: 1px solid #d4d4d4;
}
.cookie-btn-reject:hover { border-color: #0a0a0a; }

@media (max-width: 480px) {
    .cookie-banner {
        bottom: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}

/* ===== FAQ accordion ===== */
.faq-item {
    border-bottom: 1px solid #e5e5e5;
}
.faq-question {
    width: 100%;
    text-align: left;
    padding: 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    font-family: 'Space Grotesk', Inter, sans-serif;
    font-weight: 600;
    font-size: 1.0625rem;
    color: #0a0a0a;
    cursor: pointer;
    background: transparent;
    border: none;
    transition: color 0.2s ease;
}
.faq-question:hover { color: #525252; }
.faq-icon {
    position: relative;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #d4d4d4;
    display: grid;
    place-items: center;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease;
}
.faq-item.is-open .faq-icon { transform: rotate(45deg); border-color: #0a0a0a; }
.faq-icon::before, .faq-icon::after {
    content: '';
    position: absolute;
    background: #0a0a0a;
}
.faq-icon::before { width: 10px; height: 1px; }
.faq-icon::after  { width: 1px; height: 10px; }
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.faq-answer-inner {
    padding: 0 0 1.5rem;
    color: #525252;
    line-height: 1.6;
    font-size: 1rem;
    max-width: 60ch;
}

/* ===== Sticky module dot-nav (right edge of /services) ===== */
.module-dot-nav {
    position: fixed;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    z-index: 30;
}
.module-dot-nav a {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid #0a0a0a;
    background: transparent;
    transition: background 0.25s ease, transform 0.25s ease;
    position: relative;
}
.module-dot-nav a::after {
    content: attr(data-label);
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #525252;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}
.module-dot-nav a:hover::after { opacity: 1; }
.module-dot-nav a.is-active {
    background: #0a0a0a;
    transform: scale(1.3);
}
@media (max-width: 1023px) {
    .module-dot-nav { display: none; }
}

/* ===== Reduced motion guard ===== */
@media (prefers-reduced-motion: reduce) {
    .cursor-dot, .cursor-ring { display: none !important; }
    .cursor-active body, .cursor-active * { cursor: auto !important; }
    .marquee-track { animation: none !important; }
    .tilt-card { transform: none !important; }
    main#main { animation: none; }
    .mockup * { animation: none !important; transition: none !important; }
    .mockup .draw, .mockup .net-line, .mockup .trend-arrow {
        stroke-dasharray: none !important;
        stroke-dashoffset: 0 !important;
    }
    .mockup .bar-fill { transform: scaleY(1) !important; }
    .mockup .puzzle-piece, .mockup .node, .mockup .ksef-step, .mockup .chat-msg { opacity: 1 !important; transform: none !important; }
    .cookie-banner { transition: none; }
    .faq-answer { transition: none; }
}

/* ============================================================
   FAZA C4 — Mobile responsive enhancements
   ============================================================ */

/* Marquee — faster + smaller on mobile */
@media (max-width: 767px) {
    .marquee-track { animation-duration: 40s; }
    .marquee-item { font-size: 0.6875rem; padding: 1rem 0; letter-spacing: 0.14em; }
    .marquee-sep  { padding: 1rem 0.875rem; }
}

/* Hide parallax shapes on mobile (perf + clutter) */
@media (max-width: 767px) {
    .float-shape { display: none; }
}

/* Tilt cards — flat on touch devices (no hover) */
@media (hover: none) {
    .tilt-card { transform: none !important; }
}

/* Cursor — hide entirely on touch / coarse pointer */
@media (pointer: coarse) {
    .cursor-dot, .cursor-ring { display: none !important; }
    .cursor-active body, .cursor-active * { cursor: auto !important; }
}

/* Module dot-nav — also hide on touch devices */
@media (hover: none), (pointer: coarse) {
    .module-dot-nav { display: none; }
}

/* FAQ — better mobile touch targets */
@media (max-width: 640px) {
    .faq-question {
        padding: 1.25rem 0;
        font-size: 1rem;
        min-height: 60px;
    }
    .faq-answer-inner { font-size: 0.9375rem; }
}

/* === Mobile-only utility classes === */
.mobile-only { display: none; }
.desktop-only { display: block; }
@media (max-width: 767px) {
    .mobile-only { display: block; }
    .desktop-only { display: none; }
}

/* Touch target minimum — ensure interactive elements are >= 44x44 on mobile */
@media (max-width: 767px) {
    .magnetic, button.magnetic, a.magnetic { min-height: 44px; }
}
