/* =============================================
   Anima Studio Mobile — CSS (responsive layout)
   ============================================= */

/* ── always visible ── */
.mobile-header,
.mobile-nav,
.mobile-sheet,
.mobile-sheet-overlay {
  display: none;
}

/* ── narrow viewport ── */
@media (max-width: 820px) {
  html.mobile-active body {
    overflow: hidden !important;
  }

  /* hide desktop panels & header */
  html.mobile-active .header { display: none !important; }
  html.mobile-active #leftPanel { display: none !important; }
  html.mobile-active #rightPanel { display: none !important; }
  html.mobile-active .timeline-panel { display: none !important; }
  html.mobile-active .resizer-v,
  html.mobile-active .resizer-h { display: none !important; }

  /* canvas fills viewport */
  html.mobile-active .workspace {
    position: fixed;
    inset: 32px 0 48px 0;
    flex: none;
    overflow: hidden;
    z-index: 1;
  }
  html.mobile-active .viewport {
    flex: 1;
    overflow: hidden;
  }

  /* ── mini header ── */
  html.mobile-active .mobile-header {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 32px;
    background: #16171f;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    align-items: center;
    padding: 0 8px;
    gap: 6px;
    z-index: 1000;
    font-size: 11px;
    -webkit-user-select: none;
    user-select: none;
  }
  html.mobile-active .mobile-header .mh-logo {
    font-weight: 800;
    color: #d4a843;
    font-size: 11px;
    letter-spacing: 0.3px;
    white-space: nowrap;
  }
  html.mobile-active .mobile-header .mh-spacer { flex: 1; }
  html.mobile-active .mobile-header .mh-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: #ddd;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
    white-space: nowrap;
    font-family: inherit;
  }
  html.mobile-active .mobile-header .mh-btn:active {
    background: rgba(255,255,255,0.1);
  }

  /* ── bottom nav ── */
  html.mobile-active .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 48px;
    background: #16171f;
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 1000;
    padding: 0 2px;
  }
  html.mobile-active .mobile-nav .mn-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 9px;
    padding: 4px 2px;
    border-radius: 4px;
    margin: 4px 2px;
    transition: all 0.15s;
    font-family: inherit;
  }
  html.mobile-active .mobile-nav .mn-btn:active,
  html.mobile-active .mobile-nav .mn-btn.active {
    color: #d4a843;
    background: rgba(212,168,67,0.12);
  }
  html.mobile-active .mobile-nav .mn-btn svg {
    width: 18px;
    height: 18px;
  }

  /* ── sheet overlay ── */
  html.mobile-active .mobile-sheet-overlay {
    display: block;
    position: fixed;
    inset: 32px 0 0 0;
    z-index: 499;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  html.mobile-active .mobile-sheet-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── bottom sheet ── */
  html.mobile-active .mobile-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; right: 0;
    bottom: 48px;
    max-height: 65vh;
    z-index: 500;
    background: #181a26;
    border-top: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 30px rgba(0,0,0,0.5);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(.32,.72,0,1);
    overflow: visible;
  }
  html.mobile-active .mobile-sheet.open {
    transform: translateY(0);
  }

  /* handle */
  html.mobile-active .mobile-sheet .ms-handle {
    flex: none;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #181a26;
    border-radius: 14px 14px 0 0;
  }
  html.mobile-active .mobile-sheet .ms-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.18);
  }

  /* sheet body (scrollable) */
  html.mobile-active .mobile-sheet .ms-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 10px 10px;
    min-height: 0;
  }
  html.mobile-active .mobile-sheet .ms-body::-webkit-scrollbar { width: 4px; }
  html.mobile-active .mobile-sheet .ms-body::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

  /* sheet header (tab title bar) */
  html.mobile-active .mobile-sheet .ms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 10px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #ccc;
  }
  html.mobile-active .mobile-sheet .ms-header .ms-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
  }
  html.mobile-active .mobile-sheet .ms-header .ms-close:active {
    background: rgba(255,255,255,0.08);
  }

  /* ── cloned content tweaks ── */
  html.mobile-active .mobile-sheet .tools-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: 8px;
  }
  html.mobile-active .mobile-sheet .tools-grid .tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.1s;
  }
  html.mobile-active .mobile-sheet .tools-grid .tool-btn:active {
    background: rgba(255,255,255,0.1);
  }
  html.mobile-active .mobile-sheet .tools-grid .tool-separator { display: none; }

  /* compact rows in sheet */
  html.mobile-active .mobile-sheet .row {
    gap: 5px;
    padding: 3px 0;
  }
  html.mobile-active .mobile-sheet .row label {
    font-size: 10px;
  }

  /* hide interactive elements that need accurate mouse (gradient bars, resize handles etc) */
  html.mobile-active .mobile-sheet #gradientBarContainer,
  html.mobile-active .mobile-sheet #strokeGradientBarContainer,
  html.mobile-active .mobile-sheet .layers-resize-handle {
    display: none !important;
  }

  /* make select/input fit better */
  html.mobile-active .mobile-sheet select,
  html.mobile-active .mobile-sheet input[type="number"],
  html.mobile-active .mobile-sheet input[type="text"],
  html.mobile-active .mobile-sheet input[type="color"] {
    font-size: 11px !important;
  }
  html.mobile-active .mobile-sheet input[type="range"] {
    height: 20px;
  }

  /* layer list items */
  html.mobile-active .mobile-sheet .layer-list .layer-item {
    padding: 6px 8px;
    font-size: 10px;
  }

  /* group header in sheet */
  html.mobile-active .mobile-sheet .group-header {
    font-size: 9px;
    padding: 7px 8px;
  }
}
