/* ============================================================
   Padha World — Mobile-first app touches
   Loaded on every public page. Active on phones/tablets (≤820px),
   harmlessly inert on desktop. Respects reduced-motion.
   ============================================================ */

html { -webkit-tap-highlight-color: transparent; }
a, button, .subject-card, .btn, input, select, textarea { touch-action: manipulation; }

/* ---------- bottom tab bar (the "always explore" bar) ---------- */
.pw-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; display: none; }
body.pw-has-tabbar { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

.pw-tabbar-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  margin: 0 auto;
  max-width: 560px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(14, 9, 33, 0.92);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  border-top: 1px solid rgba(196, 168, 248, 0.18);
}
@media (min-width: 560px) {
  .pw-tabbar-inner { margin: 0 auto 12px; border: 1px solid rgba(196,168,248,.22); border-radius: 24px; box-shadow: 0 18px 50px rgba(6,2,24,.6), inset 0 1px 0 rgba(255,255,255,.08); max-width: 520px; }
  body.pw-has-tabbar { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

.pw-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 7px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #9f8fd4;
  text-decoration: none;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.pw-tab svg { width: 21px; height: 21px; color: inherit; transition: transform 0.18s ease, color 0.18s ease; }
.pw-tab:active { transform: scale(0.9); }
.pw-tab.active { color: #f3edff; background: linear-gradient(165deg, rgba(139,92,246,0.42), rgba(124,58,237,0.22)); }
.pw-tab.active svg { color: #d3bfff; transform: translateY(-1px); }
.pw-tab:focus-visible { outline: 2px solid #c4a8f8; outline-offset: 2px; }

/* pulsing "new" dot to draw the eye (AI Tutor) */
.pw-dot {
  position: absolute; top: 5px; left: calc(50% + 6px);
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f472b6);
  box-shadow: 0 0 0 2px #0e0921;
  animation: pw-dot-pulse 1.6s ease-in-out infinite;
}
@keyframes pw-dot-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.45); } }

/* ---------- install pill (Android/desktop Chrome "Add to Home Screen") ---------- */
.pw-install {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 95;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px 9px 14px;
  background: #f6f2ff; color: #2a1845;
  border-radius: 999px;
  border: 1px solid #e4d9ff;
  box-shadow: 0 14px 44px rgba(9, 4, 26, 0.5);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap;
}
.pw-install button { border: 0; cursor: pointer; font: inherit; }
.pw-install-go { background: #6d28d9; color: #fff; border-radius: 999px; padding: 7px 12px; }
.pw-install-x { background: transparent; color: #6b5aa8; font-size: 17px; line-height: 1; padding: 2px 6px; border-radius: 999px; }

/* ---------- horizontal snap "explore" strip ---------- */
.snap-strip {
  display: flex; gap: 12px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  padding: 6px 16px 18px; margin: 0 -16px;
  scrollbar-width: none;
}
.snap-strip::-webkit-scrollbar { display: none; }
.snap-card {
  scroll-snap-align: start;
  flex: 0 0 auto; width: 148px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 14px 12px;
  background: #ffffff;
  border: 1px solid #ece7fb;
  border-radius: 18px;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(23, 12, 56, 0.06);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.snap-card:active { transform: scale(0.95); }
.snap-emoji { font-size: 26px; line-height: 1; }
.snap-t { color: #241536; font-family: "Baloo 2", system-ui, sans-serif; font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.snap-d { color: #6f6397; font-family: "Inter", system-ui, sans-serif; font-size: 11px; font-weight: 600; line-height: 1.35; }

/* ---------- tap feedback on cards/buttons ---------- */
.subject-card:active, .learning-card:active, .tool-card:active, .game-card:active,
.btn:active, .mode-card:active, .tile:active { transform: scale(0.965) !important; }

@media (min-width: 821px) {
  /* desktop: keep everything queryable but visually inert beyond decoration */
  .snap-strip { margin: 0; padding: 6px 4px 14px; flex-wrap: wrap; overflow-x: visible; }
  .snap-card:hover { transform: translateY(-3px); border-color: #c9b8f7; box-shadow: 0 12px 30px rgba(91, 33, 182, 0.14); }
}

/* ---------- bottom bar visibility rules ---------- */
@media (max-width: 820px) {
  .pw-tabbar { display: block; }
}
@media (min-width: 821px) {
  .pw-install { bottom: 22px; }
}

/* ---------- respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .snap-strip { scroll-behavior: auto; }
  .pw-tab, .snap-card, .subject-card, .btn { transition: none !important; }
  .pw-dot { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   Excellence pass — iOS/Android ergonomics + accessibility base
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Keyboard users always get a visible ring, everywhere */
:focus-visible { outline: 3px solid #7c3aed; outline-offset: 2px; border-radius: 4px; }
@supports selector(:focus-visible) {
  :focus:not(:focus-visible) { outline: none; }
}

@media (max-width: 820px) {
  /* Stop iOS auto-zoom on form fields (needs ≥16px) */
  input, select, textarea { font-size: 16px !important; }

  /* Comfortable thumb targets (WCAG 2.5.5 / iOS HIG) */
  .btn, .quick, .nav-burger, .pw-install-go, button.share-btn, .ob-dismiss, .nav-signin {
    min-height: 44px;
  }
  .nav-signin { display: inline-flex; align-items: center; }
  .btn { display: inline-flex; align-items: center; justify-content: center; }

  /* Content must never punch through the viewport */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  pre { overflow-x: auto; max-width: 100%; }
  img, video, canvas, iframe { max-width: 100%; height: auto; }

  /* iOS Safari bottom-bar / notch breathing room for floating widgets */
  .pw-install { max-width: calc(100vw - 32px); white-space: normal; text-align: left; }
}

/* Honour reduced motion for the JS-written confetti/pulses too */
@media (prefers-reduced-motion: reduce) {
  .pw-dot, .ob-bar { animation: none !important; }
}
