/* my-gui modes: scroll lock, reduced motion, right-to-left, forced colours (high contrast), print.
   Loaded last (my-gui.css), so that these rules win over the component files at equal specificity.
   Wishlist 4, "Amit a Mortar nem tud" 3, 4, 5, 11, 12. */

/* ---------- scroll lock (ui.js: open modal) ---------- */

/* the hidden scrollbar's width comes back as padding: the page does not jump sideways */
:root.m-modal-lock { padding-inline-end: var(--m-scrollbar, 0px); }
/* a scroll that reaches the end of the modal does not carry on to the page behind it */
.m-modal, .m-modal-body, .m-menu, .m-palette-list { overscroll-behavior: contain; }

/* ---------- reduced motion ----------
   Decided (wl-controls, wishlist 4. pótlás 4): short transitions (colour, opacity, the segment indicator, small
   hover moves) stay, because they carry meaning and the setting is common; large movement (sliding in, flying,
   tilting, springing, flipping) turns into a fade; endless animations stop. JS-driven motion reads the same
   media query (MyGUI._kit.reduced()). */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  /* large movement -> fade */
  .m-toast { animation-name: m-fade-in; }
  .m-toast.is-out, .m-toast.is-swiped-start, .m-toast.is-swiped-end { transform: none; }
  .m-modal-box { transform: none; transition: opacity var(--m-t) var(--m-ease); }
  .m-tabpanel:not([hidden]), .m-rise { animation-name: m-fade-in; }
  .m-flip-inner { transition: none; }
  .m-flip-face { transition: opacity var(--m-t) var(--m-ease); }
  .m-reorder-item { transition-timing-function: var(--m-ease) !important; }
  .m-collapse::details-content { transition: none; }
  @media (max-width: 767px) {
    .m-sidenav { transform: none; opacity: 0; visibility: hidden; transition: opacity var(--m-t) var(--m-ease), visibility var(--m-t); }
    .m-shell.is-nav-open .m-sidenav { opacity: 1; visibility: visible; }
  }

  /* endless animations stop (a still frame of each stays visible) */
  .m-skel, .m-skel-line, .m-status--live::before, .m-spinner, .m-loader, .m-loader *, .m-loader::before, .m-loader::after,
  .m-thinking i, .m-typing::after, .m-btn[data-m-state="busy"]::after {
    animation: none !important;
  }
}

@keyframes m-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- right-to-left (wishlist 4. pótlás 5) ----------
   New kit parts use logical properties (inline-start / inline-end), so they mirror by themselves; these are the
   older physical rules that need a mirror. ui.js mirrors the arrow keys of the segmented switch and the tabs. */
[dir="rtl"] .m-menu { left: auto; right: 0; }
[dir="rtl"] .m-menu--right { right: auto; left: 0; }
[dir="rtl"] .m-crumbs .m-chev, [dir="rtl"] .m-row .m-chev { transform: scaleX(-1); }
@media (max-width: 767px) {
  [dir="rtl"] .m-sidenav { left: auto; right: 0; transform: translateX(102%); }
  [dir="rtl"] .m-shell.is-nav-open .m-sidenav { transform: none; }
}

/* ---------- forced colours / Windows high contrast (4. pótlás 11) ----------
   The core components are covered by wl-look's css/forced-colors.css; these are the wl-controls parts only.
   Materials (shadows, glass) disappear, so the new surfaces get a system-coloured border, chosen states use
   Highlight, and bars / dots keep a visible fill. */
