# m3-daedalus — portable laptop (standalone home-manager).
# Context: desktop | Profiles: coding, media
{
  config,
  lib,
  ...
}: let
  homeLib = import ../lib {inherit lib;};
in
  with lib; {
    imports = [
      (homeLib.mkHomeConfig {
        profiles = ["coding" "media"];
        context = "desktop";
      })
      ./home.nix
    ];

    config = mkMerge [
      {
        # Base CLI tools (new namespace)
        base = {
          shell = {
            fish.enable = true;
            nushell.enable = true;
            starship.enable = true;
          };
          cliTools = {
            fzf.enable = true;
            nitch.enable = true;
            television.enable = true;
          };
          secrets.enable = true;
        };

        # Desktop features (new namespace)
        desktop = {
          wm = {
            hyprland.enable = false;
            rofi.enable = true;
            wayland.enable = false;
          };
          apps = {
            obsidian.enable = true;
            office.enable = false;
            crypto.enable = false;
          };
          theme = {
            fonts.enable = true;
            wallpapers.enable = false;
          };
        };

        # Coding environment
        coding = {
          editors = {
            neovim.enable = true;
            zed.enable = true;
          };
          lsp.enable = true;
        };

        # Media profile features
        profiles.media = {
          obs.enable = false;
          ffmpeg.enable = false;
          kdenlive.enable = false;
          ytDlp.enable = true;
        };

        xdg = {
          enable = true;
          configFile."mimeapps.list".force = true;
          mimeApps = {
            enable = true;
            associations.added = {
              "application/zip" = ["org.gnome.FileRoller.desktop"];
              "application/csv" = ["calc.desktop"];
              "application/pdf" = ["vivaldi-stable.desktop"];
              "x-scheme-handler/http" = ["vivaldi-stable.desktop"];
              "x-scheme-handler/https" = ["vivaldi-stable.desktop"];
            };
            defaultApplications = {
              "application/zip" = ["org.gnome.FileRoller.desktop"];
              "application/csv" = ["calc.desktop"];
              "application/pdf" = ["vivaldi-stable.desktop"];
              "application/md" = ["dev.zed.Zed.desktop"];
              "application/text" = ["dev.zed.Zed.desktop"];
              "x-scheme-handler/http" = ["vivaldi-stable.desktop"];
              "x-scheme-handler/https" = ["vivaldi-stable.desktop"];
            };
          };
        };
      }

      # Host-specific Hyprland layout — only applies when hyprland is enabled
      (mkIf config.desktop.wm.hyprland.enable {
        wayland.windowManager.hyprland = {
          enable = true;
          settings = {
            monitor = [
              "eDP-1,preferred,0x0,1.25"
              "HDMI-A-1,preferred,2560x0,1"
            ];
            workspace = [
              "1, monitor:eDP-1, default:true"
              "2, monitor:eDP-1"
              "3, monitor:eDP-1"
              "4, monitor:HDMI-A-1"
              "5, monitor:HDMI-A-1,border:false,rounding:false"
              "6, monitor:HDMI-A-1"
            ];
            windowrule = [
              "match:class dev.zed.Zed, workspace 1"
              "match:class Msty, workspace 1"
              "match:class ^(com.obsproject.Studio)$, workspace 2"
              "match:class ^(brave-browser)$, workspace 4, opacity 1.0"
              "match:class ^(vivaldi-stable)$, workspace 4, opacity 1.0"
              "match:class ^steam_app_\\d+$, fullscreen on"
              "match:class ^steam_app_\\d+$, workspace 5"
              "match:class ^steam_app_\\d+$, idle_inhibit focus"
            ];
          };
        };
      })
    ];
  }
