/* ==========================================================================
   Sorouh Science Labs (Port 8080) - Mobile & Tablet Tactile HUD Components
   Strictly <= 250 lines compliant
   ========================================================================== */
@import url('mobile-labs-harmonizer.css');

/* 1. Canvas Touch Isolation & Protection */
canvas.lab-canvas, #webglContainer canvas, .viewport-canvas canvas, #canvas-container canvas, #viewport-container canvas, .physics-canvas-container canvas, .space-canvas-container canvas, .comp-canvas-layer, #webgl-canvas, canvas#viewport {
  touch-action: none !important;
  width: 100% !important;
  height: 100% !important;
  display: block;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* 2. Ultra-Compact Micro-Header (<= 44px) */
.tactile-micro-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--mobile-header-height, 42px);
  max-height: var(--mobile-header-max, 44px);
  padding: 0 var(--safe-pad-right, 10px) 0 var(--safe-pad-left, 10px);
  padding-top: var(--safe-area-top, 0px);
  background: linear-gradient(180deg, #13161d 0%, #080a0e 100%);
  border-bottom: 1px solid var(--mobile-border-subtle, rgba(255, 255, 255, 0.12));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.85), inset 0 1px 0 var(--mobile-bevel-top, rgba(255, 255, 255, 0.28));
  display: flex; align-items: center; justify-content: space-between;
  z-index: 80; user-select: none;
}
.tactile-micro-header .header-brand {
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: var(--mobile-text-title, 14px); color: #fff;
}
.tactile-micro-header .header-actions {
  display: flex; align-items: center; gap: 6px;
}
.tactile-micro-header .header-btn {
  min-width: var(--touch-target-compact, 44px); min-height: var(--touch-target-compact, 44px);
  background: linear-gradient(180deg, #1c202a 0%, #0d0f14 100%);
  border: 1px solid var(--mobile-border-subtle, rgba(255, 255, 255, 0.14));
  border-radius: var(--mobile-radius-sm, 8px); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--mobile-trans-tap);
}
.tactile-micro-header .header-btn:active { transform: translateY(2px); }