@media (forced-colors: active) {
  .m-avatar, .m-palette-box, .m-flip-face, .m-ai-input, .m-msg--user .m-msg-body, .m-selbar, .m-knob-cap,
  .m-compare, .m-reorder-item, .m-collapse, .m-sources, .m-ai-mark, .m-cite, .m-scrub {
    border: 1px solid CanvasText;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .m-tablist > [role="tab"][aria-selected="true"], .m-palette-item[aria-selected="true"], .m-table tbody tr.is-sel td,
  .m-sub > .m-mi[aria-expanded="true"] {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }
  .m-tab-ind, .m-knob-fill, .m-knob-led { forced-color-adjust: none; background: Highlight; stroke: Highlight; }
  .m-stepper-dot, .m-confidence-bars i { forced-color-adjust: none; border: 1px solid CanvasText; background: Canvas; color: CanvasText; }
  .m-stepper-step.is-done .m-stepper-dot, .m-stepper-step[aria-current="step"] .m-stepper-dot, .m-confidence-bars i.is-on {
    background: Highlight;
    color: HighlightText;
  }
  .m-spinner, .m-loader, .m-thinking-dots, .m-typing::after { forced-color-adjust: none; color: Highlight; border-block-start-color: Highlight; }
  .m-typing::after { background: Highlight; }
  .m-thinking-text { color: CanvasText; background: none; }
  .m-compare-handle, .m-compare-handle::before { forced-color-adjust: none; background: Highlight; }
  .m-reorder-item.is-grabbed, .m-reorder-item.is-dragging { outline: 2px solid Highlight; }
  .m-chart-plot > svg[tabindex]:focus-visible, .m-knob:focus-visible, .m-tabpanel:focus-visible { outline: 2px solid Highlight; }
}

/* ---------- print (wishlist 4. pótlás 12) ----------
   Any theme prints as the light theme on white paper (text, line and accent values repeat tokens.css :root;
   tests/modes.test.mjs keeps them equal); the app chrome, toasts, menus, tooltips and closed overlays are not printed; the main area flows
   over pages instead of scrolling. */
@media print {
  html:root:root:root {
    color-scheme: light;
    --m-bg: #FFFFFF;
    --m-bg-solid: #FFFFFF;
    --m-card: #FFFFFF;
    --m-card-solid: #FFFFFF;
    --m-modal: #FFFFFF;
    --m-raise: #FFFFFF;
    --m-solid: #FFFFFF;
    --m-panel: #FFFFFF;
    --m-glass: #FFFFFF;
    --m-glass-strong: #FFFFFF;
    --m-glass-edge: rgba(24,34,56,.1);
    --m-well: #F4F6FA;
    --m-text: #151B28;
    --m-text-2: #4B5366;
    --m-text-3: #6E7586;
    --m-line: rgba(24,34,56,.1);
    --m-line-strong: rgba(24,34,56,.24);
    --m-grid: rgba(24,34,56,.07);
    --m-axis: rgba(24,34,56,.2);
    --m-ink: 24,32,48;
    --m-shade: 24,34,56;
    --m-sk: .32;
    --m-accent: #1F6FE0;
    --m-accent-rgb: 31,111,224;
    --m-accent-wash: rgba(31,111,224,.09);
    --m-good-text: #0A7F0A;
    --m-warn-text: #9A6700;
    --m-danger-text: #C8243C;
    --m-est-ink: #5E35B1;
    --m-tip: #1E2330;
    --m-tip-text: #F2F4F8;
  }
  html, body, .m-page { background: #FFFFFF !important; color: var(--m-text); }
  .m-topbar, .m-sidenav, .m-statusbar, .m-nav-toggle, .m-toasts, .m-menu, .m-ctx, .m-modal:not(.is-open),
  .m-palette, .m-selbar[hidden], .m-chart-tip, [data-m-noprint] {
    display: none !important;
  }
  [data-tip]::after { display: none !important; }
  .m-shell { display: block; height: auto; }
  .m-main { overflow: visible; padding: 0; }
  .m-modal.is-open { position: static; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .m-card, .m-stat, .m-table-card, .m-toast, .m-modal-box, .m-btn, .m-input, .m-seg, .m-tag, .m-badge {
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .m-card, .m-stat, .m-table-card, .m-modal-box { border: 1px solid var(--m-line-strong); }
  .m-card, .m-stat, .m-chart, .m-table tr, .m-flip, .m-msg { break-inside: avoid; }
  .m-chart, .m-progress, .m-stepper, .m-avatar, .m-status { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .m-skel, .m-spinner, .m-loader { animation: none !important; }
  .m-flip-back { display: none; }
  .m-flip-inner { transform: none !important; }
}
