/* ============================================
   responsive.css — RWD Media Queries
   ============================================ */

/* ---- TABLET (< 1024px): shrink toolbar ---- */
@media (max-width: 1023px) {
  .preview-content { padding: 18px 20px; }
}

/* ---- MOBILE (< 768px) ---- */
@media (max-width: 767px) {
  /* Show/hide helpers */
  .desktop-only { display: none !important; }
  .mobile-only  { display: flex !important; }

  /* Navbar */
  .navbar { padding: 0 8px; gap: 6px; }
  /* Navbar logo: truncate on overflow */
  .nav-logo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; min-width: 0; }

  /* Hide desktop dropdowns on mobile */
  #cloud-dropdown,
  #lang-dropdown,
  #typo-dropdown { display: none; }

  /* Move open/download to drawer on mobile */
  #btn-open,
  #btn-download { display: none; }

  /* Settings button: icon only on mobile */
  #btn-settings { padding: 4px 7px; font-size: 15px; }

  /* Prevent nav-actions from overflowing */
  .nav-actions { overflow: hidden; flex-shrink: 1; min-width: 0; }

  /* Tab bar: horizontal scroll + snap */
  .tabs-bar { height: 36px; }
  .tabs-list { scroll-snap-type: x mandatory; }
  .tab-item { min-width: 80px; max-width: 130px; padding: 0 8px 0 10px; font-size: 12px; scroll-snap-align: start; }

  /* Editor: single column — subtract 48px toolbar + 16px swipe dots */
  .editor-wrapper {
    flex-direction: column;
    height: calc(100vh - var(--ios-banner-height, 0px) - var(--navbar-height) - var(--tabs-height) - var(--status-height) - 48px - 16px - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - var(--ios-banner-height, 0px) - var(--navbar-height) - var(--tabs-height) - var(--status-height) - 48px - 16px - env(safe-area-inset-bottom, 0px));
  }
  /* Preview mode: toolbar hidden, dots still visible */
  body.preview-mode .editor-wrapper {
    height: calc(100vh - var(--ios-banner-height, 0px) - var(--navbar-height) - var(--tabs-height) - var(--status-height) - 16px - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - var(--ios-banner-height, 0px) - var(--navbar-height) - var(--tabs-height) - var(--status-height) - 16px - env(safe-area-inset-bottom, 0px));
  }
  body.preview-mode #bottom-toolbar {
    display: none !important;
  }

  /* Default: show edit, hide preview */
  .editor-pane {
    flex: 1;
    border-right: none;
    border-bottom: none;
    height: 100%;
  }
  .preview-pane {
    flex: 1;
    height: 100%;
    display: none;
  }

  /* Mode toggle states */
  body.preview-mode .editor-pane  { display: none; }
  body.preview-mode .preview-pane { display: block; }

  /* Preview content */
  .preview-content { padding: 16px 14px; font-size: 14px; }

  /* EasyMDE toolbar: smaller icons */
  .editor-toolbar { padding: 2px 4px !important; }
  .editor-toolbar button { width: 28px !important; height: 28px !important; }

  /* Status bar: hide chars on mobile, keep words + lines */
  .status-bar {
    font-size: 10px;
    gap: 6px;
    height: auto;
    min-height: calc(var(--status-height) + env(safe-area-inset-bottom, 0px));
    padding: 0 8px calc(env(safe-area-inset-bottom, 0px) + 2px);
    box-sizing: border-box;
  }
  /* Hide chars and both its surrounding separators */
  #status-chars,
  #status-chars + .status-sep,
  .status-sep:has(+ #status-chars) { display: none; }

  /* ---- BOTTOM TOOLBAR ---- */
  .bottom-toolbar {
    height: 48px;
    background: var(--color-navbar);
    border-top: 1px solid var(--color-border);
    padding: 0 8px;
    gap: 4px;
    justify-content: space-around;
    align-items: center;
    flex-shrink: 0;
  }
  .btb-btn {
    flex: 1;
    height: 36px;
    min-width: 0;
    background: var(--color-btn);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 14px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .btb-btn:active { background: var(--color-accent); color: #fff; }
  .btb-bold   { font-weight: 700; }
  .btb-italic { font-style: italic; }
  .btb-code   { font-family: var(--font-mono); font-size: 12px; }

  /* ---- SWIPE PAGE INDICATOR ---- */
  .swipe-dots {
    height: 16px;
    background: var(--color-navbar);
    border-bottom: 1px solid var(--color-border);
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
  }
  .swipe-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-border);
    transition: background 0.2s;
  }
  #dot-edit   { background: var(--color-accent); }
  #dot-preview { background: var(--color-border); }
  body.preview-mode #dot-edit    { background: var(--color-border); }
  body.preview-mode #dot-preview { background: var(--color-accent); }

  /* ---- SHORTCUTS PANEL (portrait: bottom sheet) ---- */
  #shortcuts-panel {
    /* Reset floating panel positioning */
    top: auto !important;
    right: auto !important;
    left: 0;
    bottom: 0;
    width: 100%;
    min-width: unset;
    height: 70vh;
    border-radius: 12px 12px 0 0;
    border: none;
    border-top: 1px solid var(--color-border);
    box-shadow: none;
    z-index: 1200;
    /* Bottom sheet slide animation */
    transform: translateY(100%);
    transition: transform 0.28s ease;
    /* Override [hidden] attr so animation works */
    display: flex !important;
    flex-direction: column;
    pointer-events: none;
  }
  #shortcuts-panel:not([hidden]) {
    transform: translateY(0);
    pointer-events: auto;
  }
  .shortcuts-panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  /* Disable drag cursor on mobile header */
  .shortcuts-panel-header { cursor: default; }
  /* Backdrop */
  .shortcuts-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
  }
  .shortcuts-backdrop.active { display: block; }

  /* ---- OUTLINE BOTTOM SHEET (portrait) ---- */
  .outline-panel {
    /* Override side-panel: reset margin-left animation */
    width: 100%;
    margin-left: 0 !important;
    flex-shrink: initial;
    /* Bottom sheet positioning */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60vh;
    border-right: none;
    border-top: 1px solid var(--color-border);
    border-radius: 12px 12px 0 0;
    z-index: 1200;
    /* Closed: off-screen below */
    transform: translateY(100%);
    transition: transform 0.28s ease;
  }
  .outline-panel.outline-open {
    transform: translateY(0);
  }
}

/* ---- SEARCH PANEL (mobile portrait) ---- */
@media (max-width: 767px) {
  .search-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    border: 1px solid var(--color-border);
    border-bottom: none;
    min-width: unset;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---- SMALL MOBILE (< 400px) ---- */
@media (max-width: 399px) {
  .tab-item { min-width: 70px; max-width: 110px; font-size: 11px; }
  .nav-logo { display: none; }
}

/* ---- TOUR: mobile overrides ---- */
@media (max-width: 767px) {
  #tour-bubble {
    width: auto;
  }
  .tour-welcome-title { font-size: 16px; }
}
