/* TELIMINE public app - Default Light Mode, Full-Bleed Hero & Floating Dock */
:root {
  --c-bg: 244 245 250; --c-card: 255 255 255; --c-input: 238 241 247; --c-text: 17 24 39; --c-muted: 100 116 139; --c-line: 15 23 42;
  --c-primary: 242 101 34; --c-accent: 225 29 72; --c-violet: 124 58 237;
  --public-grid-columns: 4; --public-gutter: 14px; --tm-card-radius: 18px;
  --tm-safe-top: env(safe-area-inset-top, 0px); --tm-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tm-nav-height: 76px;
  --safe-area-surface: #f4f5fa;
}

html[data-theme="dark"] {
  --c-bg: 9 11 18; --c-card: 19 23 34; --c-input: 28 33 48; --c-text: 248 250 252; --c-muted: 148 163 184; --c-line: 255 255 255;
  --safe-area-surface: #090b12;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; background-color: rgb(var(--c-bg)); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; max-width: 100%; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: rgb(var(--c-bg));
  color: rgb(var(--c-text));
  min-height: 100dvh;
  padding-top: var(--tm-safe-top);
  padding-bottom: calc(var(--tm-nav-height) + var(--tm-safe-bottom) + 10px);
  overflow-x: clip;
  max-width: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background-color .25s ease, color .25s ease;
}

/* Allow Hero Banner to bleed edge-to-edge behind Status Bar & Top Nav on Home */
body:has(#homePage.active),
body:has(#discoverPage.active),
body:has(#tmHero) {
  padding-top: 0 !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--tm-safe-top);
  background: var(--safe-area-surface, rgb(var(--c-bg)));
  z-index: 80;
  pointer-events: none;
  transition: opacity .2s ease;
}

/* Hide opaque safe-area cover on Home so Hero image shows behind status bar */
body:has(#homePage.active)::before,
body:has(#discoverPage.active)::before,
body:has(#tmHero)::before {
  background: transparent;
}

/* Transparent Floating Top Navigation Bar over Hero */
#tmTopBar, .tm-topbar, header.sticky {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 85;
  padding-top: calc(var(--tm-safe-top) + 8px) !important;
  background: transparent !important;
  border-bottom-color: transparent !important;
  box-shadow: none !important;
  transition: background-color .25s ease, box-shadow .25s ease;
}

body.is-scrolled #tmTopBar,
body.is-scrolled .tm-topbar,
body.is-scrolled header.sticky {
  background: rgb(var(--c-card) / .92) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08) !important;
}

::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.pb-safe { padding-bottom: var(--tm-safe-bottom); }
.allow-copy { -webkit-user-select: text !important; user-select: text !important; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid rgb(var(--c-primary)); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Pages: unified transparent canvas with zero trailing margin */
.page-section { display: none; background: transparent !important; margin-bottom: 0 !important; }
.page-section.active { display: block; animation: tmPageFade .2s ease-out; }
@keyframes tmPageFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Add top clearance for non-hero inner pages so fixed Top Bar never overlaps them */
#allGamesPage, #explorePage, #reviewPage, #docPage, #searchPage, #profilePage, #favoritePage, #historyPage {
  font-family: 'Plus Jakarta Sans', sans-serif;
  margin: 0;
  padding-top: calc(var(--tm-safe-top) + 56px);
  background: transparent !important;
  color: rgb(var(--c-text));
}

/* Premium MyBL / Mukto Hero & Action Surfaces */
.tm-hero-banner {
  background: linear-gradient(135deg, rgb(var(--c-primary)) 0%, #f97316 52%, rgb(var(--c-accent)) 100%);
  color: #fff;
  border-radius: 22px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 28px -8px rgb(var(--c-primary) / .38);
}
.tm-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 8px;
  background: rgb(var(--c-card));
  border: 1px solid rgb(var(--c-line) / .07);
  border-radius: 20px;
  padding: 14px 10px;
}
.tm-quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: rgb(var(--c-text));
}
.tm-quick-icon {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(var(--c-primary) / .1);
  color: rgb(var(--c-primary));
  font-size: 18px;
}

