/* Mobile app shell — everything here is gated on html.mobile-app (<=760px).
   Desktop/tablet never sees any of it. Rule 13: activation class is set pre-paint. */

/* Flex column so the banner (if shown) + topbar sit at the top and the active pane fills the
   rest — no hard-coded top offset that the Freemium banner could push out of place. */
html.mobile-app body { display: flex; flex-direction: column; min-height: 100dvh; }
html.mobile-app .topbar { position: relative; flex: none; }

/* ---- Top bar + hamburger menu (Task 2) ---- */
html.mobile-app .header-dial-wrap { display: none; }
html.mobile-app #mobile-tree-btn { display: inline-flex; }

html.mobile-app .m-nav {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  display: flex; flex-direction: column;
  background: var(--surface, var(--bg));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
}
html.mobile-app .m-nav[hidden] { display: none; }
html.mobile-app .m-nav-item {
  text-align: left; padding: 14px 18px; font-size: 15px;
  background: none; border: 0; border-bottom: 1px solid var(--border);
  color: var(--ink);
}
html.mobile-app .m-nav-item:last-child { border-bottom: 0; }
html.mobile-app .m-nav-item.is-active { color: var(--accent); font-weight: 600; }

/* ---- Full-screen section routing (Task 3) ---- */
html.mobile-app .layout { flex: 1 1 auto; min-height: 0; display: block; position: relative; padding: 0; overflow: hidden; }
/* .content fills the layout and is the positioning context for the board/notes/folder overlays. */
html.mobile-app .content { position: absolute; inset: 0; transform: none; }

/* The sidebar (lists) and the right todo/subs panel each fill the layout area below the topbar.
   Only one shows at a time (per data-msec). */
html.mobile-app #sidebar,
html.mobile-app .todo.panel {
  position: absolute; inset: 0;
  width: auto; margin: 0; border: 0; border-radius: 0;
  transform: none; box-shadow: none; overflow-y: auto;
  padding-bottom: 24px;
}
html.mobile-app #sidebar { z-index: 5; }
html.mobile-app .todo.panel { z-index: 6; display: flex; flex-direction: column; }
html.mobile-app #sidebar-backdrop { display: none; }
/* The sidebar tab bar is redundant on mobile — the hamburger nav covers it. */
html.mobile-app #sidebar .sidebar-tabs-wrap { display: none; }

/* Bookmarks is a one-level-at-a-time folder browser in the sidebar tree (renderTree mobile
   branch): tap a folder to drill in, the back row steps up. Hover flyouts are hidden, and the
   add-forms stay pinned at the bottom so "New folder / bookmark" is on every screen. */
html.mobile-app .flyout { display: none; }
html.mobile-app .tree-back .row { color: var(--accent); font-weight: 600; }
html.mobile-app .tree-back .row-chevron { font-size: 20px; line-height: 1; }
html.mobile-app .sidebar-add {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--bg); border-top: 1px solid var(--border);
}

/* The center's bookmarks grid + widgets are unused on mobile (the sidebar list IS the
   bookmarks surface); the board + notes editor overlay full-screen when opened. */
html.mobile-app .content > .folder-block,
html.mobile-app .content > #widgets-block { display: none; }
/* Notes = bookmarks-style single-column drill-in: books list → a book's pages → editor.
   .notes-drilled (set by notes.js on mobile) swaps the books list for the open book's pages;
   the add row stays pinned at the bottom on BOTH screens (its type toggle is context-aware). */
html.mobile-app #notes-view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
html.mobile-app #notes-view .notes-col { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 0; }
html.mobile-app #notes-view .tree { flex: 1 1 auto; overflow-y: auto; }
html.mobile-app .notes-pages-head { display: none; }   /* the back row shows the book name instead */
/* Root screen: books col fills; pages col hidden (needs #notes-view to beat the
   .notes-col display:flex rule above, which carries an id). */
html.mobile-app:not(.notes-drilled) #notes-view .notes-books-col { flex: 1 1 auto; }
html.mobile-app:not(.notes-drilled) #notes-view .notes-pages-col { display: none; }
/* Drilled screen: pages col on top (fills); books col shrinks to just its pinned add form. */
html.mobile-app.notes-drilled .notes-pages-col { flex: 1 1 auto; order: 1; }
html.mobile-app.notes-drilled .notes-books-col { flex: 0 0 auto; order: 2; }
html.mobile-app.notes-drilled .notes-books-col > .sidebar-search,
html.mobile-app.notes-drilled .notes-books-col > #notes-books-list { display: none; }

