/* ============================================================================
   Alpha Computer Institute — APP SHELL
   Loads on every public page but only *activates* when the site runs as an
   installed/standalone app (html.pwa-app). Website visitors are unaffected,
   except the slim top loading bar which is a global nicety.
   ============================================================================ */

/* ---- Global top loading bar (site + app) --------------------------------- */
#appBar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100000;
  transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, #2f6cf0, #6d28d9 60%, #22c3a6);
  box-shadow: 0 0 10px rgba(47, 108, 240, .6);
  opacity: 0; transition: transform .2s ease, opacity .3s ease; pointer-events: none;
}
#appBar.go  { opacity: 1; }
#appBar.done { transform: scaleX(1) !important; opacity: 0; }

/* ============================================================================
   APP MODE — everything below only applies inside the installed app
   ============================================================================ */

/* Hide the marketing chrome; the app gets its own bar + drawer + tab bar. */
html.pwa-app header.nav#siteNav { display: none !important; }
html.pwa-app .footer { display: none !important; }
html.pwa-app .pwa-install { display: none !important; } /* already an app */

/* Give the body room for the fixed app bar (top) and tab bar (bottom). */
html.pwa-app body {
  padding-top: calc(54px + env(safe-area-inset-top, 0px)) !important;
  padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
html.pwa-app #main { min-height: 60vh; }

/* ---- App top bar --------------------------------------------------------- */
.app-top { display: none; }
html.pwa-app .app-top {
  display: flex; align-items: center; gap: 10px;
  position: fixed; top: 0; left: 0; right: 0; z-index: 940;
  height: calc(54px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 10px 0;
  background: linear-gradient(135deg, #2f6cf0, #1f57cf);
  color: #fff; box-shadow: 0 4px 18px -6px rgba(15, 36, 72, .45);
}
.app-top .at-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border: none; background: transparent;
  color: #fff; display: grid; place-items: center; border-radius: 12px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.app-top .at-btn:active { background: rgba(255, 255, 255, .18); transform: scale(.94); }
.app-top .at-brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.app-top .at-brand img { width: 30px; height: 30px; border-radius: 8px; background: #fff; padding: 3px; object-fit: contain; flex: 0 0 auto; }
.app-top .at-title { font-weight: 800; font-size: 1.02rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-top .at-title small { display: block; font-weight: 500; font-size: .64rem; opacity: .8; letter-spacing: .04em; }
.app-top .at-ava {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; overflow: hidden;
  background: rgba(255, 255, 255, .2); display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: .95rem; text-decoration: none; border: 1.5px solid rgba(255,255,255,.5);
}
.app-top .at-ava img { width: 100%; height: 100%; object-fit: cover; }
.app-top .at-stats { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.app-top .at-chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.18); border-radius: 999px; padding: 4px 9px; font-size: .82rem; font-weight: 800; color: #fff; }
.app-top .at-chip svg { display: block; }
@media (max-width: 360px) { .app-top .at-brand small { display: none; } }

/* ---- Slide-in drawer menu ------------------------------------------------ */
.app-drawer-scrim {
  display: none; position: fixed; inset: 0; z-index: 970;
  background: rgba(10, 22, 45, .5); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .25s ease;
}
.app-drawer-scrim.open { display: block; opacity: 1; }
.app-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 971; width: 86%; max-width: 340px;
  background: var(--surface, #fff); box-shadow: 20px 0 50px -20px rgba(2, 6, 23, .5);
  transform: translateX(-104%); transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
.app-drawer-scrim.open .app-drawer { transform: translateX(0); }

/* Gradient profile header (PW-style) */
.app-dr-prof {
  position: relative; overflow: hidden; color: #fff;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 18px 20px;
  background: linear-gradient(135deg, #2f6cf0 0%, #1f57cf 55%, #6d28d9 100%);
}
.app-dr-prof::after { content: ""; position: absolute; right: -32px; top: -42px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.app-dr-prof::before { content: ""; position: absolute; right: 34px; bottom: -52px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.app-dr-top { display: flex; align-items: center; gap: 13px; position: relative; }
.app-dr-ava {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto; overflow: hidden;
  background: rgba(255, 255, 255, .2); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 1.25rem; border: 2.5px solid rgba(255, 255, 255, .55);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .4);
}
.app-dr-ava img { width: 100%; height: 100%; object-fit: cover; }
.app-dr-prof .pn { font-size: 1.18rem; font-weight: 800; line-height: 1.2; color: #fff; }
.app-dr-prof .pv {
  display: inline-block; margin-top: 5px; font-size: .74rem; font-weight: 700; color: #fff;
  background: rgba(255, 255, 255, .2); padding: 3px 11px; border-radius: 999px; text-decoration: none;
}
.app-dr-chips { display: flex; gap: 9px; margin-top: 15px; position: relative; }
.app-dr-chip {
  flex: 1; display: flex; align-items: center; gap: 7px; min-width: 0;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px; padding: 8px 9px;
}
.app-dr-chip .ico { font-size: 1rem; line-height: 1; flex: 0 0 auto; }
.app-dr-chip > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.app-dr-chip .v { display: block; font-size: 1.02rem; font-weight: 800; color: #fff; line-height: 1.05; }
.app-dr-chip .k { display: block; font-size: .6rem; color: rgba(255, 255, 255, .8); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Highlight card (e.g. My Learning) */
.app-dr-card {
  display: flex; align-items: center; gap: 12px; margin: 14px 14px 6px; padding: 13px 14px;
  background: var(--brand-light, #eef3ff); border: 1px solid #dfe8ff; border-radius: 14px; text-decoration: none;
}
.app-dr-card .ci { width: 40px; height: 40px; border-radius: 11px; background: #fff; display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 2px 6px rgba(47, 108, 240, .15); }
.app-dr-card .ci svg { width: 20px; height: 20px; color: var(--brand, #2f6cf0); }
.app-dr-card .ct { flex: 1; min-width: 0; }
.app-dr-card .ct b { display: block; font-size: .95rem; color: var(--ink, #0f2448); }
.app-dr-card .ct small { font-size: .74rem; color: var(--muted, #64748b); }
.app-dr-card .cx { color: var(--muted, #94a3b8); flex: 0 0 auto; }

.app-dr-body { flex: 1; overflow-y: auto; padding: 6px 0 10px; -webkit-overflow-scrolling: touch; }
.app-dr-divider { height: 1px; background: var(--line, #eef1f6); margin: 8px 18px; }

/* Flat list rows with tinted icon tiles */
.app-dr-link {
  display: flex; align-items: center; gap: 14px; padding: 11px 18px;
  color: var(--ink, #1f2a44); text-decoration: none; font-weight: 600; font-size: .96rem;
}
.app-dr-link:active { background: var(--brand-light, #eef3ff); }
.app-dr-link.cur { color: var(--brand-dark, #1f57cf); background: var(--brand-light, #eef3ff); }
.app-dr-ic { width: 36px; height: 36px; border-radius: 10px; background: #f2f5fb; display: grid; place-items: center; flex: 0 0 auto; }
.app-dr-link svg { width: 20px; height: 20px; color: #475569; stroke-width: 1.8; }
.app-dr-link.cur .app-dr-ic { background: #dfe8ff; }
.app-dr-link.cur svg { color: var(--brand, #2f6cf0); }
.app-dr-link .lbl { flex: 1; }
.app-dr-link .nw { font-size: .62rem; font-weight: 800; color: #b26b00; background: #fff3d6; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; }
.app-dr-link.danger { color: #dc2626; }
.app-dr-link.danger .app-dr-ic { background: #fde8e8; }
.app-dr-link.danger svg { color: #dc2626; }
.app-dr-foot {
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line, #eef1f6);
  font-size: .78rem; color: var(--ink, #334155); text-align: center; font-weight: 700;
}
.app-dr-foot small { display: block; font-weight: 500; color: var(--muted, #94a3b8); margin-top: 3px; }

/* ---- Bottom tab bar: force on at ALL widths in app mode ------------------ */
html.pwa-app .mnav {
  display: grid !important; grid-template-columns: repeat(5, 1fr); align-items: end; gap: 2px;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
  background: var(--surface, #fff); border-top: 1px solid rgba(47, 108, 240, .12);
  box-shadow: 0 -10px 30px rgba(15, 36, 72, .12);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px)); border-radius: 20px 20px 0 0;
}

/* ---- Splash screen (first launch of an app session) ---------------------- */
#appSplash { display: none; }
html.show-splash #appSplash {
  display: flex; position: fixed; inset: 0; z-index: 100001;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: linear-gradient(160deg, #2f6cf0, #17336e 70%, #0f2448);
  color: #fff; font-family: Inter, system-ui, sans-serif; transition: opacity .45s ease;
}
#appSplash.hide { opacity: 0; pointer-events: none; }
#appSplash .sp-logo {
  width: 104px; height: 104px; border-radius: 26px; background: #fff; padding: 14px; object-fit: contain;
  box-shadow: 0 24px 54px -16px rgba(0, 0, 0, .5); animation: spPop .55s cubic-bezier(.2, .9, .3, 1.4);
}
#appSplash .sp-name { font-size: 1.35rem; font-weight: 800; letter-spacing: .01em; }
#appSplash .sp-tag { font-size: .8rem; opacity: .75; margin-top: -14px; letter-spacing: .08em; }
#appSplash .sp-bar { width: 180px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .22); overflow: hidden; }
#appSplash .sp-bar i { display: block; height: 100%; width: 40%; border-radius: 99px; background: #fff; animation: spLoad 1.1s ease-in-out infinite; }
@keyframes spPop { from { opacity: 0; transform: scale(.6) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spLoad { 0% { margin-left: -42%; } 100% { margin-left: 102%; } }

/* Respect reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  #appSplash .sp-logo { animation: none; }
  #appSplash .sp-bar i { animation-duration: 2s; }
}
