/// Returns the platform-appropriate Wolf3D config directory path.
///
/// This file is only ever imported by native (dart:io) code paths and must
/// never be loaded on web.
library;

import 'dart:io';

/// Returns the Wolf3D config directory for the current platform.
///
/// - Linux: `$XDG_CONFIG_HOME/wolf3d` (defaults to `~/.config/wolf3d`)
/// - macOS: `~/Library/Application Support/wolf3d`
/// - Windows: `%APPDATA%/wolf3d`
/// - Other: `~/.config/wolf3d`
String platformConfigDir() {
  if (Platform.isLinux) {
    final String xdg = Platform.environment['XDG_CONFIG_HOME'] ?? '';
    final String home = Platform.environment['HOME'] ?? '.';
    return xdg.isNotEmpty ? '$xdg/wolf3d' : '$home/.config/wolf3d';
  }
  if (Platform.isMacOS) {
    final String home = Platform.environment['HOME'] ?? '.';
    return '$home/Library/Application Support/wolf3d';
  }
  if (Platform.isWindows) {
    final String appData = Platform.environment['APPDATA'] ?? '.';
    return '$appData/wolf3d';
  }
  final String home = Platform.environment['HOME'] ?? '.';
  return '$home/.config/wolf3d';
}
