/* ═══════════════════════════════════════════════════════════════════
   DESIGN V2 — cinematic layer (design-motion playbook)
   Matte-editorial at rest, alive in motion. transform/opacity only.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Elevation scale: layered shadows in light mode (Jakub) ── */
:root {
  --e1: 0 0 0 1px rgba(20,21,23,.05), 0 1px 2px -1px rgba(20,21,23,.06), 0 2px 6px rgba(20,21,23,.04);
  --e2: 0 0 0 1px rgba(20,21,23,.06), 0 2px 4px -1px rgba(20,21,23,.07), 0 8px 20px -4px rgba(20,21,23,.08);
  --e3: 0 0 0 1px rgba(20,21,23,.06), 0 4px 8px -2px rgba(20,21,23,.08), 0 18px 44px -8px rgba(20,21,23,.16);
  /* spring overshoot in pure CSS (Jhey) */
  --spring: linear(
    0, 0.006, 0.023, 0.049, 0.084, 0.128, 0.18, 0.239, 0.304, 0.374,
    0.448, 0.526, 0.606, 0.687, 0.768, 0.847, 0.923, 0.994, 1.059, 1.116,
    1.166, 1.207, 1.239, 1.262, 1.275, 1.279, 1.273, 1.258, 1.234, 1.202,
    1.163, 1.117, 1.065, 1.008, 0.947, 0.884, 0.819, 0.754, 0.69, 0.628,
    0.569, 0.514, 0.463, 0.417, 0.377, 0.343, 0.315, 0.293, 0.277, 0.267,
    0.263, 0.265, 0.272, 0.284, 0.301, 0.322, 0.347, 0.376, 0.408, 0.443,
    0.481, 0.521, 0.563, 0.606, 0.65, 0.695, 0.74, 0.784, 0.827, 0.869,
    0.909, 0.946, 0.98, 1.011, 1.038, 1.061, 1.08, 1.094, 1.103, 1.108,
    1.107, 1.101, 1.09, 1.074, 1.053, 1.028, 0.999, 0.967, 0.931, 0.893,
    0.852, 0.81, 0.767, 0.724, 0.681, 0.64, 0.6, 0.563, 0.529, 0.497,
    0.468, 0.443, 0.422, 0.406, 0.394, 0.387, 0.385, 0.388, 0.395, 0.406,
    0.421, 0.439, 0.46, 0.484, 0.511, 0.54, 0.571, 0.604, 0.638, 0.673,
    0.709, 0.745, 0.781, 0.817, 0.852, 0.886, 0.919, 0.95, 0.979, 1.006,
    1.03, 1.051, 1.069, 1.083, 1.093, 1.099, 1.1, 1.097, 1.089, 1.077,
    1.061, 1.041, 1.017, 0.99, 0.96, 0.928, 0.893, 0.857, 0.82, 0.782,
    0.744, 0.706, 0.668, 0.631, 0.596, 0.562, 0.53, 0.5, 0.472, 0.447,
    0.425, 0.405, 0.388, 0.375, 0.364, 0.357, 0.353, 0.352, 0.354, 0.359,
    0.367, 0.377, 0.39, 0.405, 0.422, 0.441, 0.462, 0.485, 0.508, 0.533,
    0.558, 0.584, 0.61, 0.636, 0.662, 0.687, 0.712, 0.736, 0.758, 0.779,
    0.798, 0.815, 0.829, 0.841, 0.85, 0.857, 0.86, 0.861, 0.858, 0.852,
    0.844, 0.832, 0.818, 0.801, 0.782, 0.76, 0.736, 0.71, 0.683, 0.654,
    0.624, 0.593, 0.561, 0.529, 0.496, 0.463, 0.431, 0.398, 0.366, 0.335,
    0.305, 0.276, 0.249, 0.223, 0.199, 0.177, 0.156, 0.138, 0.122, 0.108,
    0.096, 0.086, 0.078, 0.073, 0.07, 0.069, 0.07, 0.074, 0.079, 0.087,
    0.096, 0.107, 0.12, 0.134, 0.15, 0.167, 0.185, 0.205, 0.225, 0.246,
    0.268, 0.29, 0.313, 0.336, 0.359, 0.383, 0.406, 0.429, 0.452, 0.474,
    0.495, 0.516, 0.535, 0.553, 0.569, 0.584, 0.597, 0.608, 0.617, 0.624,
    0.628, 0.63, 0.63, 0.627, 0.621, 0.613, 0.602, 0.589, 0.573, 0.555,
    0.535, 0.512, 0.488, 0.462, 0.434, 0.405, 0.374, 0.342, 0.309, 0.275,
    0.24, 0.205, 0.169, 0.133, 0.097, 0.061, 0.024, -0.013, -0.05,
    -0.087, -0.124, -0.16, -0.195, -0.229, -0.262, -0.294, -0.324,
    -0.353, -0.38, -0.404, -0.427, -0.447, -0.464, -0.479, -0.49,
    -0.499, -0.504, -0.506, -0.505, -0.5, -0.492, -0.48, -0.465,
    -0.446, -0.425, -0.4, -0.372, -0.341, -0.307, -0.271, -0.231,
    -0.19, -0.146, -0.1, -0.052, -0.002, 0.05, 0.104, 0.16, 0.217,
    0.276, 0.335, 0.396, 0.457, 0.519, 0.581, 0.643, 0.705, 0.766,
    0.827, 0.887, 0.945, 1.002, 1.057, 1.11, 1.16, 1.208, 1.253,
    1.295, 1.334, 1.369, 1.4, 1.427, 1.45, 1.468, 1.481, 1.489,
    1.492, 1.489, 1.481, 1.467, 1.447, 1.422, 1.391, 1.354, 1.312,
    1.264, 1.211, 1.152, 1.088, 1.018, 0.943, 0.863, 0.779, 0.689,
    0.594, 0.495, 0.391, 0.283, 0.17, 0.054, -0.067, -0.192,
    -0.322, -0.456, -0.595, -0.738, -0.886, -1.038, -1.195, -1.355,
    -1.52, -1.689, -1.861, -2.037, -2.216, -2.398, -2.584, -2.772,
    -2.963, -3.157, -3.353, -3.551, -3.751, -3.953, -4.156, -4.36,
    -4.565, -4.771, -4.977, -5.183, -5.388, -5.593, -5.796, -5.998,
    -6.198, -6.396, -6.592, -6.785, -6.976, -7.163, -7.346, -7.525,
    -7.699, -7.868, -8.031, -8.188, -8.338, -8.481, -8.617, -8.745,
    -8.865, -8.977, -9.08, -9.174, -9.258, -9.333, -9.397, -9.451,
    -9.494, -9.526, -9.546, -9.554, -9.55, -9.533, -9.504, -9.461,
    -9.405, -9.335, -9.251, -9.153, -9.04, -8.912, -8.769, -8.61,
    -8.436, -8.246, -8.04, -7.818, -7.579, -7.324, -7.052, -6.763,
    -6.457, -6.133, -5.792, -5.433, -5.055, -4.659, -4.243, -3.808,
    -3.352, -2.875, -2.377, -1.857, -1.314, -0.748, -0.158, 0.457,
    1.098, 1.764, 2.457, 3.176, 3.922, 4.696, 5.497, 6.327, 7.186,
    8.074, 8.992, 9.94, 10.918, 11.928, 12.969, 14.042, 15.147,
    16.285, 17.456, 18.66, 19.899, 21.172, 22.479, 23.821, 25.198,
    26.61, 28.058, 29.542, 31.062, 32.618, 34.21, 35.839, 37.505,
    39.208, 40.948, 42.725, 44.54, 46.392, 48.281, 50.207, 52.17,
    54.17, 56.207, 58.281, 60.392, 62.539, 64.723, 66.943, 69.2,
    71.493, 73.821, 76.185, 78.585, 81.02, 83.49, 85.996, 88.537,
    91.113, 93.723, 96.368, 99.047, 101.76, 104.507, 107.287, 110.1,
    112.946, 115.825, 118.736, 121.679, 124.653, 127.658, 130.694,
    133.76, 136.856, 139.981, 143.136, 146.319, 149.531, 152.771,
    156.038, 159.333, 162.654, 166.002, 169.376, 172.776, 179.652 / 180,
    1
  );
}
[data-theme="dark"] {
  --e1: 0 0 0 1px rgba(255,255,255,.05), 0 1px 2px -1px rgba(0,0,0,.4);
  --e2: 0 0 0 1px rgba(255,255,255,.06), 0 6px 18px -4px rgba(0,0,0,.5);
  --e3: 0 0 0 1px rgba(255,255,255,.07), 0 18px 44px -8px rgba(0,0,0,.6);
}

