/* CLIK.ma « Revenir en haut » (__clik_totop.tpl, js/core/clik-totop.js): the CLIK cube alone, no circle (the owner,
   3 Nov). It builds itself in grey, then its top face turns CLIK blue and lights up; as the page goes down the lid opens
   into an up arrow (its corners moved by the script) and the red / yellow faces fill from the bottom. Bottom START
   corner - the « Créer » button owns the end one; beside the left menu on a computer, above the bottom bar on phones. */
.clik-tt {
  --tt-size: 56px; --tt-bottom: 16px; --tt-start: 16px; --tt-lift: 0px; --tt-p: 0;
  --tt-glow: 31, 107, 255; --tt-shadow: rgba(16, 24, 40, .28);
  position: fixed; z-index: 1039; bottom: calc(var(--tt-bottom) + var(--tt-lift)); inset-inline-start: var(--tt-start);
  width: var(--tt-size); height: var(--tt-size); padding: 0; margin: 0; border: 0; border-radius: 12px;
  display: flex; align-items: flex-end; justify-content: center;
  background: transparent; cursor: pointer; overflow: visible; font-family: inherit;
  -webkit-tap-highlight-color: transparent; opacity: 0; transform: translateY(14px) scale(.6); pointer-events: none;
  transition: opacity .28s ease, transform .38s cubic-bezier(.2, 1.4, .4, 1), bottom .25s ease, left .25s ease, --tt-p .6s cubic-bezier(.3, .7, .2, 1);
}
.clik-tt[hidden] { display: none !important; }
.clik-tt.is-on { opacity: 1; transform: none; pointer-events: auto; }
.clik-tt.is-on.is-aside { opacity: 0; transform: translateY(10px) scale(.8); pointer-events: none; }
@media (min-width: 768px) { .clik-tt { --tt-start: calc(var(--side-w, 0px) + 16px); } }
@media (max-width: 668px) { .clik-tt { --tt-size: 52px; --tt-start: 12px; --tt-bottom: calc(45px + env(safe-area-inset-bottom, 0px) + 12px); } }
/* the « Créer » button set in the start corner: this one takes the end */
.clik-tt.is-end { inset-inline-start: auto; inset-inline-end: 16px; }
@media (min-width: 1200px) { body:has(.chat-sidebar:not(.disabled)) .clik-tt.is-end { inset-inline-end: 110px; } }
@media (max-width: 668px) { .clik-tt.is-end { inset-inline-end: 12px; } }

/* the cube is the whole button (its 80 x 88 drawing as tall as the button), a soft shadow under it */
.clik-tt-cube { position: relative; display: block; width: calc(var(--tt-size) * 80 / 88); height: var(--tt-size); flex: none; filter: drop-shadow(0 4px 5px var(--tt-shadow)); transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); }
.clik-tt-cube svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
/* as big as the « Créer » bubble it stands over (56 px, 52 on phones), and smaller with it while the page scrolls */
.clik-tt.is-shrunk .clik-tt-cube { transform: scale(.84); transform-origin: 50% 100%; }
/* the colours rise from the bottom of the side faces with how far the page is read; --tt-p is a registered number so it glides */
@property --tt-p { syntax: '<number>'; inherits: true; initial-value: 0; }
.clik-tt-c { clip-path: inset(calc((1 - var(--tt-p)) * 100%) 0 0 0); }
.clik-tt-g polygon, .clik-tt-lid .f-t { transform-box: fill-box; transform-origin: center; }

/* the lid: grey while it builds, then CLIK blue - the light comes on (a halo behind it, its edge shining) */
.clik-tt-blue, .clik-tt-in, .clik-tt-shine { opacity: 0; transition: opacity .45s ease; }
.clik-tt.is-lit .clik-tt-blue { opacity: 1; }
.clik-tt.is-lit .clik-tt-in { opacity: 1; }
.clik-tt.is-lit .clik-tt-shine { opacity: .75; }
.clik-tt-lid { filter: drop-shadow(0 0 0 rgba(var(--tt-glow), 0)); transition: filter .45s ease; }
.clik-tt.is-lit .clik-tt-lid { filter: drop-shadow(0 0 calc(1.5px + var(--tt-p) * 3px) rgba(var(--tt-glow), calc(.55 + var(--tt-p) * .4))); }
.clik-tt-halo { position: absolute; left: 50%; top: 2%; width: 120%; height: 60%; margin-left: -60%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(var(--tt-glow), .55), rgba(var(--tt-glow), .18) 55%, rgba(var(--tt-glow), 0));
  opacity: 0; transform: translateY(calc(var(--tt-p) * -14%)) scale(.7); transition: opacity .45s ease; }
.clik-tt.is-lit .clik-tt-halo { opacity: calc(.45 + var(--tt-p) * .45); animation: clik-tt-breathe 2.6s ease-in-out infinite; }
@keyframes clik-tt-breathe { 0%, 100% { transform: translateY(calc(var(--tt-p) * -14%)) scale(.78); } 50% { transform: translateY(calc(var(--tt-p) * -14%)) scale(1.02); } }
/* the light running along the lid's top edges once it is lit */
.clik-tt.is-lit .clik-tt-shine { stroke-dasharray: 18 100; animation: clik-tt-run 2.6s ease-in-out infinite; }
@keyframes clik-tt-run { 0% { stroke-dashoffset: 20; } 60%, 100% { stroke-dashoffset: -82; } }

