/**
 * DOM Overlay Styles for Portal AR
 * These styles apply to the 2D UI overlaid on the AR view
 */

/* Reset and base */
* {
  box-sizing: border-box;
}

/* Overlay container - covers full screen but doesn't block AR */
#dom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  z-index: 9999;
}

/* Allow pointer events on interactive children */
#dom-overlay > * {
  pointer-events: auto;
}

/* AR Entry Button */
#ar-button {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 16px 32px;
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(135deg, #4a90a4 0%, #357a8a 100%);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(74, 144, 164, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: none; /* Hidden until we check AR support */
}

#ar-button:hover:not(:disabled) {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 6px 25px rgba(74, 144, 164, 0.5);
}

#ar-button:active:not(:disabled) {
  transform: translateX(-50%) scale(0.98);
}

#ar-button:disabled {
  background: #888;
  cursor: not-allowed;
  box-shadow: none;
}

/* Posture Indicator */
#posture-indicator {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background-color 0.3s, transform 0.2s;
}

#posture-indicator.posture-changed {
  background: rgba(74, 144, 164, 0.8);
  transform: translateX(-50%) scale(1.1);
}

/* Instructions */
.instructions {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
  max-width: 80%;
  display: none; /* Hidden until in AR */
}

/* Generic overlay button style */
.overlay-btn {
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
}

.overlay-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.overlay-btn:active {
  transform: scale(0.98);
}

/* Action buttons (future: add note, add image) */
.action-btn {
  position: absolute;
  width: 56px;
  height: 56px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 50%;
}

#add-btn {
  bottom: 30px;
  right: 30px;
}

/* Safe area padding for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
  #posture-indicator {
    top: calc(20px + env(safe-area-inset-top));
  }

  #ar-button,
  .instructions {
    bottom: calc(40px + env(safe-area-inset-bottom));
  }

  .instructions {
    bottom: calc(100px + env(safe-area-inset-bottom));
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .overlay-btn {
    background: rgba(40, 40, 40, 0.95);
    color: white;
  }
}

/* Shared control bar base */
.control-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px;
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.control-bar .divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Shared button base inside control bars */
.control-bar button {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  line-height: 1;
}

.control-bar button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.control-bar button:active {
  background: rgba(255, 255, 255, 0.15);
}

/* Mode Toggle (top bar) */
.mode-toggle {
  top: 60px;
}

.mode-btn.active {
  background: #4a90a4;
  color: white;
}

/* One-shot action — visually quieter than mode toggles */
.mode-btn.mode-action {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 400;
}

.mode-btn.mode-action:hover {
  color: rgba(255, 255, 255, 0.85);
}

/* Adjustment Controls (bottom bar) */
.adjust-controls {
  bottom: 160px;
}

/* Add Note Button (floating action, shown when door is open) */
#add-note-btn {
  position: absolute;
  bottom: 100px;
  right: 24px;
  width: 52px;
  height: 52px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  background: rgba(74, 144, 164, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s, box-shadow 0.2s;
}

#add-note-btn:active {
  transform: scale(0.92);
}

/* Note Editor Modal */
.note-editor-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.note-editor-modal.visible {
  display: flex;
}

.note-editor {
  width: 85%;
  max-width: 320px;
  background: rgba(30, 30, 35, 0.95);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.note-editor textarea {
  width: 100%;
  height: 120px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  resize: none;
  outline: none;
}

.note-editor textarea:focus {
  border-color: #4a90a4;
}

.note-editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  justify-content: flex-end;
}

.note-editor-actions button {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s;
}

.note-editor-actions button:active {
  transform: scale(0.95);
}

.note-editor-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.note-editor-save {
  background: #4a90a4;
  color: white;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
