/* ============================================================
   MEDICAL TRAINING — wersja mobilna jak aplikacja
   Pasek kart, arkusz „Menu”, pasek zakupu, kompaktowy nagłówek.
   Działa do 980 px (tam, gdzie nagłówek strony pokazuje hamburger).
   Znaczniki drukuje inc/mobile.php, zachowanie — assets/js/mt-app.js.
   ============================================================ */

.mtc-app,
.mtc-appbar-akcja,
.mtc-appbar-wstecz { display: none; }
.mtc-ikona { display: block; flex-shrink: 0; }

@media (max-width: 980px) {

  /* ---------- Tokeny (z zapasem, gdyby arkusz strony głównej nie doszedł) ---------- */
  :root {
    --mt-nav-h: 56px;
    --mtc-bg: var(--mt-bg, #0D0D0F);
    --mtc-bg1: var(--mt-bg-1, #141416);
    --mtc-bg2: var(--mt-bg-2, #1A1A1E);
    --mtc-bg3: var(--mt-bg-3, #222226);
    --mtc-line: var(--mt-line, rgba(255,255,255,.08));
    --mtc-line2: var(--mt-line-2, rgba(255,255,255,.14));
    --mtc-text: var(--mt-text, #EDEAE5);
    --mtc-text-m: var(--mt-text-m, #9B968E);
    --mtc-text-d: var(--mt-text-d, #686460);
    --mtc-fire: var(--mt-fire, #FF4D1C);
    --mtc-fire2: var(--mt-fire-2, #FF6B3D);
    --mtc-fire-g: var(--mt-fire-g, rgba(255,77,28,.14));
    --mtc-font: var(--mt-font-body, 'Plus Jakarta Sans', system-ui, sans-serif);
    --mtc-font-d: var(--mt-font-display, 'Instrument Sans', system-ui, sans-serif);
    --mtc-tab-h: 64px;
    --mtc-dol: calc(var(--mtc-tab-h) + env(safe-area-inset-bottom, 0px));
    --mtc-ease: cubic-bezier(.2, .8, .2, 1);
  }

  .mtc-app {
    display: block;
    font-family: var(--mtc-font);
    -webkit-font-smoothing: antialiased;
  }
  .mtc-app *, .mtc-app *::before, .mtc-app *::after { box-sizing: border-box; }

  html { -webkit-tap-highlight-color: transparent; }

  /* Treść nie chowa się pod paskiem kart. */
  body.mtc-app-on:not(.mtc-bez-paska) { padding-bottom: var(--mtc-dol) !important; }
  body.mtc-app-on.mtc-cta-on:not(.mtc-bez-paska) { padding-bottom: calc(var(--mtc-dol) + 84px) !important; }
  body.mtc-app-on.mtc-cta-on.mtc-bez-paska { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px) !important; }

  /* Dawny dolny pasek ze snippetu WP Code (Tutor 2.x) — zastąpiony przez ten. */
  body.mtc-app-on #mt-mobile-nav { display: none !important; }

  /* ---------- Nagłówek jako pasek aplikacji ---------- */
  body.mtc-app-on .mt-topbar { display: none !important; }
  body.mtc-app-on .mt-nav-inner {
    height: 56px !important;
    gap: 10px;
  }
  body.mtc-app-on .mt-logo { margin-right: auto; min-width: 0; }
  /* Plik logo ma szerokie ciemne marginesy (znak zajmuje ok. 65% × 50% obrazka),
     więc w niskim pasku przycinamy je powiększeniem wewnątrz okienka. */
  body.mtc-app-on .mt-logo-mark {
    width: var(--mtc-logo-w, 88px) !important;
    height: var(--mtc-logo-h, 46px) !important;
    border-radius: 8px;
    overflow: hidden;
  }
  body.mtc-app-on .mt-logo-mark img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transform: scale(var(--mtc-logo-zoom, 1.5));
  }
  body.mtc-app-on .mt-nav-right,
  body.mtc-app-on .mt-hmb,
  body.mtc-app-on .mt-mobile-menu,
  body.mtc-app-on .mt-nav .gtranslate_wrapper { display: none !important; }

  .mtc-appbar-akcja,
  .mtc-appbar-wstecz {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid var(--mtc-line2);
    background: var(--mtc-bg2);
    color: var(--mtc-text);
    text-decoration: none;
    transition: transform .15s var(--mtc-ease), background .2s;
  }
  .mtc-appbar-akcja .mtc-ikona,
  .mtc-appbar-wstecz .mtc-ikona { width: 20px; height: 20px; }
  .mtc-appbar-akcja:active,
  .mtc-appbar-wstecz:active { transform: scale(.92); background: var(--mtc-bg3); }
  .mtc-appbar-wstecz { display: none; margin-right: 2px; }
  body.mtc-standalone .mtc-appbar-wstecz { display: inline-flex; }

  /* ---------- Pasek kart ---------- */
  .mtc-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    height: var(--mtc-dol);
    padding: 6px 6px env(safe-area-inset-bottom, 0px);
    background: rgba(13, 13, 15, .88);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--mtc-line);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .35);
    transition: transform .25s var(--mtc-ease);
  }
  .mtc-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    min-width: 0;
    height: 52px;
    padding: 2px 0 0;
    border: 0;
    border-radius: 14px;
    background: none;
    color: var(--mtc-text-m);
    font: 600 11px/1.1 var(--mtc-font);
    letter-spacing: .01em;
    text-decoration: none !important;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
  }
  .mtc-tab-ikona {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 30px;
    border-radius: 999px;
    transition: background .2s, color .2s, transform .15s var(--mtc-ease);
  }
  .mtc-tab-ikona .mtc-ikona { width: 23px; height: 23px; }
  .mtc-tab-nazwa {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mtc-tab.is-active { color: var(--mtc-text); }
  .mtc-tab.is-active .mtc-tab-ikona { background: var(--mtc-fire-g); color: var(--mtc-fire); }
  .mtc-tab:active .mtc-tab-ikona { transform: scale(.9); }
  .mtc-tab:focus-visible { outline: 2px solid var(--mtc-fire); outline-offset: -2px; }
  .mtc-tab[aria-expanded="true"] .mtc-tab-ikona { background: var(--mtc-bg3); color: var(--mtc-text); }

  /* ---------- Arkusz od dołu ---------- */
  .mtc-sheet {
    position: fixed;
    inset: 0;
    z-index: 9995;
    display: none;
  }
  .mtc-sheet.is-open,
  .mtc-sheet:target { display: block; }

  .mtc-sheet-tlo {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    opacity: 0;
    transition: opacity .28s ease;
    cursor: default;
  }
  .mtc-sheet.is-visible .mtc-sheet-tlo,
  .mtc-sheet:target .mtc-sheet-tlo { opacity: 1; }

  .mtc-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px calc(20px + env(safe-area-inset-bottom, 0px));
    background: var(--mtc-bg1);
    border-top: 1px solid var(--mtc-line2);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -24px 60px rgba(0, 0, 0, .55);
    color: var(--mtc-text);
    transform: translateY(100%);
    transition: transform .34s var(--mtc-ease);
    outline: none;
  }
  .mtc-sheet.is-visible .mtc-sheet-panel,
  .mtc-sheet:target .mtc-sheet-panel { transform: translateY(var(--mtc-przesuniecie, 0px)); }
  .mtc-sheet.is-dragging .mtc-sheet-panel { transition: none; }

  .mtc-sheet-uchwyt {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    margin: 0 -16px;
    padding: 10px 0 6px;
    background: var(--mtc-bg1);
    touch-action: none;
    cursor: grab;
  }
  .mtc-sheet-uchwyt span {
    width: 40px;
    height: 5px;
    border-radius: 99px;
    background: var(--mtc-line2);
  }
  .mtc-sheet-glowa {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px 14px;
    touch-action: none;
  }
  .mtc-sheet-glowa h2 {
    margin: 0;
    font: 800 26px/1.1 var(--mtc-font-d);
    letter-spacing: -.02em;
    color: var(--mtc-text) !important;
  }
  .mtc-sheet-zamknij {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--mtc-bg3);
    color: var(--mtc-text) !important;
    text-decoration: none;
  }
  .mtc-sheet-zamknij .mtc-ikona { width: 20px; height: 20px; }

  .mtc-sheet-szybkie {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 22px;
  }
  .mtc-szybka {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    padding: 14px 12px 12px;
    border-radius: 16px;
    background: var(--mtc-bg2);
    border: 1px solid var(--mtc-line);
    color: var(--mtc-text) !important;
    text-decoration: none !important;
    transition: transform .15s var(--mtc-ease), border-color .2s;
  }
  .mtc-szybka:first-child { background: var(--mtc-fire); border-color: var(--mtc-fire); color: #0A0A0A !important; }
  .mtc-szybka:first-child small { color: rgba(10, 10, 10, .72); }
  .mtc-szybka:active { transform: scale(.96); }
  .mtc-szybka-ikona { margin-bottom: 8px; }
  .mtc-szybka-ikona .mtc-ikona { width: 22px; height: 22px; }
  .mtc-szybka strong { font: 700 15px/1.2 var(--mtc-font); }
  .mtc-szybka small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--mtc-text-m);
  }

  .mtc-sheet-grupa { margin-bottom: 18px; }
  .mtc-sheet-grupa h3 {
    margin: 0 4px 8px;
    font: 500 11px/1 var(--mt-font-mono, ui-monospace, monospace);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--mtc-text-d) !important;
  }
  .mtc-sheet-grupa ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--mtc-bg2);
    border: 1px solid var(--mtc-line);
  }
  .mtc-sheet-grupa li + li { border-top: 1px solid var(--mtc-line); }
  .mtc-sheet-grupa li a {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 54px;
    padding: 8px 14px;
    color: var(--mtc-text) !important;
    font: 600 15px/1.25 var(--mtc-font);
    text-decoration: none !important;
    transition: background .15s;
  }
  .mtc-sheet-grupa li a:active { background: var(--mtc-bg3); }
  .mtc-link-ikona {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--mtc-fire-g);
    color: var(--mtc-fire);
  }
  .mtc-link-ikona .mtc-ikona { width: 19px; height: 19px; }
  .mtc-link-nazwa { flex: 1; min-width: 0; }
  .mtc-sheet-grupa li a > .mtc-ikona { width: 18px; height: 18px; color: var(--mtc-text-d); }

  .mtc-sheet-jezyk[hidden] { display: none !important; }
  .mtc-sheet-jezyk .gtranslate_wrapper {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--mtc-bg2);
    border: 1px solid var(--mtc-line);
  }
  .mtc-sheet-jezyk .gtranslate_wrapper a { display: inline-flex; padding: 4px; border-radius: 8px; }
  .mtc-sheet-jezyk .gtranslate_wrapper img { width: 32px !important; height: auto !important; }

  .mtc-sheet-stopka {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 6px 4px 4px;
  }
  .mtc-sheet-stopka a,
  .mtc-sheet-stopka button {
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--mtc-text-m) !important;
    font: 500 13px/1.3 var(--mtc-font);
    text-decoration: underline;
    text-decoration-color: var(--mtc-line2);
    text-underline-offset: 3px;
    cursor: pointer;
  }
  .mtc-sheet-stopka [hidden] { display: none !important; }

  html.mtc-zablokowane,
  html.mtc-zablokowane body { overflow: hidden !important; }

  /* ---------- Pasek zakupu ---------- */
  .mtc-cta {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--mtc-dol) + 10px);
    z-index: 9980;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    border-radius: 18px;
    background: rgba(30, 30, 34, .94);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--mtc-line2);
    box-shadow: 0 14px 36px rgba(0, 0, 0, .5);
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .22s ease, transform .28s var(--mtc-ease);
    pointer-events: none;
  }
  .mtc-cta[hidden] { display: none; }
  .mtc-cta.is-visible { opacity: 1; transform: none; pointer-events: auto; }
  body.mtc-bez-paska .mtc-cta { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  .mtc-cta-opis { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .mtc-cta-cena {
    font: 800 18px/1.1 var(--mtc-font-d);
    color: var(--mtc-text);
    white-space: nowrap;
  }
  .mtc-cta-tytul {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--mtc-text-m);
  }
  .mtc-cta-btn {
    flex-shrink: 0;
    min-height: 48px;
    max-width: 58%;
    padding: 0 20px;
    border: 0;
    border-radius: 13px;
    background: var(--mtc-fire);
    color: #0A0A0A;
    font: 700 15px/1.1 var(--mtc-font);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: transform .15s var(--mtc-ease), background .2s;
  }
  .mtc-cta-btn:active { transform: scale(.96); background: var(--mtc-fire2); }

  /* Klawiatura na ekranie: paski nie wiszą nad polem, w którym się pisze. */
  body.mtc-pisanie .mtc-tabbar { transform: translateY(110%); }
  body.mtc-pisanie .mtc-cta { opacity: 0; pointer-events: none; }

  /* ---------- Dopracowanie dotykowe ---------- */
  body.mtc-app-on .mt-btn:active,
  body.mtc-app-on .mt-course-card:active,
  body.mtc-app-on .mt-blog-card:active { transform: scale(.98); }

  body.mtc-app-on input[type="text"],
  body.mtc-app-on input[type="email"],
  body.mtc-app-on input[type="tel"],
  body.mtc-app-on input[type="search"],
  body.mtc-app-on input[type="password"],
  body.mtc-app-on input[type="number"],
  body.mtc-app-on input[type="url"],
  body.mtc-app-on select,
  body.mtc-app-on textarea { font-size: 16px !important; } /* iOS nie powiększa strony przy wpisywaniu */

  /* Rzędy filtrów przewijane palcem jak w aplikacji. */
  body.mtc-app-on .mt-filters-left,
  body.mtc-app-on .mt-blog-filters,
  body.mtc-app-on .mt-terms-filters,
  body.mtc-app-on .mt-course-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  body.mtc-app-on .mt-filters-left::-webkit-scrollbar,
  body.mtc-app-on .mt-blog-filters::-webkit-scrollbar,
  body.mtc-app-on .mt-terms-filters::-webkit-scrollbar,
  body.mtc-app-on .mt-course-tabs::-webkit-scrollbar { display: none; }
  body.mtc-app-on .mt-filters-left > *,
  body.mtc-app-on .mt-blog-filters > *,
  body.mtc-app-on .mt-terms-filters > *,
  body.mtc-app-on .mt-course-tabs > * { flex-shrink: 0; scroll-snap-align: start; }
}

/* ---------- Zainstalowana aplikacja (ekran główny) ---------- */
@media (max-width: 980px) and (display-mode: standalone) {
  body.mtc-app-on .mt-nav { padding-top: env(safe-area-inset-top, 0px); }
}

/* ---------- Płynne przejścia między stronami ---------- */
@media (max-width: 980px) and (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .mtc-tabbar { view-transition-name: mtc-tabbar; }
  body.mtc-app-on .mt-nav { view-transition-name: mtc-appbar; }
  ::view-transition-old(root) { animation: mtc-znikanie .16s ease both; }
  ::view-transition-new(root) { animation: mtc-pojawianie .22s var(--mtc-ease) both; }
}
@keyframes mtc-znikanie { to { opacity: 0; } }
@keyframes mtc-pojawianie { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  .mtc-sheet-tlo,
  .mtc-sheet-panel,
  .mtc-cta,
  .mtc-tabbar { transition: none !important; }
}
