/* TeachMe Now - performance layer (smooth on phones, old devices and desktops) */

/* 1. Theme / language switch: freeze transitions for one frame so nothing animates across the whole page */
html.no-anim *, html.no-anim *::before, html.no-anim *::after { transition: none !important; animation: none !important; }

/* 2. Blur is the most expensive effect on phones: keep it for desktops only, use solid surfaces elsewhere */
@media (max-width: 899px), (hover: none) {
  *, *::before, *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .topbar, .landing-topbar, .chat-header, .chat-input-bar { background: rgba(10,16,32,.97); }
  .bottom-nav { background: rgba(10,16,32,.98); }
  .sidebar { background: rgba(10,16,32,.99); }
  .modal-overlay, .sidebar-overlay { background: rgba(0,0,0,.72); }
  [data-theme="light"] .topbar, [data-theme="light"] .landing-topbar,
  [data-theme="light"] .chat-header, [data-theme="light"] .chat-input-bar { background: rgba(238,242,249,.98); }
  [data-theme="light"] .bottom-nav { background: rgba(238,242,249,.99); }
  [data-theme="light"] .sidebar { background: rgba(226,234,247,.99); }
}
/* 3. Low-end devices (flag set before first paint): no decorative motion or heavy shadows */
html.lite *, html.lite *::before, html.lite *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
html.lite .hero-tile, html.lite .hero-eyebrow-dot, html.lite .skeleton { animation: none !important; }
html.lite .glass-card:hover, html.lite .course-card:hover, html.lite .grade-level-card:hover, html.lite .feature-card:hover { transform: none; }
html.lite .btn-primary, html.lite .btn-gold, html.lite .stat-card, html.lite .wallet-card { box-shadow: none; }
html.lite .bg-mesh, html.lite .bg-stars { display: none; }
html.lite .page.slide-in { animation-duration: .15s; }

/* 4. Cheaper hover effects and clean touch behaviour */
html { -webkit-tap-highlight-color: transparent; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
button, .nav-item, .filter-chip, .grade-tab-btn, .year-option, .grade-level-card, .course-card, .sidebar-link { touch-action: manipulation; }
body { overflow-x: hidden; overscroll-behavior-y: none; }
img { height: auto; }
.logo-dark, .logo-light { width: auto; }
.topbar-logo, .landing-logo, .landing-topbar img { height: 34px; width: auto; }
.auth-logo { height: 42px; width: auto; }
.scroll-x, .year-grid, .chat-messages, .modal, .sidebar { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* 5. Keep animated layers on the GPU only where they move */
.page.slide-in, .su-slide, .sidebar, .toast { will-change: transform, opacity; }
.page:not(.slide-in), .sidebar:not(.open) { will-change: auto; }

/* 6. Old / small phones (320-360px): nothing may overflow or overlap */
@media (max-width: 380px) {
  .landing-topbar { padding: 0 10px; gap: 6px; }
  .landing-topbar-actions { gap: 6px; }
  .landing-topbar-actions .btn { padding: 8px 12px; font-size: .78rem; }
  .landing-topbar-actions [data-login] { display: none; }
  .hero { padding: 90px 14px 40px; }
  .hero-title { font-size: 1.75rem; }
  .hero-cta .btn { width: 100%; }
  .auth-card { padding: 20px 16px; }
  .su-q { font-size: 1.2rem; }
  .year-grid { grid-template-columns: 1fr; max-height: 46vh; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .courses-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-wallet { padding: 6px 10px; font-size: .78rem; }
  .grade-banner { padding: 16px; gap: 12px; }
  .grade-value { font-size: 1.9rem; }
}
@media (max-height: 560px) { .su-slide { justify-content: flex-start; } .hero { min-height: 0; } }
@supports not (aspect-ratio: 16/9) {
  .course-thumb, .course-thumb-placeholder, .course-detail-thumb, .player-wrap { height: 0; padding-bottom: 56.25%; }
}

/* 7. Google sign-in: official button laid invisibly over our styled button */
.g-wrap { position: relative; width: 100%; height: 46px; }
.g-wrap .google-btn { height: 46px; padding-top: 0; padding-bottom: 0; }
.g-slot { position: absolute; top: 0; right: 0; bottom: 0; left: 0; opacity: .01; overflow: hidden; display: flex; align-items: center; justify-content: center; z-index: 2; }
.year-other { grid-column: 1 / -1; }
html[dir="ltr"] .hero-title, html[dir="ltr"] .section-big-title { letter-spacing: -.01em; }
