/* layout.css (layout + structure) */
/* Split from legacy style.css */

.container {
  /* Flex column prevents global `.body { grid-area: body }` rules from reordering children */
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--dark-bg);
}

/* Header */
/* Unified Header */
header.unified-header,
.unified-header {
  width: 100%;
  color: var(--text-primary);
  background: linear-gradient(to bottom, rgba(10, 10, 15, 0.98), rgba(8, 8, 12, 0.95));
  border-bottom: 1px solid rgba(0, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  padding: 0.5rem 0.75rem;
  z-index: 6000;
  position: sticky;
  top: 0;
  overflow: visible !important;
}

.unified-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  overflow: visible !important;
}

.unified-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  margin-right: 0.5rem;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  text-shadow: none !important;
}

.brand-name .highlight {
  color: var(--neon-pink);
  text-shadow: none !important;
}

.menu-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.menu-divider-vertical {
  height: 24px;
  width: 1px;
  border: none;
  background: rgba(0, 255, 255, 0.2);
  margin: 0 0.75rem;
}

.play-button-nav {
  color: var(--neon-cyan) !important;
  font-weight: 800 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.play-button-nav.playing {
  color: var(--neon-pink) !important;
}

.solve-button-nav {
  color: var(--text-secondary) !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.solve-button-nav.active {
  color: var(--neon-pink) !important;
  border-color: rgba(255, 0, 255, 0.3) !important;
}

.home-btn-nav {
  font-size: 1.2rem !important;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.5rem !important;
  transition: transform 0.2s ease;
}

.home-btn-nav:hover {
  transform: scale(1.15);
  background: transparent !important;
  border-color: transparent !important;
}

.menu-item {
  position: relative;
}

.menu-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.menu-btn:hover {
  background: rgba(0, 255, 255, 0.08);
  color: var(--neon-cyan);
  border-color: rgba(0, 255, 255, 0.15);
}

.menu-item:hover .menu-dropdown {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: rgba(10, 10, 15, 0.98);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.menu-dropdown button,
.menu-dropdown-btn,
.menu-link {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: block;
  width: 100%;
}

.menu-dropdown button:hover,
.menu-dropdown-btn:hover,
.menu-link:hover {
  background: rgba(0, 255, 255, 0.12);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}

.menu-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  gap: 1rem;
}

.menu-toggle-item label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  flex: 1;
}

.menu-toggle-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--neon-cyan);
  width: 16px;
  height: 16px;
}

.menu-divider {
  border: 0;
  height: 1px;
  background: rgba(0, 255, 255, 0.1);
  margin: 0.4rem 0.25rem;
}

/* Workspace Controls Integration */
.workspace-controls-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(0, 255, 255, 0.15);
  border-radius: 8px;
  padding: 2px;
  transition: all 0.3s ease;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
}

.workspace-controls-wrapper:hover {
  border-color: rgba(0, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.workspace-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  padding: 2px 4px;
}

.workspace-zoom-pct {
  min-width: 54px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.workspace-help-container {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.workspace-help-btn {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  font-weight: bold;
  font-size: 14px;
  margin-left: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.workspace-help-tooltip {
  position: absolute;
  top: calc(100% + 15px);
  right: -5px;
  width: 240px;
  background: rgba(10, 10, 15, 0.98);
  border: 1px solid var(--neon-cyan);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), var(--glow-cyan-soft);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  visibility: hidden;
}

.workspace-help-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 12px;
  border-width: 8px;
  border-style: solid;
  border-color: transparent transparent var(--neon-cyan) transparent;
}

.workspace-help-container:hover .workspace-help-tooltip,
.workspace-help-container:focus-within .workspace-help-tooltip,
.workspace-help-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.workspace-help-tooltip .workspace-title {
  color: var(--neon-cyan);
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  padding-bottom: 6px;
  text-align: left;
}

.workspace-help-tooltip .workspace-hint {
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.5;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  text-align: left;
  white-space: normal;
}

.workspace-help-tooltip .workspace-hint:last-child {
  margin-bottom: 0;
}

.workspace-help-tooltip .workspace-hint::before {
  content: "•";
  margin-right: 10px;
  color: var(--neon-cyan);
  flex-shrink: 0;
  font-weight: bold;
}

.shortcut-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.shortcut-btn {
  font-size: 1.1rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 6px !important;
}

.unified-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
}

.mobile-nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  line-height: 1;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 255, 0.22);
  background: rgba(0, 255, 255, 0.06);
  color: var(--neon-cyan);
  font-weight: 900;
  letter-spacing: 0.02em;
  font-size: 18px;
}