/* it builds itself, grey, when it appears: the three faces come together */
.clik-tt.is-build .clik-tt-lid .f-t { animation: clik-tt-ft .55s cubic-bezier(.2, 1.3, .4, 1) both; }
.clik-tt.is-build .clik-tt-g .f-l { animation: clik-tt-fl .55s .08s cubic-bezier(.2, 1.3, .4, 1) both; }
.clik-tt.is-build .clik-tt-g .f-r { animation: clik-tt-fr .55s .16s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes clik-tt-ft { from { opacity: 0; transform: translateY(-60%) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes clik-tt-fl { from { opacity: 0; transform: translate(-60%, 40%) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes clik-tt-fr { from { opacity: 0; transform: translate(60%, 40%) scale(.6); } to { opacity: 1; transform: none; } }

/* whole: the arrow flashes and the cube pops */
.clik-tt.is-full.is-pop .clik-tt-cube { animation: clik-tt-pop .5s cubic-bezier(.2, 1.5, .4, 1); }
.clik-tt.is-full .clik-tt-halo { opacity: 1; }
@keyframes clik-tt-pop { 40% { transform: scale(1.18) translateY(-6%); } to { transform: none; } }

/* on the way up the cube spins */
.clik-tt.is-going .clik-tt-cube { animation: clik-tt-spin .7s cubic-bezier(.4, 0, .2, 1); }
@keyframes clik-tt-spin { to { transform: rotate(360deg); } }

@media (hover: hover) and (pointer: fine) {
  .clik-tt.is-on:hover .clik-tt-cube { transform: translateY(-3px); }
  .clik-tt.is-on.is-lit:hover .clik-tt-lid { filter: drop-shadow(0 0 5px rgba(var(--tt-glow), 1)); }
}
.clik-tt.is-on:active .clik-tt-cube { transform: scale(.92); }
.clik-tt:focus { outline: none; }
.clik-tt:focus-visible { outline: 2px solid #0866FF; outline-offset: 3px; }

/* the share read « 70 % » written along an arc over the cube (the owner, 3 Nov: "put it on top of the cube in circled
   way", "the %"), every device, once the lid is lit; a computer's mouse / keyboard focus turns it into « Revenir en
   haut · 70 % lu » on the same arc. The arc's centre is the cube's middle, its line clear of the open arrow's tip; a
   halo of the page's colour keeps the letters readable on any photo */
.clik-tt-arc { position: absolute; left: 50%; width: calc(var(--tt-size) * 180 / 56); height: calc(var(--tt-size) * 90 / 56);
  margin-left: calc(var(--tt-size) * -90 / 56); top: calc(var(--tt-size) / 2 - var(--tt-size) * 82 / 56); overflow: visible; pointer-events: none; }
.clik-tt-arc text { font-family: inherit; font-weight: 800; paint-order: stroke; stroke: #fff; stroke-linejoin: round;
  transform-box: view-box; transform-origin: 50% 91%; transition: opacity .2s ease, transform .3s cubic-bezier(.2, 1.4, .4, 1); }
.clik-tt-pct { font-size: 14px; letter-spacing: 0; stroke-width: 4px; fill: #0866FF; opacity: 0; transform: scale(.8); }
.clik-tt.is-lit .clik-tt-pct { opacity: 1; transform: none; }
.clik-tt.is-full .clik-tt-pct { fill: #16A34A; }
.clik-tt-full { font-size: 12px; font-weight: 700; letter-spacing: .02em; stroke-width: 4px; fill: #1c1e21; opacity: 0; transform: scale(.86); }
.clik-tt-full .b { fill: #0866FF; }
[dir="rtl"] .clik-tt-arc text, [dir="RTL"] .clik-tt-arc text { direction: rtl; unicode-bidi: plaintext; letter-spacing: 0; }
[dir="rtl"] .clik-tt-full, [dir="RTL"] .clik-tt-full { font-size: 13px; }
@media (hover: hover) and (pointer: fine) {
  .clik-tt.is-on:hover .clik-tt-full, .clik-tt.is-on:focus-visible .clik-tt-full { opacity: 1; transform: none; }
  .clik-tt.is-on:hover .clik-tt-pct, .clik-tt.is-on:focus-visible .clik-tt-pct { opacity: 0; transform: scale(.8); }
}
body.night-mode .clik-tt-arc text { stroke: #18191a; }
body.night-mode .clik-tt-pct, body.night-mode .clik-tt-full .b { fill: #4C9AFF; }
body.night-mode .clik-tt.is-full .clik-tt-pct { fill: #22C55E; }
body.night-mode .clik-tt-full { fill: #e4e6eb; }

body.night-mode .clik-tt { --tt-glow: 76, 154, 255; --tt-shadow: rgba(0, 0, 0, .55); }

/* the printed page, a window, the photo viewer: it steps away */
@media print { .clik-tt { display: none !important; } }
body.modal-open .clik-tt, body.phv-open .clik-tt, body.clik-gh-voicing .clik-tt { opacity: 0 !important; pointer-events: none !important; }

.clik-tt.no-motion, .clik-tt.no-motion * { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .clik-tt, .clik-tt * { animation: none !important; transition: opacity .2s ease !important; }
  .clik-tt { transform: none !important; }
}
