/* ==========================================================================
 * Motion — one feel across the website, the admin and the app.
 *
 * Three rules keep it premium rather than busy:
 *   1. Everything moves on the same few curves and durations, so the product
 *      feels like one thing.
 *   2. Only transform and opacity animate — the GPU handles them and nothing
 *      re-flows, so it stays smooth on a ₹10,000 phone.
 *   3. Movement is small. Things settle into place; they don't fly in.
 *
 * People who ask their device for less motion get none of it.
 * ========================================================================== */

:root{
  --m-out: cubic-bezier(.22, 1, .36, 1);        /* fast start, long soft landing */
  --m-in-out: cubic-bezier(.65, 0, .35, 1);
  --m-spring: cubic-bezier(.34, 1.4, .64, 1);   /* a hint of overshoot, for things that pop */
  --m-fast: 140ms;
  --m-base: 240ms;
  --m-slow: 420ms;
}

/* --------------------------------------------------------------------------
 * Page to page
 * Browsers that support it cross-fade between pages and keep the header (and
 * the app's sidebar) still, so moving around feels like one app, not a series
 * of reloads. Others get a soft fade-up of the page's content instead.
 * ------------------------------------------------------------------------ */
@view-transition { navigation: auto; }

::view-transition-old(root){ animation: m-page-out 160ms var(--m-in-out) both; }
::view-transition-new(root){ animation: m-page-in  320ms var(--m-out) both; }
@keyframes m-page-out{ to   { opacity: 0; transform: translateY(-4px); } }
@keyframes m-page-in { from { opacity: 0; transform: translateY(8px); } }

/* parts that stay put between pages */
.topnav  { view-transition-name: m-topbar; }
.side    { view-transition-name: m-sidebar; }
header.nav { view-transition-name: m-site-header; }
.adm-top { view-transition-name: m-admin-top; }
::view-transition-group(m-topbar), ::view-transition-group(m-sidebar),
::view-transition-group(m-site-header), ::view-transition-group(m-admin-top){ animation-duration: 0s; }

/* where the browser can't, the content still eases in */
html.m-no-vt main,
html.m-no-vt .wrap,
html.m-no-vt .adm-main{ animation: m-page-in 360ms var(--m-out) both; }

/* --------------------------------------------------------------------------
 * Buttons
 * A soft lift on hover, a small press when held, a light sheen across the main
 * ones, and a ripple from wherever the finger or cursor touched.
 * ------------------------------------------------------------------------ */
.btn, .btn-ghost, .lj-b, .lbc-btn, .bk-time, .bk-day, .bill-tab, .tab, .chip-btn{
  transition:
    transform var(--m-base) var(--m-out),
    box-shadow var(--m-base) var(--m-out),
    background-color var(--m-base) var(--m-out),
    border-color var(--m-base) var(--m-out),
    color var(--m-base) var(--m-out),
    filter var(--m-base) var(--m-out),
    opacity var(--m-base) var(--m-out);
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.btn, .btn-ghost, .lj-b{ position: relative; overflow: hidden; isolation: isolate; }

@media (hover: hover){
  .btn:hover:not(:disabled), .lj-b.main:hover{
    transform: translateY(-1.5px);
    box-shadow: 0 10px 24px -12px var(--ring-2), 0 2px 6px -2px var(--sh);
    filter: brightness(1.04) saturate(1.05);
  }
  .btn-ghost:hover:not(:disabled), .lj-b.ghost:hover, .bk-time:hover, .bk-day:hover{
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -10px var(--sh);
  }
}
.btn:active:not(:disabled), .btn-ghost:active:not(:disabled), .lj-b:active,
.bk-time:active, .bk-day:active, .lbc-btn:active, .bill-tab:active{
  transform: translateY(0) scale(.97);
  transition-duration: var(--m-fast);
  box-shadow: none;
}

/* the sheen: a soft band of light that crosses the main button on hover */
.btn::after{
  content:""; position:absolute; inset:0; z-index:-1; pointer-events:none;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.28) 48%, transparent 66%);
  transform: translateX(-120%);
}
@media (hover: hover){ .btn:hover:not(:disabled)::after{ transform: translateX(120%); transition: transform 900ms var(--m-out); } }

