/* Smooth, professional motion for the whole site (public pages, member area and admin):
   pop-up windows, toasts, a soft cross-fade between pages, smooth accordions, header shadow on scroll.
   Everything is calm, quick and switched off for "reduce motion". */

/* ---------- page to page: a soft cross-fade (Chrome, Edge, Safari; others just change page) ---------- */
@view-transition { navigation: auto; }
/* the header, the side menu and the phone bar stay still; only the page's content fades over (owner, Oct 2026: "it shouldn't look like a reload") */
.site-header, .app-top { view-transition-name: site-header; }
.side { view-transition-name: side-menu; }
.phone-bar { view-transition-name: phone-bar; }
::view-transition-group(site-header), ::view-transition-group(side-menu), ::view-transition-group(phone-bar),
::view-transition-new(site-header), ::view-transition-new(side-menu), ::view-transition-new(phone-bar) { animation: none; }
::view-transition-old(site-header), ::view-transition-old(side-menu), ::view-transition-old(phone-bar) { display: none; }
::view-transition-old(root) { animation: .14s ease-out both mt-fade-out; }
::view-transition-new(root) { animation: .22s cubic-bezier(.2, .7, .2, 1) both mt-fade-in; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* the next page is on its way: a thin gold bar along the top (site.js, only after 0.15 s) */
.nav-load { position: fixed; top: 0; left: 0; right: 0; z-index: 2000; height: 3px; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0); opacity: 0;
  background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.nav-load.is-on { opacity: 1; animation: mt-load 12s cubic-bezier(.08, .8, .2, 1) both; }
@keyframes mt-load { 0% { transform: scaleX(0); } 6% { transform: scaleX(.4); } 30% { transform: scaleX(.75); } 100% { transform: scaleX(.94); } }
/* the button that saves: a small spinner after its words (::before with order, as gold buttons use ::after for their shine), and it can't be clicked twice */
.btn.is-sending { pointer-events: none; opacity: .88; }
.btn.is-sending::before { content: ''; flex: none; order: 9; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: mt-spin .7s linear infinite; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---------- header: a soft shadow once you scroll ---------- */
.site-header { transition: box-shadow .3s ease, border-color .3s ease; }
.site-header.is-scrolled { box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .7); }
:root[data-theme="light"] .site-header.is-scrolled { box-shadow: 0 10px 28px -16px rgba(30, 40, 8, .28); }

/* ---------- links and controls: everything eases instead of jumping ---------- */
a, .btn, .chip, .icon-btn, input, select, textarea, .switch input { transition: color .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease, opacity .2s ease; }
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 4px var(--gold-soft); }
.btn:active { transform: translateY(1px) scale(.99); }

/* ---------- phone menu slides down ---------- */
@media (prefers-reduced-motion: no-preference) {
  #mobile-menu:not([hidden]), .mobile-menu:not([hidden]) { animation: mt-menu-in .3s cubic-bezier(.2, .8, .2, 1) both; }
}
@keyframes mt-menu-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- questions open and close smoothly (site.js animates the height) ---------- */
.faq details > :not(summary) { overflow: hidden; }
.faq summary { transition: color .2s ease; }
.faq summary:hover { color: var(--gold); }

/* ======================= pop-up windows ======================= */
.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 24px 16px; }
.modal.is-open { display: flex; }
html.modal-lock { overflow: hidden; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(8px) saturate(1.1); backdrop-filter: blur(8px) saturate(1.1); animation: mt-fade-in .28s ease both; }
:root[data-theme="light"] .modal-backdrop { background: rgba(30, 36, 12, .32); }
.modal-panel { position: relative; width: min(480px, 100%); max-height: min(92vh, 900px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--gold-line); border-radius: 22px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .6), 0 0 0 1px rgba(231, 190, 49, .06); animation: mt-modal-in .38s cubic-bezier(.2, .85, .25, 1) both; }
:root[data-theme="light"] .modal-panel { background: #fff; box-shadow: 0 40px 90px rgba(30, 40, 8, .25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px 14px 22px; background: var(--brand-bg); border-bottom: 1px solid var(--brand-line); }
.modal-head .logo img { height: 40px; }
.modal-head .logo-word b { font-size: 16px; }
.modal-x { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--brand-line); background: transparent; color: var(--brand-text); cursor: pointer;
  transition: background .2s ease, transform .25s ease, color .2s ease; }
