/* ════════════════════════════════════════════════════════════════════
   mobile.css — Galaxy Note Web Client: Mobile Touch UI
   TASK-1070 | 2026-03-26
   Applies on: max-width 768px
   Design System: DESIGN_SYSTEM.md (CSS vars, radii, font sizes, z-index)
   ════════════════════════════════════════════════════════════════════ */

/* ── Bottom Navigation Bar ────────────────────────────────────────── */

.gn-bottom-nav {
  display: none; /* hidden by default; shown via @media below */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: var(--z-sticky);
  background: var(--card-bg-solid);
  border-top: 1px solid var(--glass-border);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  /* Slight blur for glass feel */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.gn-bottom-nav__inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: 56px; /* fixed inner height, padding-bottom adds safe area space */
}

.gn-bottom-nav__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  min-height: 48px;
  min-width: 48px;
  padding: 4px 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gn-bottom-nav__tab svg,
.gn-bottom-nav__tab .gn-btn-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.gn-bottom-nav__tab span {
  font-size: var(--fs-xs);
  line-height: 1;
}

.gn-bottom-nav__tab--active,
.gn-bottom-nav__tab:focus-visible {
  color: var(--primary);
  outline: none;
}

.gn-bottom-nav__tab:active {
  opacity: 0.7;
}

body.light-mode .gn-bottom-nav {
  background: rgba(255, 255, 255, 0.95);
  border-top-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .gn-bottom-nav__tab {
  color: var(--text-muted);
}

body.light-mode .gn-bottom-nav__tab--active {
  color: var(--primary);
}

/* ── Swipe area: reserve left 20px for back-gesture ──────────────── */
/* Prevents accidental taps on interactive elements near the left edge */
.gn-swipe-guard {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  z-index: 1; /* below modals, above content */
  pointer-events: none; /* pass-through for clicks; handled via touch events in JS */
}

/* ── @media (max-width: 768px) — all mobile overrides ────────────── */

@media (max-width: 768px) {

  /* ── Safe areas: notch / home-indicator support ─────────────── */

  body {
    padding-top: env(safe-area-inset-top);
    /* Bottom padding handled by bottom-nav height + safe-area */
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  /* ── App layout: collapse 3-column grid to single column ─────── */

  .app-container {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
    height: auto !important;
    min-height: 100dvh !important;
    overflow-y: auto !important;
    padding: 0.5rem 0.5rem 0 !important;
    gap: 0.5rem !important;
  }

  /* ── Header ──────────────────────────────────────────────────── */

  header.panel {
    padding: 0 0.75rem;
    min-height: 52px;
    grid-column: 1 !important;
  }

  .header-right {
    gap: 0.4rem;
  }

  #clock {
    display: none;
  }

  /* ── Sidebar: hide on mobile, replaced by bottom nav ─────────── */

  .sidebar-left,
  .sidebar-right,
  .sidebar-resize-handle {
    display: none !important;
  }

  /* ── Editor: full-width, no split ────────────────────────────── */

  .editor-area,
  .editor-container,
  .editor-pane,
  .note-editor {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0.75rem !important;
  }

  /* No split-pane on mobile */
  .split-editor-container {
    flex-direction: column !important;
  }

  .split-editor-container > * {
    width: 100% !important;
    max-height: 40vh;
  }

  .editor-title {
    font-size: var(--fs-lg) !important;
  }

  /* ── Touch targets: min 48x48 for all interactive elements ────── */

  button,
  a,
  [role="button"],
  .hdr-btn,
  .sidebar-bottom-btn,
  .gn-ctx-btn,
  .btn {
    min-height: 48px;
    min-width: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Inline/icon buttons that mustn't stretch — keep 44px via padding */
  .hdr-btn,
  .btn--ghost,
  .btn--xs,
  .gn-icon-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px !important;
  }

  /* Context menu items: larger tap area */
  .gn-ctx-btn {
    padding: 12px 16px !important;
    font-size: var(--fs-base);
  }

  /* ── Font sizes: slightly larger for mobile readability ─────── */

  html {
    font-size: 68%; /* up from 65% desktop */
  }

  .note-content,
  .editor-content,
  [contenteditable="true"] {
    font-size: var(--fs-md) !important;
    line-height: 1.7;
  }

  .note-list-item-title {
    font-size: var(--fs-base);
  }

  /* ── Modals: full-screen on mobile ───────────────────────────── */

  .gn-modal-box,
  .gn-overlay .gn-modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100dvh !important;
    min-height: 50dvh;
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
    padding: 20px 16px !important;
    /* Slide up from bottom */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    transform: none !important;
    overflow-y: auto;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }

  .gn-overlay {
    align-items: flex-end !important;
  }

  /* Fullscreen modals (larger content: AI, settings, etc.) */
  .gn-overlay--full .gn-modal-box,
  .gn-modal-box--fullscreen {
    top: env(safe-area-inset-top) !important;
    min-height: 90dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  }

  /* ── Cards ────────────────────────────────────────────────────── */

  .kanban-card,
  .note-card,
  .dash-stat-cell {
    padding: 12px 14px;
  }

  /* ── AI panel ─────────────────────────────────────────────────── */

  .ai-panel {
    width: calc(100vw - 1rem) !important;
    right: 0.5rem !important;
    left: 0.5rem !important;
    bottom: calc(56px + env(safe-area-inset-bottom) + 0.5rem) !important;
    max-height: 60dvh;
    overflow-y: auto;
  }

  /* ── Spotlight ───────────────────────────────────────────────── */

  .spotlight-box {
    width: calc(100vw - 2rem) !important;
    max-width: 100% !important;
    margin: 0 1rem;
    top: calc(env(safe-area-inset-top) + 0.5rem);
  }

  /* ── Dashboard ────────────────────────────────────────────────── */

  .dash-stat-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* ── Welcome / Login ────────────────────────────────────────── */

  .welcome-card {
    padding: 2rem 1.25rem;
  }

  .welcome-card h1 {
    font-size: 2.5rem;
  }

  /* ── Bottom nav: show on mobile ─────────────────────────────── */

  .gn-bottom-nav {
    display: block;
  }

  /* ── Utility: hide elements irrelevant on mobile ─────────────── */

  .gn-desktop-only {
    display: none !important;
  }

  .gn-mobile-only {
    display: block !important;
  }

  /* ── Sidebar collapse button: hide (no sidebar) ─────────────── */

  .sidebar-collapse-btn,
  .sidebar-expand-btn {
    display: none !important;
  }

  /* ── Scroll: smooth momentum on iOS ─────────────────────────── */

  .app-container,
  .editor-area,
  .note-editor,
  [contenteditable="true"] {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

} /* end @media (max-width: 768px) */

/* ── Utility classes: always-available ────────────────────────────── */

/* Hidden by default, shown on mobile */
.gn-mobile-only {
  display: none;
}

/* Shown by default, hidden on mobile (handled above via @media) */
.gn-desktop-only {
  display: block;
}
