/*
 * MYK Sınav — mobil uygulama (PWA) katmanı (CLAUDE 203).
 * Kurulum daveti, izinler sayfası, ana ekrandan açılışta (standalone) uygulama hissi.
 * Masaüstü (≥768px) yerleşimine dokunmaz; sayfa/tab bar kuralları CLAUDE 181.3'te.
 */
:root { --app-accent: #1173c9; --app-accent-soft: #e8f3fd; --app-ink: #0f172a; --app-muted: #64748b; }
html[data-app-kind="student"] { --app-accent: #1173c9; --app-accent-soft: #e8f3fd; --app-ink: #16212e; }

/* ───────── alt sayfa (sheet) iskeleti ───────── */
.mapp-backdrop {
    position: fixed; inset: 0; z-index: 9990; background: rgba(15, 23, 42, .45);
    opacity: 0; transition: opacity .22s ease; -webkit-tap-highlight-color: transparent;
}
.mapp-backdrop.on { opacity: 1; }
.mapp-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9991;
    max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
    background: #fff; color: var(--app-ink);
    border-radius: 22px 22px 0 0; box-shadow: 0 -12px 40px rgba(15, 23, 42, .18);
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.mapp-sheet.on { transform: translateY(0); }
.mapp-sheet *, .mapp-sheet *::before, .mapp-sheet *::after { box-sizing: border-box; }
.mapp-grab { width: 40px; height: 5px; border-radius: 99px; background: #e2e8f0; margin: 0 auto 12px; }
.mapp-x {
    position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 999px;
    background: transparent; color: #94a3b8; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.mapp-x:active { background: #f1f5f9; }
.mapp-x svg { width: 20px; height: 20px; }
@media (min-width: 768px) {
    .mapp-sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 440px; border-radius: 20px;
        transform: translate(-50%, -46%); opacity: 0; transition: transform .22s ease, opacity .22s ease; padding-bottom: 20px; }
    .mapp-sheet.on { transform: translate(-50%, -50%); opacity: 1; }
    .mapp-grab { display: none; }
}

.mapp-head { display: flex; align-items: center; gap: 12px; padding-right: 40px; }
.mapp-icon { width: 56px; height: 56px; border-radius: 14px; flex: 0 0 auto; box-shadow: 0 4px 14px rgba(15, 23, 42, .14); background: #fff; }
.mapp-title { font-size: 17px; font-weight: 700; line-height: 1.25; margin: 0; }
.mapp-sub { font-size: 13.5px; color: var(--app-muted); line-height: 1.45; margin: 4px 0 0; }
.mapp-benefits { list-style: none; margin: 14px 0 4px; padding: 0; display: grid; gap: 8px; }
.mapp-benefits li { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: #334155; }
.mapp-benefits svg { width: 18px; height: 18px; color: var(--app-accent); flex: 0 0 auto; }
.mapp-actions { display: flex; gap: 10px; margin-top: 16px; }
.mapp-btn {
    flex: 1 1 0; min-height: 48px; border-radius: 14px; border: 0; font: 600 15px/1 'Inter', system-ui, sans-serif;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 0 16px;
    -webkit-tap-highlight-color: transparent; transition: transform .12s ease, filter .12s ease;
}
.mapp-btn:active { transform: scale(.97); }
.mapp-btn-primary { background: var(--app-accent); color: #fff; box-shadow: 0 6px 16px rgba(17, 115, 201, .25); }
.mapp-btn-ghost { background: #f1f5f9; color: #334155; }
.mapp-btn svg { width: 18px; height: 18px; }

/* iOS "Ana Ekrana Ekle" adımları */
.mapp-steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; counter-reset: st; }
.mapp-steps li {
    display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: #f8fafc;
    font-size: 14px; line-height: 1.4; color: #1e293b; counter-increment: st;
}
.mapp-steps li::before {
    content: counter(st); width: 26px; height: 26px; flex: 0 0 auto; border-radius: 999px; background: var(--app-accent);
    color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.mapp-steps .mapp-glyph {
    margin-left: auto; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; background: #fff;
    border: 1px solid #e2e8f0; color: #0a84ff; display: flex; align-items: center; justify-content: center;
}
.mapp-steps .mapp-glyph svg { width: 20px; height: 20px; }
.mapp-note { margin: 12px 0 0; font-size: 12.5px; color: var(--app-muted); line-height: 1.45; }
.mapp-arrow {
    position: fixed; left: 50%; bottom: calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 9992; margin-left: -14px;
    width: 28px; height: 28px; color: #fff; pointer-events: none; animation: mappBob 1.1s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}
@keyframes mappBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* İzinler */
.mapp-perms { display: grid; gap: 10px; margin-top: 16px; }
.mapp-perm { border: 1px solid #e2e8f0; border-radius: 16px; padding: 12px; }
.mapp-perm.prio { border-color: var(--app-accent); background: var(--app-accent-soft); }
.mapp-perm-row { display: flex; align-items: center; gap: 12px; }
.mapp-perm-ico { width: 42px; height: 42px; border-radius: 12px; background: #fff; border: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: center; color: var(--app-accent); flex: 0 0 auto; }
.mapp-perm-ico svg { width: 22px; height: 22px; }
.mapp-perm-txt { flex: 1 1 auto; min-width: 0; }
.mapp-perm-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mapp-perm-desc { font-size: 12.5px; color: var(--app-muted); line-height: 1.4; margin-top: 2px; }
.mapp-tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--app-accent); color: #fff; }
.mapp-state { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.mapp-state.granted { background: #dcfce7; color: #15803d; }
.mapp-state.denied { background: #ffe4e6; color: #be123c; }
.mapp-state.prompt { background: #f1f5f9; color: #475569; }
.mapp-state.unsupported { background: #f1f5f9; color: #94a3b8; }
.mapp-perm-btn {
    flex: 0 0 auto; min-height: 44px; min-width: 92px; padding: 0 14px; border-radius: 12px; border: 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap;
    font: 600 14px/1 'Inter', system-ui, sans-serif; background: var(--app-accent); color: #fff; cursor: pointer;
}
.mapp-perm-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.mapp-perm-btn[disabled] { background: #e2e8f0; color: #64748b; cursor: default; }
.mapp-perm-btn.ghost { background: #fff; color: #be123c; border: 1px solid #fecdd3; }
.mapp-help { display: none; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #fff7ed; color: #9a3412;
    font-size: 12.5px; line-height: 1.5; }
.mapp-perm.show-help .mapp-help { display: block; }
.mapp-link { background: none; border: 0; padding: 10px 0 0; color: var(--app-muted); font-size: 12.5px; text-decoration: underline; cursor: pointer; }

/* Profil/menü kısayolu kartı */
.mapp-entry { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; min-height: 56px;
    border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.mapp-entry:active { background: #f8fafc; }

/* Aşağı çekip yenile (yalnız ana ekrandan açılışta) */
.mapp-ptr {
    position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 9980; width: 40px; height: 40px; margin-left: -20px;
    border-radius: 999px; background: #fff; box-shadow: 0 4px 16px rgba(15, 23, 42, .18); display: flex; align-items: center; justify-content: center;
    color: var(--app-accent); transform: translateY(-64px); opacity: 0; pointer-events: none;
}
.mapp-ptr svg { width: 20px; height: 20px; }
.mapp-ptr.spin svg { animation: mappSpin .7s linear infinite; }
@keyframes mappSpin { to { transform: rotate(360deg); } }

/* Karanlık tema (yönetim paneli) */
[data-theme="dark"] .mapp-sheet { background: #0f172a; color: #e2e8f0; }
[data-theme="dark"] .mapp-steps li, [data-theme="dark"] .mapp-btn-ghost { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .mapp-perm, [data-theme="dark"] .mapp-perm-ico, [data-theme="dark"] .mapp-entry { border-color: #334155; background: #111827; }
[data-theme="dark"] .mapp-perm.prio { background: #1e1b4b; }
[data-theme="dark"] .mapp-benefits li { color: #cbd5e1; }

/* ───────── telefonda uygulama hissi ───────── */
@media (max-width: 767px) {
    /* Sayfalar arası yumuşak geçiş (destekleyen tarayıcıda; alt/üst çubuk sabit kalır) */
    @view-transition { navigation: auto; }
    ::view-transition-old(root) { animation: mappOut .14s ease-in both; }
    ::view-transition-new(root) { animation: mappIn .2s ease-out both; }
    #mob-tabbar, .st-tabbar { view-transition-name: app-tabbar; }
    #app-navbar, body > div > header.sticky { view-transition-name: app-topbar; }

    /* Dokunma hedefleri ≥44px: üst çubuk simge düğmelerine görünmez dokunma alanı (yerleşim değişmez) */
    #app-navbar button.h-9.w-9, header.sticky a.p-2, header.sticky button.p-2 { position: relative; }
    #app-navbar button.h-9.w-9::after, header.sticky a.p-2::after, header.sticky button.p-2::after {
        content: ''; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%);
    }
    #app-navbar #mob-back, #stBack { min-width: 44px; min-height: 44px; }
    /* Uygulama çubukları basılı tutunca metin seçimi/menü açmasın */
    #mob-tabbar, .st-tabbar, #app-navbar, body > div > header.sticky { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
@keyframes mappOut { to { opacity: 0; } }
@keyframes mappIn { from { opacity: 0; transform: translateY(6px); } }

/* Ana ekrandan açılış: lastik bant/zincirleme kaydırma yok, çentik payı */
@media (display-mode: standalone) {
    html, body { overscroll-behavior-y: none; }
    main { overscroll-behavior-y: contain; }
    body { -webkit-tap-highlight-color: transparent; }
    #app-navbar, body > div > header.sticky { padding-top: env(safe-area-inset-top, 0px); }
    #app-navbar { height: calc(60px + env(safe-area-inset-top, 0px)) !important; }
}
@media (prefers-reduced-motion: reduce) {
    .mapp-sheet, .mapp-backdrop { transition: none; }
    .mapp-arrow { animation: none; }
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
    html.mapp-splashing::before, html.mapp-splashing::after { animation: none; }
}

/* ───────── açılış animasyonu (splash) — yalnız ana ekrandan (standalone) ─────────
 * _head.php (standalone + reduced-motion değil) <html>'e .mapp-splashing ekler; myk-app.js
 * içerik hazır olunca .mapp-splash-done ile yumuşakça kaldırır. İlk boyadan itibaren görünür.
 */
:root { --app-splash-bg: #ffffff; }
html[data-app-kind="student"] { --app-splash-bg: #f2f6fb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --app-splash-bg: #0f172a; } }
:root[data-theme="dark"] { --app-splash-bg: #0f172a; }
@media (display-mode: standalone), (display-mode: fullscreen) {
    html.mapp-splashing::before {
        content: ''; position: fixed; inset: 0; z-index: 2147483646;
        /* Logo ::before arka planında: iOS'un statik açılış görseliyle (aynı logo, aynı boyut)
           kesintisiz birleşir; ::after yalnız dönen halkadır. */
        background: url('/assets/img/app-icon-512.png?v=3') center / 116px 116px no-repeat var(--app-splash-bg);
        transition: opacity .45s ease; padding-top: env(safe-area-inset-top, 0px);
    }
    html.mapp-splashing::after {
        content: ''; position: fixed; z-index: 2147483647; left: 50%; top: 50%;
        width: 148px; height: 148px; margin: -74px 0 0 -74px; border-radius: 50%;
        border: 3px solid rgba(30, 136, 210, .18); border-top-color: #1e88d2;
        animation: mappSplashSpin .9s linear infinite;
        transition: opacity .35s ease;
    }
    html.mapp-splash-done::before, html.mapp-splash-done::after { opacity: 0; pointer-events: none; }
}
@keyframes mappSplashSpin { to { transform: rotate(360deg); } }

/* ───────── "Uygulamayı yükle" butonu (giriş sayfaları + panel) ─────────
 * myk-app.js [data-app-install] öğelerini yalnız kurulabilir telefonda gösterir (canInstall).
 */
.mapp-install-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    min-height: 48px; padding: 0 18px; border: 0; border-radius: 14px; cursor: pointer;
    font: 600 15px/1 'Inter', system-ui, -apple-system, sans-serif;
    color: #fff; background: var(--app-accent); box-shadow: 0 6px 18px rgba(17, 115, 201, .25);
    -webkit-tap-highlight-color: transparent; transition: transform .12s ease, filter .12s ease;
}
.mapp-install-btn:active { transform: scale(.97); }
.mapp-install-btn svg { width: 19px; height: 19px; flex: 0 0 auto; }
.mapp-install-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0;
    border-radius: 999px; cursor: pointer; white-space: nowrap;
    font: 600 12.5px/1 'Inter', system-ui, -apple-system, sans-serif;
    color: #fff; background: var(--app-accent); box-shadow: 0 3px 10px rgba(17, 115, 201, .25);
    -webkit-tap-highlight-color: transparent;
}
.mapp-install-chip:active { transform: scale(.96); }
.mapp-install-chip svg { width: 16px; height: 16px; flex: 0 0 auto; }
/* class display:inline-flex, UA'nın [hidden]=display:none kuralını EZER → gizliyken de görünür kalırdı. Düzelt: */
.mapp-install-btn[hidden], .mapp-install-chip[hidden] { display: none !important; }