/* 3. Floating Action Buttons (FAB, >= 48px) */
.tactile-fab {
  position: fixed; z-index: 85;
  min-width: var(--touch-target-min, 48px); min-height: var(--touch-target-min, 48px);
  width: var(--touch-target-fab, 52px); height: var(--touch-target-fab, 52px);
  border-radius: 50%;
  background: linear-gradient(180deg, var(--mobile-bg-surface, #181b24) 0%, var(--mobile-bg-base, #0a0c10) 100%);
  border: 1px solid var(--mobile-border-medium, rgba(255, 255, 255, 0.22));
  box-shadow: var(--mobile-shadow-fab);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; transition: var(--mobile-trans-tap);
}
.tactile-fab:active {
  transform: translateY(3px) scale(0.96);
  box-shadow: var(--mobile-shadow-fab-pressed);
}
.tactile-fab .fab-well {
  width: var(--touch-icon-well, 38px); height: var(--touch-icon-well, 38px);
  border-radius: 50%;
  background: linear-gradient(180deg, #050608 0%, #10131a 100%);
  box-shadow: var(--mobile-shadow-well);
  display: flex; align-items: center; justify-content: center;
}
.tactile-fab .fab-led {
  position: absolute; top: 3px; right: 8px; width: 6px; height: 6px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.25);
}
.tactile-fab .fab-led.led-chem { background: var(--led-chem, #f59e0b); box-shadow: 0 0 6px var(--led-glow-chem); }
.tactile-fab .fab-led.led-phys { background: var(--led-phys, #00b4d8); box-shadow: 0 0 6px var(--led-glow-phys); }
.tactile-fab .fab-led.led-bio { background: var(--led-bio, #10b981); box-shadow: 0 0 6px var(--led-glow-bio); }
.tactile-fab .fab-led.led-tutor { background: var(--led-tutor, #a855f7); box-shadow: 0 0 6px var(--led-glow-tutor); }

.fab-bottom-right { bottom: calc(var(--safe-pad-bottom, 12px) + 64px); right: var(--safe-pad-right, 12px); }
.fab-bottom-left { bottom: calc(var(--safe-pad-bottom, 12px) + 64px); left: var(--safe-pad-left, 12px); }
.fab-top-right { top: calc(var(--mobile-header-height, 42px) + 12px); right: var(--safe-pad-right, 12px); }

/* 4. Tactile Bottom Sheet */
.tactile-bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--mobile-bg-sheet, #0e1117);
  border-top: 1px solid var(--mobile-border-medium, rgba(255, 255, 255, 0.22));
  border-radius: var(--mobile-radius-sheet, 20px 20px 0 0);
  box-shadow: var(--mobile-shadow-sheet);
  padding: 8px var(--safe-pad-right, 12px) calc(var(--safe-area-bottom, 0px) + 8px) var(--safe-pad-left, 12px);
  transform: translateY(calc(100% - var(--mobile-sheet-collapsed-height, 48px)));
  transition: var(--mobile-trans-sheet);
  display: flex; flex-direction: column;
}
.tactile-bottom-sheet.is-peek {
  transform: translateY(calc(100% - var(--mobile-sheet-peek-height, 120px)));
}
.tactile-bottom-sheet.is-expanded {
  transform: translateY(0);
  max-height: var(--mobile-sheet-expanded-height, 72vh);
}
.tactile-bottom-sheet.is-hidden { transform: translateY(100%); }

.tactile-sheet-handle {
  width: 38px; height: 5px; margin: 4px auto 10px;
  background: rgba(255, 255, 255, 0.25); border-radius: var(--mobile-radius-pill, 9999px);
  cursor: grab;
}
.tactile-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 34px; padding: 0 4px 6px;
}
.tactile-sheet-content {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-height: calc(var(--mobile-sheet-expanded-height, 72vh) - 70px);
  padding: 6px 2px;
}

/* 5. Sliding Tactile Side Drawer */
.tactile-drawer {
  position: fixed; top: 0; bottom: 0; z-index: 95;
  width: min(var(--mobile-drawer-width-phone, 280px), 85vw);
  background: var(--mobile-bg-drawer, #0c0e14);
  box-shadow: var(--mobile-shadow-drawer);
  transition: var(--mobile-trans-drawer);
  display: flex; flex-direction: column;
  padding: var(--safe-pad-top, 8px) var(--safe-pad-right, 10px) var(--safe-pad-bottom, 12px) var(--safe-pad-left, 10px);
}
[dir="rtl"] .tactile-drawer, .tactile-drawer-right {
  right: 0; transform: translateX(100%);
  border-left: 1px solid var(--mobile-border-medium, rgba(255, 255, 255, 0.2));
}
[dir="ltr"] .tactile-drawer, .tactile-drawer-left {
  left: 0; transform: translateX(-100%);
  border-right: 1px solid var(--mobile-border-medium, rgba(255, 255, 255, 0.2));
}
.tactile-drawer.is-open { transform: translateX(0) !important; }

.tactile-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px); z-index: 94;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.tactile-drawer-backdrop.is-visible { opacity: 1; pointer-events: auto; }

/* 6. Fullscreen Overlay Cards for Mobile Inspection */
.tactile-overlay-card {
  position: fixed; inset: 0; z-index: 100;
  background: var(--mobile-bg-overlay, rgba(0, 0, 0, 0.88));
  display: flex; align-items: center; justify-content: center;
  padding: var(--safe-pad-top, 12px) var(--safe-pad-right, 12px) var(--safe-pad-bottom, 12px) var(--safe-pad-left, 12px);
  opacity: 0; pointer-events: none; transition: opacity 0.24s ease;
}
.tactile-overlay-card.is-active { opacity: 1; pointer-events: auto; }

.tactile-overlay-card .overlay-card-panel {
  background: linear-gradient(180deg, var(--mobile-bg-surface, #181b24) 0%, var(--mobile-bg-card, #141720) 100%);
  border: 1px solid var(--mobile-border-bright, rgba(255, 255, 255, 0.45));
  border-radius: var(--mobile-radius-lg, 18px);
  box-shadow: var(--mobile-shadow-card);
  width: 100%; max-width: 580px; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.tactile-overlay-card .overlay-header {
  padding: 12px 16px; border-bottom: 1px solid var(--mobile-border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.tactile-overlay-card .overlay-body {
  padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}

/* 7. Responsive Media Queries (360px - 1366px) */

/* Mobile Portrait (360px - 480px) */
@media screen and (max-width: 480px) {
  .tactile-overlay-card .overlay-card-panel {
    max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; border: none;
  }
  .tactile-bottom-sheet { width: 100%; }
}

/* Mobile Landscape (481px - 768px with Height < 500px) */
@media screen and (min-width: 481px) and (max-width: 768px) and (orientation: landscape),
       screen and (max-height: 500px) and (orientation: landscape) {
  .tactile-micro-header { height: 38px; }
  .tactile-fab {
    min-width: var(--touch-target-compact, 44px); min-height: var(--touch-target-compact, 44px);
    width: 46px; height: 46px;
  }
  .fab-bottom-right, .fab-bottom-left { bottom: 12px; }
  .tactile-bottom-sheet {
    max-width: 360px; left: auto; right: var(--safe-pad-right, 10px);
    border-radius: var(--mobile-radius-md, 12px);
  }
}

/* Tablet Portrait (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
  .tactile-drawer { width: var(--mobile-drawer-width-tablet, 340px); }
  .tactile-bottom-sheet { max-width: 600px; margin: 0 auto; left: 10px; right: 10px; }
}

/* Tablet Landscape (1025px - 1366px) */
@media screen and (min-width: 1025px) and (max-width: 1366px) {
  .tactile-drawer { width: 360px; }
  .tactile-bottom-sheet { max-width: 720px; margin: 0 auto; left: 20px; right: 20px; }
}