/* Cards pick up the elevation scale */
.stat-cell, .doc-card, .notif-panel, .wa-msg-menu, .chat-emoji-menu,
#waChatContextMenu, .user-pop {
  box-shadow: var(--e1);
}
.doc-card:hover {
  box-shadow: var(--e2);
  transform: translateY(-2px);
}
.notif-panel, .wa-msg-menu { box-shadow: var(--e3); }

/* ── Boot choreography: one cascade on first paint ── */
body.boot-entrance .stat-cell,
body.boot-entrance #vDash .card {
  animation: matIn var(--d3) var(--ease-out) backwards;
}
body.boot-entrance .stat-cell:nth-child(1) { animation-delay: 60ms; }
body.boot-entrance .stat-cell:nth-child(2) { animation-delay: 110ms; }
body.boot-entrance .stat-cell:nth-child(3) { animation-delay: 160ms; }
body.boot-entrance .stat-cell:nth-child(4) { animation-delay: 210ms; }
body.boot-entrance #vDash .card:nth-of-type(1) { animation-delay: 260ms; }
body.boot-entrance #vDash .card:nth-of-type(2) { animation-delay: 320ms; }
@keyframes matIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scroll reveals (IntersectionObserver adds .in) ── */
.reveal { opacity: 0; transform: translateY(12px); }
.reveal.in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 50ms);
}