/* the ripple, added by motion.js where you press */
.m-ripple{
  position:absolute; border-radius:50%; pointer-events:none; z-index:0;
  background: currentColor; opacity:.22; transform: scale(0);
  animation: m-ripple 560ms var(--m-out) forwards;
}
@keyframes m-ripple{ to { transform: scale(1); opacity: 0; } }

/* a pressed button that is now waiting on the server: its words fade out and
   a small spinner, in the button's own text colour, takes their place */
.m-busy{ pointer-events:none; cursor:progress; color: transparent !important; }
.m-busy::before{
  content:""; position:absolute; z-index:2; top:50%; left:50%; width:16px; height:16px; margin:-8px 0 0 -8px;
  border-radius:50%; border:2px solid var(--m-busy-c, #fff); border-right-color: transparent;
  animation: m-spin 700ms linear infinite;
}
.m-busy .mi, .m-busy svg{ opacity: 0; }
@keyframes m-spin{ to { transform: rotate(360deg); } }

/* keyboard focus: a clear, soft ring — never for mouse clicks */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--ring-1), 0 0 0 1px var(--ring-2);
  border-radius: 10px;
  transition: box-shadow var(--m-fast) var(--m-out);
}

/* --------------------------------------------------------------------------
 * Fields
 * ------------------------------------------------------------------------ */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea{
  transition: border-color var(--m-base) var(--m-out), box-shadow var(--m-base) var(--m-out),
              background-color var(--m-base) var(--m-out);
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):focus, select:focus, textarea:focus{
  box-shadow: 0 0 0 4px var(--ring-0);
}
input[type=checkbox], input[type=radio]{ transition: transform var(--m-fast) var(--m-spring); }
input[type=checkbox]:active, input[type=radio]:active{ transform: scale(.88); }

/* --------------------------------------------------------------------------
 * Links, menus, tabs
 * ------------------------------------------------------------------------ */
a{ transition: color var(--m-base) var(--m-out), opacity var(--m-base) var(--m-out); }

/* menu links: the underline grows from the middle */
.nav-link, .foot-col a{ position: relative; }
.nav-link::after{
  content:""; position:absolute; left:50%; right:50%; bottom:-4px; height:2px; border-radius:2px;
  background: currentColor; opacity:.7; transition: left var(--m-base) var(--m-out), right var(--m-base) var(--m-out);
}
.nav-link:hover::after, .nav-link.on::after{ left:12%; right:12%; }

/* app sidebar: the hovered entry slides a touch; the icon nudges */
.side-nav a{ transition: background-color var(--m-base) var(--m-out), color var(--m-base) var(--m-out), transform var(--m-base) var(--m-out); }
@media (hover: hover){ .side-nav a:hover{ transform: translateX(3px); } }
.side-nav a .mi{ transition: transform var(--m-base) var(--m-spring), font-variation-settings var(--m-base) var(--m-out); }
.side-nav a:hover .mi{ transform: scale(1.12); }

/* tabs in the admins */
.adm-tabs a, .tabs a{ transition: background-color var(--m-base) var(--m-out), color var(--m-base) var(--m-out); }

/* --------------------------------------------------------------------------
 * Cards and rows
 * ------------------------------------------------------------------------ */
.prod, .svc-card, .post-card, .plan, .step, .lch-card, .dstat, .as-card, .bk-done{
  transition: transform var(--m-slow) var(--m-out), box-shadow var(--m-slow) var(--m-out),
              border-color var(--m-base) var(--m-out);
}
@media (hover: hover){
  .prod:hover, .svc-card:hover, .post-card:hover, .plan:hover, .lch-card:hover{
    transform: translateY(-4px);
    box-shadow: 0 22px 40px -24px var(--sh);
  }
  .post-card:hover .post-img img{ transform: scale(1.04); }
}
.post-img{ overflow: hidden; }
.post-img img{ transition: transform 700ms var(--m-out); }

