/* ==========================================================================
   Motion & interaction layer (shared by tv.artline.sa and artline.sa).
   Everything here is progressive: without JS or with reduced motion the
   page is fully visible and usable.
   ========================================================================== */

/* ---- Page-to-page transitions (View Transitions API, Chromium/Safari) ---- */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
::view-transition-old(root) { animation: vt-out 180ms var(--ease) both; }
::view-transition-new(root) { animation: vt-in 320ms var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ---- Scroll reveal (JS adds .has-motion on <html> and .is-in per element) ---- */
.has-motion [data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.has-motion [data-reveal="fade"] { transform: none; }
.has-motion [data-reveal="scale"] { transform: scale(.96); }
.has-motion [data-reveal].is-in { opacity: 1; transform: none; }

/* ---- Hero entrance ---- */
.hero__copy > * { animation: rise 800ms var(--ease) both; }
.hero__copy > *:nth-child(2) { animation-delay: 80ms; }
.hero__copy > *:nth-child(3) { animation-delay: 160ms; }
.hero__copy > *:nth-child(4) { animation-delay: 240ms; }
.hero__copy > *:nth-child(5) { animation-delay: 320ms; }
.hero__copy > *:nth-child(6) { animation-delay: 400ms; }
.hero .feature { animation: reveal-card 1000ms 200ms var(--ease) both; }
.hero .feature img { animation: kenburns 22s 1.2s ease-in-out infinite alternate; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes reveal-card { from { opacity: 0; transform: translateY(24px) scale(.97); clip-path: inset(8% 8% 8% 8% round 28px); } to { clip-path: inset(0 0 0 0 round 28px); } }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.08) translate(-1%, -1%); } }

/* ---- Header: compacts on scroll ---- */
.site-header__inner { transition: height 300ms var(--ease); }
.is-scrolled .site-header { box-shadow: 0 6px 24px rgba(29, 28, 27, .06); }
.is-scrolled .site-header__inner { height: 64px; }

/* ---- Navigation: sliding underline + active indicator ---- */
.main-nav a:hover, .main-nav a.is-active { background: transparent; }
.main-nav a::after {
  content: ""; position: absolute; inset-inline: 14px; bottom: 4px; height: 2px; border-radius: 2px;
  background: var(--brand); transform: scaleX(0); transform-origin: center; transition: transform 300ms var(--ease);
}
.main-nav a:hover::after { transform: scaleX(.6); }
.main-nav a.is-active::after { transform: scaleX(1); }