/* ── Sliding nav indicator ── */
.nav-ind {
  position: absolute;
  left: 8px;
  width: calc(100% - 16px);
  height: 44px;
  border-radius: 10px;
  background: var(--paper-3);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s var(--ease-out), opacity 0.2s ease, height 0.2s ease;
  z-index: 0;
}
.side-nav { position: relative; }
.side-nav button { position: relative; z-index: 1; }
@media (max-width: 940px) {
  .nav-ind {
    display: none !important;
  }
}

/* ── Bell ring: single trigger when the dot appears ── */
@keyframes bellRing {
  0% { transform: rotate(0); }
  18% { transform: rotate(14deg); }
  36% { transform: rotate(-11deg); }
  54% { transform: rotate(7deg); }
  72% { transform: rotate(-4deg); }
  100% { transform: rotate(0); }
}
.ring-me svg {
  animation: bellRing 0.6s var(--ease-out);
  transform-origin: top center;
}

/* ── CTA arrow nudge ── */
.btn svg { transition: transform var(--d1) var(--ease-out); }
.btn:hover svg { transform: translateX(2px); }

/* ── Toast: top slide with overshoot + progress hairline ── */
#toast { overflow: hidden; }
#toast.on { animation: toastIn 0.45s var(--spring); }
#toast.on::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--petrol);
  transform-origin: left;
  animation: toastBar linear forwards;
  animation-duration: var(--toast-ms, 2800ms);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastBar {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Chat bubbles: springier arrival ── */
.bub.pop-in { animation: bubIn 0.4s var(--spring) !important; }
@keyframes bubIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Login: cinematic, oklch washes drifting behind the card ── */
.auth { position: relative; overflow: hidden; }
.auth::before,
.auth::after {
  content: '';
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
}
.auth::before {
  background: radial-gradient(circle at 30% 30%, oklch(0.62 0.09 210), transparent 65%);
  top: -25vmax; left: -18vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
.auth::after {
  background: radial-gradient(circle at 70% 70%, oklch(0.7 0.07 60), transparent 65%);
  bottom: -28vmax; right: -20vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(9vmax, 7vmax) scale(1.15); }
}
@keyframes drift2 {
  from { transform: translate(0, 0) scale(1.1); }
  to   { transform: translate(-8vmax, -6vmax) scale(0.95); }
}
[data-theme="dark"] .auth::before { opacity: 0.22; }
[data-theme="dark"] .auth::after { opacity: 0.16; }
.auth-card { position: relative; z-index: 1; animation: authIn 0.45s var(--ease-out) backwards 0.05s; }
.auth-crest { animation: crestDrop 0.7s var(--spring) backwards; }
@keyframes crestDrop {
  from { opacity: 0; transform: translateY(-26px) scale(0.85); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Theme switch: circular reveal (View Transitions API) ── */
::view-transition-old(root) { animation: none; }
::view-transition-new(root) {
  animation: vtReveal 0.5s var(--ease-out);
  mix-blend-mode: normal;
}
@keyframes vtReveal {
  from { clip-path: circle(0% at var(--vt-x, 90%) var(--vt-y, 90%)); }
  to   { clip-path: circle(140% at var(--vt-x, 90%) var(--vt-y, 90%)); }
}

/* ── Count-up digits use tabular figures (no layout shift) ── */
.stat-cell .v { font-variant-numeric: tabular-nums; }

/* ── Reduced motion: kill the whole cinematic layer ── */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .auth::before, .auth::after { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .bub.pop-in { animation: none !important; }
}
