/* ============================================================
   JinBhakt — Layout & Responsive Shell
   Breakpoints:  <900px mobile drawer · >=900px sidebar
   ============================================================ */

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header"
    "main"
    "footer";
  min-height: 100vh;
  min-height: 100dvh;
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-areas:
      "header header"
      "nav    main"
      "footer footer";
  }
}

/* ---------- Header ---------- */
.site-header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 12px;
  background: linear-gradient(135deg, var(--color-saffron), var(--color-gold));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-md);
}

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  min-width: 0;
  flex: 1;
}

.site-title a {
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.site-title a:hover { color: rgba(255, 255, 255, 0.88); }

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
  padding: 2px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

@media (min-width: 600px) {
  .site-header { padding: 0 20px; gap: 16px; }
  .site-title  { font-size: 1.4rem; }
  .header-logo { width: 40px; height: 40px; }
}

/* ---------- Menu toggle ---------- */
.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.menu-toggle:hover,
.menu-toggle:focus-visible { background: rgba(255, 255, 255, 0.32); }
.menu-toggle svg { width: 24px; height: 24px; fill: #fff; }
body.nav-open .menu-toggle { background: rgba(255, 255, 255, 0.32); }

@media (min-width: 900px) {
  .menu-toggle { display: none; }
}

/* ---------- Overlay ---------- */
.body-overlay {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: var(--color-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  z-index: var(--z-overlay);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

body.nav-open .body-overlay { opacity: 1; pointer-events: auto; }

@media (min-width: 900px) {
  .body-overlay { display: none !important; }
}

/* ---------- Nav panel: mobile drawer ---------- */
.nav-panel {
  background: var(--color-nav-bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: calc(var(--z-overlay) + 1);
}

@media (max-width: 899px) {
  .nav-panel {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(86vw, 340px);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform var(--transition-base);
    visibility: hidden;
  }

  body.nav-open .nav-panel {
    transform: translateX(0);
    visibility: visible;
  }
}

/* ---------- Nav panel: desktop sidebar ---------- */
@media (min-width: 900px) {
  .nav-panel {
    grid-area: nav;
    position: sticky;
    top: var(--header-h);
    align-self: start;
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    border-right: 1px solid var(--color-border);
    transform: none !important;
    visibility: visible !important;
  }
}

/* ---------- Main ---------- */
.main-content {
  grid-area: main;
  padding: 16px 14px 40px;
  min-width: 0;               /* allow long Hindi words to wrap */
  width: 100%;
}

@media (min-width: 600px)  { .main-content { padding: 24px 24px 48px; } }
@media (min-width: 900px)  { .main-content { padding: 28px 32px 56px; } }
@media (min-width: 1400px) { .main-content { padding: 32px 48px 64px; } }

.main-content:focus { outline: none; }

/* Constrain very wide desktop lines for readability */
@media (min-width: 1400px) {
  .home-view, .cat-view, .reader, .empty-state, .path-view, .path-step-view, .index-view, .letter-view, .mine-view, .kids-view {
    max-width: 1100px;
    margin-inline: auto;
  }
  /* The game frame is allowed to run wider — the games manage their own lines. */
  .kids-game-view {
    max-width: 1240px;
    margin-inline: auto;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  grid-area: footer;
  text-align: center;
  padding: 16px 12px;
  background: var(--color-maroon);
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--font-size-xs);
}

.site-footer a { color: rgba(255, 255, 255, 0.92); text-decoration: underline; }
