/* Tedy motion layer (loaded last). Presentation only.
   Continuous motion uses transform/opacity only; html[data-motion] = full | lite | off. */

/* ---------- Static background pattern ---------- */
:root { --carbon: url(/tb-carbon.svg); }
body { background-attachment: scroll !important; }

/* ---------- Pause: hidden tab, unfocused window, offscreen ---------- */
/* :not(#tb-x) lifts specificity above any animation shorthand that would reset play-state. */
html.tb-paused *:not(#tb-x), html.tb-paused *:not(#tb-x)::before, html.tb-paused *:not(#tb-x)::after,
.is-offscreen:not(#tb-x), .is-offscreen *:not(#tb-x), .is-offscreen:not(#tb-x)::before, .is-offscreen:not(#tb-x)::after,
.is-offscreen *:not(#tb-x)::before, .is-offscreen *:not(#tb-x)::after { animation-play-state: paused !important; }

/* ---------- Border beams: old @property conic + mask animation removed ---------- */
:is(.tb-beam, .dash-card, .driver-grid-card, .team-grid-card, .team-card, .track-card, .glass-panel, .news-card)::before {
  content: none !important; animation: none !important;
}
.tb-ring {
  position: absolute !important; inset: 0 !important; border-radius: inherit; padding: 1px; pointer-events: none; z-index: 0 !important;
  overflow: hidden; display: block; margin: 0 !important;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  opacity: .35; transition: opacity 260ms ease;
}
.tb-ring > .tb-ring-c {
  position: absolute; left: 50%; top: 50%; width: var(--rs, 600px); height: var(--rs, 600px);
  margin: calc(var(--rs, 600px) / -2) 0 0 calc(var(--rs, 600px) / -2);
  background: conic-gradient(transparent 0 70%, rgba(255,255,255,0.55) 80%, var(--accent) 86%, transparent 94% 100%);
  animation: tbRingSpin 9s linear infinite; will-change: transform;
}
.tb-beam > .tb-ring { padding: 1.5px; opacity: var(--beam-op, 1); }
.tb-beam > .tb-ring > .tb-ring-c {
  background: conic-gradient(transparent 0 62%, var(--beam, var(--accent)) 78%, var(--beam2, var(--beam, var(--accent))) 84%, transparent 92% 100%);
  animation-duration: var(--beam-dur, 4s);
}
:is(.dash-card, .driver-grid-card, .team-grid-card, .team-card, .track-card, .news-card):hover > .tb-ring { opacity: .85; }
@keyframes tbRingSpin { to { transform: rotate(360deg); } }
html:not([data-motion="full"]) .tb-ring { display: none; }

/* ---------- Cover: pre-blurred shine, one sweep about every 20 s ---------- */
.cover-shine i, .cover-shine b { filter: none !important; width: 22% !important; }
.cover-shine i { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.10) 25%, rgba(255,255,255,0.42) 45%, rgba(255,255,255,0.52) 50%, rgba(255,255,255,0.42) 55%, rgba(255,255,255,0.10) 75%, transparent) !important; }
.cover-shine b { background: linear-gradient(90deg, transparent, rgba(12,14,18,0.08) 30%, rgba(12,14,18,0.18) 50%, rgba(12,14,18,0.08) 70%, transparent) !important; }
.cover-shine i, .cover-shine b { animation: tbCoverSweep 20s cubic-bezier(.45,.05,.35,.95) infinite !important; }
@keyframes tbCoverSweep {
  0%, 87% { transform: translateX(-180%) skewX(-16deg); opacity: 0; }
  89%, 98% { opacity: 1; }
  100% { transform: translateX(560%) skewX(-16deg); opacity: 0; }
}
/* Brand: breathing filter / text-shadow / background-position loops removed, one static look + one opacity pulse */
.brand-tedy { animation: none !important; filter: drop-shadow(0 6px 18px rgba(0,0,0,0.55)); }
.brand-f1 { animation: none !important; filter: drop-shadow(0 0 12px rgba(225,6,0,0.4)); }
.brand-divider { animation: none !important; background: linear-gradient(180deg, transparent, rgba(255,255,255,0.5), transparent) !important; background-size: 100% 100% !important; }
#tb-title.brand-pokal { animation: none !important; }
.brand-lockup::after {
  content: ""; position: absolute; left: 30%; top: 50%; width: 46%; height: 160%; transform: translate(0, -50%);
  background: radial-gradient(closest-side, rgba(225,6,0,0.14), transparent); pointer-events: none; z-index: -1;
  opacity: .35; animation: tbBrandPulse 6s ease-in-out infinite;
}
@keyframes tbBrandPulse { 0%, 100% { opacity: .3; } 50% { opacity: .7; } }
.cover-dot { animation: tbDotPulse 2s ease-in-out infinite !important; }
@keyframes tbDotPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- Result chips: shine once on hover ---------- */
#results .res-cell .res-mark::after { animation: none !important; }
#results .res-cell:is(.pos-1, .pos-2, .pos-3):hover .res-mark::after { animation: tbResShine .8s ease-out 1 !important; }
@keyframes tbResShine { from { transform: translateX(0) rotate(20deg); } to { transform: translateX(490%) rotate(20deg); } }

/* ---------- Hover: transform/opacity transitions; glow shadows apply without transition ---------- */
.dash-card, .race-card, .track-card, .driver-row, .podium-card, .driver-grid-card, .team-card, .team-grid-card,
.news-card, .manual-news-card, .rumor-card, .sponsor-card, .glass-panel {
  transition: transform 360ms var(--ease-expo, cubic-bezier(.16,1,.3,1)), opacity 260ms ease !important;
}
.btn { transition: transform 200ms var(--ease-expo, cubic-bezier(.16,1,.3,1)), opacity 200ms ease !important; }
.chip { transition: opacity 200ms ease, transform 200ms ease !important; }
.tab-btn { transition: transform 180ms ease, opacity 180ms ease !important; }

/* ---------- Containment ---------- */
#main-content :is(.dash-card, .race-card, .track-card, .driver-grid-card, .team-grid-card, .team-card, .news-card, .manual-news-card, .rumor-card, .sponsor-card) { contain: layout paint; }
#calendar .race-card { content-visibility: auto; contain-intrinsic-size: auto 360px; }
#tracks .track-card { content-visibility: auto; contain-intrinsic-size: auto 420px; }
#news :is(.news-card, .manual-news-card) { content-visibility: auto; contain-intrinsic-size: auto 380px; }
.archive-row { content-visibility: auto; contain-intrinsic-size: auto 64px; }
#results .gap-card { content-visibility: auto; contain-intrinsic-size: auto 80px; }
#drivers .driver-row { content-visibility: auto; contain-intrinsic-size: auto 76px; }

/* ---------- Entrance: only on a real tab switch, first 12 children, <= 250 ms ---------- */
.driver-row { animation: none !important; opacity: 1 !important; }
.view.tb-in .driver-row:nth-child(-n+12) { animation: fadeInUp .4s ease-out both !important; animation-delay: min(var(--delay, 0s), .22s) !important; will-change: transform, opacity; }
.tb-stagger > :nth-child(n+13) { animation: none !important; }
.tb-stagger > :nth-child(-n+12), .view.tb-in > * { will-change: transform, opacity; }

/* ---------- backdrop-filter: full keeps glass panels, nav and overlays only ---------- */
html[data-motion="full"] #main-content :is(.dash-card, .race-card, .results-wrap, .driver-row, .team-grid-card, .driver-grid-card, .track-card, .team-card, .news-card, .manual-news-card, .rumor-card, .sponsor-card, .news-filter, .news-search, .news-subtab) {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}

/* ---------- LITE ---------- */
html[data-motion="lite"] *, html[data-motion="lite"] *::before, html[data-motion="lite"] *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
html[data-motion="lite"] .tabs-wrap { background: rgba(10,10,12,0.96) !important; }
html[data-motion="lite"] #panel.panel { background: rgba(12,12,18,0.97) !important; }
html[data-motion="lite"] .glass-panel { background-color: rgba(16,16,22,0.92) !important; }
html[data-motion="lite"] :is(.cover-shine i, .cover-shine b, .cover-dot, .driver-row .driver-row-bg, .status-next),
html[data-motion="lite"] .brand-lockup::after, html[data-motion="lite"] .driver-row .driver-row-bg::before { animation: none !important; }
html[data-motion="lite"] .cover-shine { display: none; }
html[data-motion="lite"] .brand-lockup::after { opacity: .35; }
html[data-motion="lite"] .driver-row .driver-row-bg { opacity: .5; }
html[data-motion="lite"] #results .res-cell .res-mark::after { animation: none !important; display: none; }
html[data-motion="lite"] .view.tb-in { animation: tbLiteFade 140ms linear both !important; }
html[data-motion="lite"] .view.tb-in > *, html[data-motion="lite"] .tb-stagger > *, html[data-motion="lite"] .view.tb-in .driver-row { animation: none !important; will-change: auto !important; }
@keyframes tbLiteFade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- OFF ---------- */
html[data-motion="off"] body *:not(#panel, #panel *), html[data-motion="off"] body *:not(#panel, #panel *)::before, html[data-motion="off"] body *:not(#panel, #panel *)::after {
  animation: none !important; transition: none !important;
}
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
html[data-motion="off"] .tabs-wrap { background: rgba(10,10,12,0.96) !important; }
html[data-motion="off"] #panel.panel { background: rgba(12,12,18,0.97) !important; }
html[data-motion="off"] .cover-shine { display: none; }
html[data-motion="off"] .driver-row .driver-row-bg { opacity: .5; }

/* ---------- Footer switch ---------- */
.tb-footer { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 18px 16px 28px; font: 500 12px/1 'Hind', sans-serif; color: rgba(245,245,245,0.45); }
.tb-footer select { background: rgba(255,255,255,0.05); color: rgba(245,245,245,0.75); border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 5px 10px; font: inherit; color-scheme: dark; }
.tb-footer select option { background: #121216; color: #f5f5f5; }

@media (prefers-reduced-motion: reduce) {
  .tb-ring > .tb-ring-c, .brand-lockup::after, .cover-shine i, .cover-shine b, .cover-dot { animation: none !important; }
}

/* The intro always plays in full; never pause it for blur/hidden/offscreen states. */
html #intro-overlay:not(#tb-x), html #intro-overlay *:not(#tb-x), html #intro-overlay *:not(#tb-x)::before, html #intro-overlay *:not(#tb-x)::after { animation-play-state: running !important; }

/* Standings: rank-up flash (opacity only) */
.driver-row.tb-moved-up::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, rgba(34,197,94,0.22), transparent 60%); animation: tbMovedUp 1.6s ease-out both; }
@keyframes tbMovedUp { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