/* ---- Buttons: arrow nudge, shine, press ---- */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn .ui-icon { transition: transform 300ms var(--ease); }
.btn:hover .ui-icon--go { transform: translateX(4px); }
[dir="rtl"] .btn:hover .ui-icon--go { transform: translateX(-4px) scaleX(-1); }
[dir="rtl"] .btn .ui-icon--go { transform: scaleX(-1); }
.btn--primary::before {
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; width: 60%; left: -80%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent);
  transform: skewX(-20deg); transition: left 700ms var(--ease);
}
.btn--primary:hover::before { left: 130%; }
.btn--primary { box-shadow: none; }
.btn--primary:hover { box-shadow: 0 8px 20px rgba(29, 28, 27, .14); transform: translateY(-1px); }
.btn--outline:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn:active { transform: translateY(0) scale(.97); transition-duration: 80ms; }
.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin 700ms linear infinite; }
.btn--outline.is-loading::after { border-color: rgba(29, 28, 27, .2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Links with animated arrow ---- */
.sec-link { transition: background-color 300ms var(--ease), color 300ms var(--ease), border-color 300ms var(--ease); }
.sec-link:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.sec-link .ui-icon { transition: transform 300ms var(--ease); }
.sec-link:hover .ui-icon { transform: translateX(3px); }
[dir="rtl"] .sec-link:hover .ui-icon { transform: translateX(-3px) scaleX(-1); }

/* ---- Cards ---- */
.vcard__link { transition: transform 400ms var(--ease); }
.vcard__link:hover { transform: translateY(-4px); }
.vcard__media { transition: box-shadow 400ms var(--ease); }
.vcard__link:hover .vcard__media { box-shadow: 0 18px 40px rgba(29, 28, 27, .22); }
.vcard__info { transition: transform 400ms var(--ease); }
.vcard__link:hover .vcard__info { transform: translateY(-4px); }
.vcard__play svg, .feature__play svg, .spotlight__play svg { fill: currentColor; }
.vcard__link:hover .vcard__play::after, .feature:hover .feature__play::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); animation: ping 1.2s var(--ease) infinite;
}
@keyframes ping { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
.stile__icon .icon { transition: transform 400ms var(--ease); }
.stile:hover .stile__icon .icon { transform: scale(1.12) rotate(-6deg); }
.dcard__photo { transition: box-shadow 400ms var(--ease), transform 400ms var(--ease); }
.dcard:hover .dcard__photo { transform: translateY(-4px); box-shadow: 0 18px 40px rgba(29, 28, 27, .18); }

/* ---- Images fade in when loaded ---- */
.has-motion img[loading="lazy"] { opacity: 0; transition: opacity 600ms var(--ease); }
.has-motion img[loading="lazy"].is-loaded { opacity: 1; }

/* ---- Marquee ---- */
.marquee { overflow: hidden; border-block: 1px solid var(--line); background: var(--bg); padding-block: 18px; mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent); }
.marquee__track { display: flex; width: max-content; gap: 48px; animation: marquee 38s linear infinite; }
[dir="rtl"] .marquee__track { animation-name: marquee-rtl; }
.marquee:hover .marquee__track { animation-play-state: paused; }
.marquee__item { display: inline-flex; align-items: center; gap: 16px; font-family: var(--font-display); font-size: clamp(1.125rem, .9rem + .8vw, 1.5rem); font-weight: 600; color: var(--ink); white-space: nowrap; }
.marquee__item .ui-icon { width: 22px; height: 22px; color: var(--brand); }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes marquee-rtl { to { transform: translateX(50%); } }

/* ---- Mobile menu: full-screen with staggered links ---- */
@media (max-width: 1024px) {
  .main-nav { inset: var(--header-h) 0 0; height: calc(100dvh - var(--header-h)); display: flex; flex-direction: column; padding-top: 24px; box-shadow: none; transform: none; clip-path: inset(0 0 100% 0); opacity: 1; transition: clip-path 450ms var(--ease), visibility 450ms; }
  .nav-open .main-nav { clip-path: inset(0 0 0 0); }
  .main-nav li { opacity: 0; transform: translateY(14px); transition: opacity 400ms var(--ease), transform 400ms var(--ease); }
  .nav-open .main-nav li { opacity: 1; transform: none; }
  .nav-open .main-nav li:nth-child(2) { transition-delay: 40ms; }
  .nav-open .main-nav li:nth-child(3) { transition-delay: 80ms; }
  .nav-open .main-nav li:nth-child(4) { transition-delay: 120ms; }
  .nav-open .main-nav li:nth-child(5) { transition-delay: 160ms; }
  .nav-open .main-nav li:nth-child(6) { transition-delay: 200ms; }
  .main-nav a { display: flex; width: 100%; justify-content: space-between; font-family: var(--font-display); font-size: clamp(1.5rem, 1rem + 3vw, 2rem); font-weight: 600; height: 68px; padding-inline: 4px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .main-nav a.is-active { color: var(--brand-strong); }
  .main-nav a::after { display: none; }
  .nav-open { overflow: hidden; }
  .nav-toggle .ui-icon { transition: transform 300ms var(--ease); }
  .nav-open .nav-toggle .ui-icon { transform: rotate(90deg); }
}

/* ---- Rails: drag to scroll ---- */
.rail__track.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.rail__track.is-dragging a { pointer-events: none; }

/* ---- Scroll progress (thin brand line under the header) ---- */
.scroll-progress { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 70; background: var(--brand); transform-origin: left; transform: scaleX(var(--p, 0)); pointer-events: none; }
[dir="rtl"] .scroll-progress { transform-origin: right; }

@media (prefers-reduced-motion: reduce) {
  .hero__copy > *, .hero .feature, .hero .feature img { animation: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .marquee__track { animation: none; }
}