.mobile-nav-toggle:hover {
  border-color: var(--dark-border-hover);
  background: rgba(0, 255, 255, 0.10);
}

/* Mobile left nav drawer (only enabled on ≤901px) */
.mobile-nav-overlay,
.mobile-nav-drawer {
  display: none;
}

/* Body Layout */
.body {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  overflow: hidden;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  z-index: 200;
}

@media screen and (min-width: 901px) {
  .body {
    grid-template-columns: 1fr;
    height: calc(100dvh - 56px);
    overflow: hidden;
  }

  .content {
    overflow: hidden;
    min-width: 0;
  }

  .sidebar {
    display: none;
  }
}


/* Content Area */
.content {
  background: var(--dark-bg);
  scrollbar-color: rgba(0, 255, 255, 0.2) transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: auto;
  padding: 0.5rem 0.6rem;
}

/* Player container for canvas */
#player {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
  touch-action: none;
}

#player.zoomed {
  display: block;
  overflow: auto;
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 255, 0.25) transparent;
}

#player.zoomed.dragging {
  cursor: grabbing;
}

#player canvas {
  display: block;
}

.canvas-hud-btn {
  min-width: 38px;
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 255, 0.22);
  background: rgba(0, 255, 255, 0.06);
  color: var(--neon-cyan);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.canvas-hud-btn:hover {
  border-color: var(--dark-border-hover);
  background: rgba(0, 255, 255, 0.12);
}