.modal-x:hover { background: var(--gold-soft); color: var(--gold); transform: rotate(90deg); }
.modal-body { padding: 22px 26px 26px; overflow-y: auto; overscroll-behavior: contain; }
.modal-body h1 { font: 800 24px/1.2 var(--head); margin: 0 0 6px; }
.modal-body .sub { margin: 0 0 18px; color: var(--text-2); }
.modal-body .auth-foot { margin: 18px 0 0; text-align: center; font-size: 14px; color: var(--text-2); }
.modal-body.is-loading { min-height: 220px; display: grid; place-items: center; }
.modal-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--gold); animation: mt-spin .8s linear infinite; }
.modal.is-closing .modal-panel { animation: mt-modal-out .22s ease both; }
.modal.is-closing .modal-backdrop { animation: mt-fade-out .22s ease both; }
/* "Are you sure?" pop-up */
.modal-confirm .modal-panel { width: min(420px, 100%); }
.modal-confirm .modal-body p { margin: 0 0 20px; font-size: 16px; color: var(--text); }
.modal-confirm .btn-row { justify-content: flex-end; }
@keyframes mt-modal-in { from { opacity: 0; transform: translateY(26px) scale(.96); } }
@keyframes mt-modal-out { to { opacity: 0; transform: translateY(18px) scale(.97); } }
@keyframes mt-fade-in { from { opacity: 0; } }
@keyframes mt-fade-out { to { opacity: 0; } }
@keyframes mt-spin { to { transform: rotate(360deg); } }
/* phones: the pop-up slides up from the bottom like an app sheet */
@media (max-width: 640px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal-panel { width: 100%; max-height: 94vh; border-radius: 22px 22px 0 0; border-bottom: 0; animation-name: mt-sheet-in; }
  .modal.is-closing .modal-panel { animation-name: mt-sheet-out; }
  .modal-body { padding: 20px 18px 24px; }
}
@keyframes mt-sheet-in { from { transform: translateY(100%); } }
@keyframes mt-sheet-out { to { transform: translateY(100%); } }

/* ======================= toasts ======================= */
.toasts { position: fixed; top: 92px; right: 24px; z-index: 1100; width: min(392px, calc(100% - 32px)); display: grid; gap: 10px; pointer-events: none; }
.toast { --tc: var(--ok); position: relative; overflow: hidden; pointer-events: auto; display: grid; grid-template-columns: 34px minmax(0, 1fr) 26px; gap: 12px; align-items: start;
  padding: 14px 12px 16px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: var(--text); font-size: 14px; line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 18px 40px -12px rgba(0, 0, 0, .6); animation: mt-toast-in .55s cubic-bezier(.16, 1, .3, 1) backwards; transition: transform .3s ease, opacity .3s ease; }
:root[data-theme="light"] .toast { background: #fff; box-shadow: 0 1px 2px rgba(30, 40, 8, .05), 0 16px 34px -12px rgba(30, 40, 8, .3); }
.toast-err { --tc: var(--err); }
.toast-warn { --tc: var(--warn, #E0A500); }
.toast-info { --tc: var(--gold); }
.toast-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--tc); background: color-mix(in srgb, var(--tc) 16%, transparent);
  animation: mt-toast-pop .5s .12s cubic-bezier(.34, 1.56, .64, 1) backwards; }
.toast-body { display: grid; gap: 2px; min-width: 0; padding-top: 6px; }
.toast-title { font-weight: 700; color: var(--text); }
.toast-msg { color: var(--text-2); overflow-wrap: anywhere; }
.toast-x { width: 26px; height: 26px; margin-top: 4px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.toast-x:hover { background: var(--surface-2); color: var(--text); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--tc); transform-origin: left; opacity: .8; }
.toast.is-leaving { opacity: 0; transform: translateX(24px); }
@keyframes mt-toast-in { from { opacity: 0; transform: translateX(40px) scale(.98); } }
@keyframes mt-toast-pop { from { transform: scale(.4); opacity: 0; } }
/* without JavaScript, or inside a pop-up, messages sit in the page instead */
html:not(.js) .toasts, .modal-body .toasts, .auth-partial .toasts { position: static; width: auto; margin: 0 0 14px; }
html:not(.js) .toast-bar { display: none; }
@media (max-width: 640px) { .toasts { top: 76px; right: 16px; } }
/* member area and admin have no top bar on wide screens, so messages sit higher */
.app-body .toasts { top: 24px; }
@media (max-width: 980px) { .app-body .toasts { top: 80px; right: 16px; } }

/* ---------- less motion: no animations, still the same pop-ups ---------- */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .modal-panel, .modal-backdrop, .toast, .toast-ico, .modal.is-closing .modal-panel, .modal.is-closing .modal-backdrop { animation: none; }
  .modal-x:hover { transform: none; }
}

/* ---------- page intros rise in when a page opens ---------- */
@media (prefers-reduced-motion: no-preference) {
  .motion .mt-enter { animation: mt-rise .7s cubic-bezier(.2, .7, .2, 1) both; }
  .motion .mt-enter + .mt-enter { animation-delay: .08s; }
}

/* ---------- phones: "Create account" (or My account / Admin) stays in the top bar; the theme switch moves into the menu ---------- */
.head-theme { display: contents; }
@media (max-width: 640px) {
  .site-header .head-theme { display: none; }
  .site-header .head-join { padding-inline: 13px; white-space: nowrap; }
  /* "Sign in" lives in the menu on phones (owner, Oct 2026: on a 412px Android the bar ran off the screen) */
  .site-header .head-actions .hide-xs { display: none !important; }
}
@media (max-width: 380px) {
  .site-header .logo-word { display: none; }   /* the logo itself already says MAGICTRADE */
}

/* footer: a long email address wraps instead of pushing the page wider than the screen */
.foot-grid > * { min-width: 0; }
.foot-contact a, .foot-contact span { overflow-wrap: anywhere; }