/* Notes editor overlays full-screen only while a page is open (else the pages list shows).
   Opaque bg so the sidebar's book list behind it doesn't show through the toolbar gaps. */
html.mobile-app.note-open[data-msec="notes"] #notes-block {
  position: absolute; inset: 0; z-index: 10; overflow: auto; padding-bottom: 24px;
  background: var(--bg);
}
/* Editor top bar: Back + the open page's name, sticky above the toolbar. */
html.mobile-app.note-open[data-msec="notes"] #notes-mobile-bar {
  display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 12; width: 100%;
  background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 12px;
}
html.mobile-app.note-open[data-msec="notes"] #notes-mobile-back {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 15px; padding: 2px;
}
html.mobile-app.note-open[data-msec="notes"] #notes-mobile-title {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; font-size: 15px; color: var(--ink);
}
#notes-mobile-bar { display: none; }   /* injected always; visible only on mobile + note-open */

/* Editor toolbar dropdowns must stay inside a narrow phone screen (table grid was cut off). */
html.mobile-app .nt-menu { max-width: calc(100vw - 20px); }
html.mobile-app .nt-table-menu { left: auto; right: 0; }
/* Projects are view-only on mobile — no creating projects here (do it in the web app). */
html.mobile-app .sidebar-add:has(#add-project-form) { display: none; }
/* Projects: show the project LIST until one is picked; then its board overlays (view-only).
   mobile-shell toggles .proj-open from MarkerStore.activeProject. */
html.mobile-app[data-msec="projects"]:not(.proj-open) #mindmap-block { display: none; }
html.mobile-app.proj-open #mindmap-block {
  position: absolute; inset: 0; z-index: 10; overflow: auto; padding-bottom: 24px;
}
html.mobile-app.proj-open #mm-mobile-hint {
  display: block !important;   /* beats the UA [hidden] rule */
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 11;
  padding: 6px 12px; font-size: 11.5px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  box-shadow: var(--shadow-sm); white-space: nowrap; max-width: 92%;
}

/* Bookmarks / Projects / Notes → sidebar view; hide the right panel. */
html.mobile-app[data-msec="bookmarks"] .todo.panel,
html.mobile-app[data-msec="projects"] .todo.panel,
html.mobile-app[data-msec="notes"] .todo.panel,
html.mobile-app[data-msec="activities"] .todo.panel { display: none; }
/* Todos / Subs / Activities → their own panel; hide the sidebar. */
html.mobile-app[data-msec="todos"] #sidebar,
html.mobile-app[data-msec="subs"] #sidebar,
html.mobile-app[data-msec="activities"] #sidebar { display: none; }

/* ---- Todo & Reminders vs Subscription split (Task 4/5) ---- */
/* Todos section: hide the subscriptions block (it is its own section). */
html.mobile-app[data-msec="todos"] #subscriptions-block { display: none; }
/* Subs section: show ONLY the subscriptions block, full height. */
html.mobile-app[data-msec="subs"] .todo.panel > .panel-head,
html.mobile-app[data-msec="subs"] .todo.panel > #todo-form,
html.mobile-app[data-msec="subs"] .todo.panel > #todo-list { display: none; }
html.mobile-app[data-msec="subs"] #subscriptions-block {
  position: static; max-height: none; height: auto; flex: 1 1 auto;
}
/* Mobile to-do group headers (Overdue / Today / Upcoming / No date). */
html.mobile-app .todo-group-head {
  list-style: none; margin: 0; padding: 14px 14px 4px;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}

/* ---- Board view-only (Task 6) ---- */
html.mobile-app #mindmap-block .mm-toolset { display: none; }   /* no editing tools on mobile */
html.mobile-app .mm-back {
  display: inline-flex !important;   /* beats the UA [hidden] rule (effectively !important) */
  align-items: center; gap: 4px;
  background: none; border: 0; color: var(--accent);
  font-size: 15px; font-weight: 600; padding: 6px 4px;
}

/* Activities: its own full-screen section (moved out of the bottom shutter). */
html.mobile-app .reserved-block { display: none; }
html.mobile-app[data-msec="activities"] .reserved-block {
  display: block; position: absolute; inset: 0; z-index: 4;
  overflow-y: auto; padding: 10px; margin: 0;
}
html.mobile-app #reserved-resizer { display: none; }

/* ---- No widgets / no tour on mobile (Task 8) ---- */
/* (Widgets already sit inside the hidden .folder-block; this makes the intent explicit.) */
html.mobile-app #widgets-toggle,
html.mobile-app #widgets-block { display: none !important; }
html.mobile-app #profile-menu-tour { display: none; }