/* Skeleton + image fallback */
.tm-skel { background: linear-gradient(90deg, rgb(var(--c-card)) 25%, rgb(var(--c-line) / .08) 37%, rgb(var(--c-card)) 63%); background-size: 400% 100%; animation: tmShimmer 1.4s ease infinite; }
.tm-skel-light { background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 37%, #e5e7eb 63%); background-size: 400% 100%; animation: tmShimmer 1.4s ease infinite; }
@keyframes tmShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.tm-cover { background: linear-gradient(135deg, rgb(var(--c-primary) / .88), #1e1b4b); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; }
.tm-cover img { width: 100%; height: 100%; object-fit: cover; }
.tm-card-r { border-radius: var(--tm-card-radius); }

/* Bottom sheet & Toasts */
.bottom-sheet-overlay { display: none; opacity: 0; transition: opacity .3s; }
.bottom-sheet-overlay.active { display: block; opacity: 1; }
.bottom-sheet { transform: translateY(100%); transition: transform .4s cubic-bezier(.16, 1, .3, 1); visibility: hidden; }
.bottom-sheet.active { transform: translateY(0); visibility: visible; }

.tm-sheet-bg { position: fixed; inset: 0; z-index: 140; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: tmFadeOnly .2s; }
.tm-sheet { width: 100%; max-width: 32rem; max-height: 82vh; overflow-y: auto; background: rgb(var(--c-card)); color: rgb(var(--c-text)); border-radius: 24px 24px 0 0; padding: 18px 18px calc(20px + var(--tm-safe-bottom)); animation: tmSheetUp .35s cubic-bezier(.16, 1, .3, 1); }
.tm-sheet h3 { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 1.05rem; margin-bottom: 14px; }
.tm-sheet h3 button { width: 32px; height: 32px; border-radius: 999px; background: rgb(var(--c-line) / .08); color: rgb(var(--c-muted)); }

#tm-toast-region { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tm-nav-height) + var(--tm-safe-bottom) + 12px); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 26rem); pointer-events: none; }
.tm-toast { pointer-events: auto; padding: 11px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; color: #fff; background: #1f2937; border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: tmSheetUp .25s; }
.tm-toast[data-kind="success"] { background: #047857; } .tm-toast[data-kind="error"] { background: #b91c1c; }

#tmNetworkStatus { position: fixed; top: calc(var(--tm-safe-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 250; padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #b45309; color: #fff; }
#tmNetworkStatus[data-online="true"] { background: #047857; }

.tm-switch { width: 48px; height: 26px; border-radius: 999px; background: rgb(var(--c-muted) / .5); position: relative; transition: background .2s; flex-shrink: 0; }
.tm-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; transition: transform .2s; }
.tm-switch[aria-checked="true"] { background: rgb(var(--c-primary)); }
.tm-switch[aria-checked="true"]::after { transform: translateX(22px); }

/* Tightened page wrapper: eliminated extra bottom padding */
.tm-pg { padding: 12px 12px 6px; }
.tm-pg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tm-pg-head h2 { font-size: 19px; font-weight: 900; line-height: 1.15; color: rgb(var(--c-text)); }
.tm-pg-head p { font-size: 12px; color: rgb(var(--c-muted)); margin-top: 2px; }
.tm-page-back { width: 38px; height: 38px; border-radius: 13px; background: rgb(var(--c-card)); border: 1px solid rgb(var(--c-line) / .1); color: rgb(var(--c-text)); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform .15s; }
.tm-page-back:active { transform: scale(.92); }

.tm-box { background: rgb(var(--c-card)); border: 1px solid rgb(var(--c-line) / .08); border-radius: 20px; padding: 14px; }
.tm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 14px; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, rgb(var(--c-primary)), rgb(var(--c-accent))); box-shadow: 0 6px 18px rgb(var(--c-primary) / .28); transition: transform .15s, opacity .2s; }
.tm-btn:active { transform: scale(.97); }

img { -webkit-user-drag: none; user-drag: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; pointer-events: none; }
img, video, iframe { max-width: 100%; }
body, main, .page, .content, .container { min-width: 0; }

/* View Transitions & Persistent Floating Bottom Bar */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .12s; }
#tmBottomBar {
  position: fixed;
  z-index: 90;
  view-transition-name: tm-bottom-bar;
}
::view-transition-group(tm-bottom-bar) { animation-duration: 0s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }
