/* Mohrati motion: shared by the public site and the admin.
   Rules: short (under 250 ms), quiet, only opacity / transform / colour, off for people who ask for less motion.
   Colours come from the page's own tokens (--ink, --gold, --line, --bg, --panel). */
:root {
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-1: 150ms;
  --dur-2: 240ms;
  --dx: 0px;   /* sideways offset of the next screen, set by the admin (motion.js) */
  --sx: 1;     /* step direction on the public planner; flipped to -1 for Arabic */
}
html[dir="rtl"] { --sx: -1; }

/* ---------- 1. polish: hover, press, focus ---------- */
.btn, .pill, .round, .chip > span, .chip-s, .subtle-btn, .backlink, .tabbar a, .side a, .menu a, .list > a, .list > .li,
#rl > .li, .card.slim, .vrow > summary, .toast, input, select, textarea {
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover, .round:hover { transform: translateY(-1px); }
  .btn.primary:not(:disabled):hover { box-shadow: 0 6px 16px color-mix(in srgb, var(--gold) 32%, transparent); }
  .pill:hover, .menu a:hover, .list > a:hover, .list > .li:hover, #rl > .li:hover, .card.slim:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
  .menu a:hover, .list > a:hover, #rl > .li:hover { transform: translateY(-1px); }
  .backlink:hover { background: color-mix(in srgb, var(--gold) 12%, transparent); }
}
.btn:not(:disabled):active, .pill:active, .round:active, .chip:active > span, .backlink:active { transform: scale(.97); }
.menu a:active, .list > a:active { transform: scale(.985); }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }

/* theme switch: colours cross-fade instead of snapping (class set for 400 ms by motion.js) */
html.theming, html.theming *, html.theming *::before, html.theming *::after {
  transition: background-color .35s var(--ease), color .35s var(--ease), border-color .35s var(--ease), fill .35s var(--ease), stroke .35s var(--ease), box-shadow .35s var(--ease) !important;
}

/* the sun/moon swap keeps its own turn while the colours cross-fade */
html.theming .ctl svg, html.theming .round svg { transition: transform .5s cubic-bezier(.3, 1.2, .5, 1), opacity .25s ease, stroke .35s var(--ease) !important; }

/* ---------- 2. screens and steps ---------- */
@keyframes rise { from { opacity: 0; transform: translate(var(--dx), 8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes stepIn { from { opacity: 0; transform: translateX(calc(var(--sx) * var(--dir, 1) * 26px)); } to { opacity: 1; transform: none; } }

/* public planner: the new step slides in from the side it belongs to (mirrored in Arabic) */
#app.s-fwd { --dir: 1; } #app.s-back { --dir: -1; }
#app.s-fwd > *, #app.s-back > * { animation: stepIn var(--dur-2) var(--ease-out) both; }
#app.s-fwd > :nth-child(2), #app.s-back > :nth-child(2) { animation-delay: 30ms; }
#app.s-fwd > :nth-child(n+3), #app.s-back > :nth-child(n+3) { animation-delay: 60ms; }

/* sections that open (details, "Towns and areas", "Heat dates"): the content eases in */
details[open] > :not(summary) { animation: drop var(--dur-2) var(--ease-out) both; }

/* success tick on the public confirmation */
@keyframes popIn { 0% { opacity: 0; transform: scale(.7); } 60% { opacity: 1; transform: scale(1.06); } 100% { transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.big-ok .tick { animation: popIn .45s var(--ease-out) both; }
.big-ok .tick path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .45s .2s var(--ease) forwards; }
.big-ok > h1, .big-ok > .lead, .big-ok > .hint { animation: rise var(--dur-2) .25s var(--ease-out) both; }

/* ---------- 3. loading and feedback ---------- */
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.sk-wrap { display: grid; gap: 12px; }
.sk { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 10px; }
.sk-l { display: block; height: 12px; border-radius: 8px;
  background: linear-gradient(100deg, color-mix(in srgb, var(--line) 70%, transparent) 30%, color-mix(in srgb, var(--line) 25%, transparent) 50%, color-mix(in srgb, var(--line) 70%, transparent) 70%);
  background-size: 250% 100%; animation: shimmer 1.4s linear infinite; }
.sk-l.w30 { width: 30%; } .sk-l.w40 { width: 40%; } .sk-l.w60 { width: 60%; } .sk-l.w80 { width: 80%; }
.sk-l.h { height: 18px; }

@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
.toast { animation: toastIn var(--dur-2) var(--ease-out) both; }
.toast.out { animation: toastOut 200ms var(--ease) both; }
@keyframes barUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.savebar.on { animation: barUp var(--dur-2) var(--ease-out) both; }
@keyframes pillPop { 0% { transform: scale(.94); } 55% { transform: scale(1.04); } 100% { transform: none; } }
#stbtn .pill.on { animation: pillPop .3s var(--ease-out); }

/* admin screens: content rises in, lists one row after another (only just after a screen change; see motion.js) */
#view[data-enter] > :not(.list):not(#rl):not(#vl):not(.menu):not(.sk-wrap):not(.cardgrid) { animation: rise var(--dur-2) var(--ease-out) both; }
#view[data-enter] :is(.list, #rl, #vl, .menu, .cardgrid, .sk-wrap) > * { animation: rise var(--dur-2) var(--ease-out) both; }
#view[data-enter] :is(.list, #rl, #vl, .menu, .cardgrid, .sk-wrap) > :nth-child(2) { animation-delay: 35ms; }
#view[data-enter] :is(.list, #rl, #vl, .menu, .cardgrid, .sk-wrap) > :nth-child(3) { animation-delay: 70ms; }
#view[data-enter] :is(.list, #rl, #vl, .menu, .cardgrid, .sk-wrap) > :nth-child(4) { animation-delay: 105ms; }
#view[data-enter] :is(.list, #rl, #vl, .menu, .cardgrid, .sk-wrap) > :nth-child(5) { animation-delay: 140ms; }
#view[data-enter] :is(.list, #rl, #vl, .menu, .cardgrid, .sk-wrap) > :nth-child(n+6) { animation-delay: 175ms; }

/* ---------- less motion for people who ask for it ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .sk-l { animation: none !important; }
  .big-ok .tick path { stroke-dashoffset: 0; }
}

/* ---------- 5. glass on the public pages: the floating back link ---------- */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .backlink { background: color-mix(in srgb, var(--bg, #fff) 62%, transparent); border: 1px solid var(--line); -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px); }
}
@media (prefers-reduced-transparency: reduce) { .backlink { background: var(--bg, #fff); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* admin screen change: the old screen fades out quickly (browser View Transitions, where supported) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; animation-timing-function: var(--ease); }