tbody tr{ transition: background-color var(--m-fast) var(--m-out); }

/* --------------------------------------------------------------------------
 * Things that appear: menus, dialogs, flashes, details
 * ------------------------------------------------------------------------ */
.mod-menu:not([hidden]), .nav-drop:not([hidden]), .dropdown:not([hidden]), .menu-pop:not([hidden]){
  animation: m-pop var(--m-base) var(--m-spring) both; transform-origin: top center;
}
.crm-modal:not([hidden]) .crm-modal-card, .modal:not([hidden]) .modal-card, .lj-panel:not([hidden]), .lbc-panel:not([hidden]){
  animation: m-pop 300ms var(--m-spring) both;
}
.crm-modal:not([hidden]), .modal:not([hidden]){ animation: m-fade var(--m-base) var(--m-out) both; }
@keyframes m-pop { from { opacity:0; transform: translateY(6px) scale(.97); } }
@keyframes m-fade{ from { opacity:0; } }

.flash, .alert, .form-err, .flash-ok, .toast{ animation: m-slide-down 380ms var(--m-out) both; }
@keyframes m-slide-down{ from { opacity:0; transform: translateY(-8px); } }

details > summary{ transition: background-color var(--m-base) var(--m-out); }
details[open] > *:not(summary){ animation: m-fade-up 280ms var(--m-out) both; }
@keyframes m-fade-up{ from { opacity:0; transform: translateY(6px); } }

/* --------------------------------------------------------------------------
 * Arriving on screen (website): sections settle in as you scroll to them.
 * Only when motion.js is running, so nothing is ever left invisible.
 * ------------------------------------------------------------------------ */
html.m-js .m-reveal{ opacity: 0; transform: translateY(18px); }
html.m-js .m-reveal.m-in{
  opacity: 1; transform: none;
  transition: opacity 700ms var(--m-out), transform 700ms var(--m-out);
  transition-delay: var(--m-delay, 0ms);
}

/* app: the first cards of a page rise in, one after another */
html.m-js .m-rise{ animation: m-fade-up 420ms var(--m-out) both; animation-delay: var(--m-delay, 0ms); }

/* scrolling to an anchor glides */
html{ scroll-behavior: smooth; }

/* ==========================================================================
 * Ease of use — found by crawling every page of the site and the app
 * ========================================================================== */

/* wide tables scroll inside their own box instead of pushing the page sideways */
.table-wrap, .m-table{ overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
/* rows of header buttons wrap on narrow screens rather than run off the edge */
.crm-head-act, .hr-head-act, .page-actions, .adm-head, .head-actions, .toolbar{ flex-wrap: wrap; }

/* on touch screens, everything you tap is at least a fingertip big */
@media (pointer: coarse){
  select, .btn, .btn-ghost, .mod-pill, .tab, .chip, .pager a, .blog-cats a, .svc-jump a, .lj-t,
  input[type=text], input[type=email], input[type=tel], input[type=number], input[type=search],
  input[type=date], input[type=time], input[type=url], input[type=password], input:not([type]){ min-height: 40px; }
  .foot-col a{ display: inline-block; padding: 6px 0; }
  table select{ min-width: 92px; }
}

/* on phones, nothing you need to read is smaller than 12px */
@media (max-width: 640px){
  small, .fine, .pill, thead th, .dstat span, .helptext small, .post-meta, .bk-day span, .bk-day small,
  .lj-cap-count, .seo-pill, .badge, .tag, .meta, .muted, label small{ font-size: 12px !important; }
}

/* --------------------------------------------------------------------------
 * Less motion, when asked
 * ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce){
  @view-transition { navigation: none; }
  html{ scroll-behavior: auto; }
  *, *::before, *::after{ animation-duration: 1ms !important; animation-iteration-count: 1 !important;
                          transition-duration: 1ms !important; }
  html.m-js .m-reveal{ opacity: 1; transform: none; }
  .m-ripple{ display: none; }
}