.canvas-hud-btn--reset {
  min-width: 64px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

/* Mobile responsive fixes */
@media screen and (max-width: 901px) {
  .unified-header-content {
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
  }

  /* Hide all menu-bar content except workspace zoom controls; keep zoom in nav */
  .menu-bar {
    display: flex !important;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
  }

  .menu-bar > *:not(.workspace-controls-wrapper) {
    display: none !important;
  }

  .mobile-nav-toggle {
    display: inline-grid;
    place-items: center;
  }

  .mobile-nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    z-index: 17500;
  }

  .mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile drawer – standard slide-in navigation */
  .mobile-nav-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(85vw, 300px);
    max-width: 300px;
    background: #1a1b1f;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 17501;
    overflow: hidden;
  }

  .mobile-nav-drawer.open {
    transform: translateX(0);
  }

  .mobile-nav-drawer .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: 56px;
    padding: 0 16px;
    background: #1a1b1f;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-nav-drawer .mobile-nav-title {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.02em;
  }

  .mobile-nav-drawer .mobile-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 -8px 0 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.25rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-drawer .mobile-nav-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }

  .mobile-nav-drawer .mobile-nav-close:active {
    background: rgba(255, 255, 255, 0.12);
  }

  /* Section spacing – section titles and link groups don’t grow */
  .mobile-nav-drawer > .mobile-nav-section,
  .mobile-nav-drawer > .mobile-nav-links,
  .mobile-nav-drawer > .mobile-drawer-actions,
  .mobile-nav-drawer > .mobile-drawer-workspace {
    flex-shrink: 0;
  }

  /* Collapsible section container */
  .mobile-nav-drawer .mobile-nav-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .mobile-nav-drawer .mobile-nav-section:last-of-type {
    border-bottom: none;
  }

  /* Reset native details/summary marker; summary = clickable section title */
  .mobile-nav-drawer .mobile-nav-section summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-drawer .mobile-nav-section summary::-webkit-details-marker,
  .mobile-nav-drawer .mobile-nav-section summary::marker {
    display: none;
  }

  /* Chevron: down when closed, rotates up when open */
  .mobile-nav-drawer .mobile-nav-section summary::after {
    content: '\25BE';
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
    transition: transform 0.2s ease;
  }

  .mobile-nav-drawer .mobile-nav-section[open] summary::after {
    transform: rotate(180deg);
  }

  .mobile-nav-drawer .mobile-nav-section-title {
    padding: 20px 16px 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
  }

  .mobile-nav-drawer .mobile-nav-section:first-of-type .mobile-nav-section-title {
    padding-top: 12px;
  }

  .mobile-nav-drawer .mobile-nav-links {
    display: flex;
    flex-direction: column;
    padding: 0 8px 8px;
  }

  .mobile-nav-drawer .mobile-nav-link {
    display: block;
    width: 100%;
    margin: 0;
    padding: 12px 12px;
    min-height: 44px;
    box-sizing: border-box;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .mobile-nav-drawer .mobile-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
  }

  .mobile-nav-drawer .mobile-nav-link:active {
    background: rgba(255, 255, 255, 0.1);
  }

  .mobile-nav-drawer .mobile-drawer-actions {
    padding: 0 8px 8px;
  }

  .mobile-nav-drawer .mobile-drawer-actions .maze-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .mobile-nav-drawer .mobile-drawer-actions .mobile-nav-link {
    margin: 0;
  }

  .mobile-nav-drawer .mobile-drawer-divider,
  .mobile-nav-drawer hr.mobile-drawer-divider {
    margin: 8px 16px;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-nav-drawer #mobileDrawerTitleSlot.mobile-drawer-title,
  .mobile-nav-drawer .mobile-drawer-title {
    flex-shrink: 0;
  }

  .mobile-nav-drawer .mobile-drawer-workspace {
    padding: 0 8px 8px;
  }

  /* Scrollable region: everything after header */
  .mobile-nav-drawer {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(200px, 45%);
    height: calc(100dvh - 50px);
  }

  .body.settings-closed .sidebar {
    display: none;
  }

  .body.settings-closed {
    grid-template-rows: 1fr;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    border-top: 1px solid var(--dark-border);
    display: flex;
    flex-direction: column;
    background: rgba(5, 5, 10, 0.6);
  }

  .mobile-settings-slot {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }

  .modal-overlay.in-mobile-slot {
    position: static;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: transparent;
  }

  .modal-overlay.in-mobile-slot.hidden {
    display: none;
  }

  .modal-overlay.in-mobile-slot .modal-container {
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: 100%;
  }

  .modal-overlay.in-mobile-slot .modal-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Maximize button: visible only when modal is in the mobile slot */
  .modal-overlay .mobile-maximize-btn {
    display: none;
  }

  .modal-overlay.in-mobile-slot .mobile-maximize-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 4px 0 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }

  .modal-overlay.in-mobile-slot .mobile-maximize-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }

  .modal-overlay.in-mobile-slot .mobile-maximize-btn:active {
    background: rgba(255, 255, 255, 0.12);
  }

  /* Maximized state: section fills viewport */
  .modal-overlay.in-mobile-slot.maximized {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 18000;
    background: #0a0a0f;
  }

  .modal-overlay.in-mobile-slot.maximized .modal-container {
    max-height: 100%;
  }
}

/* Sidebar and general buttons */
.sidebar-close {
  display: none;
}

@media screen and (max-width: 901px) {
  .sidebar-close {
    display: block;
  }
}

/* Mobile Settings Toggle */
.mobile-settings-toggle {
  padding: 0.5rem 1rem;
  border: 1px solid var(--dark-border);
  border-radius: 4px;
  background: rgba(0, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mobile-settings-toggle:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
  background: rgba(0, 255, 255, 0.1);
  color: var(--neon-cyan);
}
